|
|
@@ -12,6 +12,7 @@
|
|
|
|
|
|
#include <cm/optional>
|
|
|
|
|
|
+#include "cmConstStack.h"
|
|
|
#include "cmSystemTools.h"
|
|
|
|
|
|
/** \class cmListFileCache
|
|
|
@@ -128,6 +129,17 @@ public:
|
|
|
{
|
|
|
}
|
|
|
|
|
|
+ static cmListFileContext FromListFilePath(std::string const& filePath)
|
|
|
+ {
|
|
|
+ // We are entering a file-level scope but have not yet reached
|
|
|
+ // any specific line or command invocation within it. This context
|
|
|
+ // is useful to print when it is at the top but otherwise can be
|
|
|
+ // skipped during call stack printing.
|
|
|
+ cmListFileContext lfc;
|
|
|
+ lfc.FilePath = filePath;
|
|
|
+ return lfc;
|
|
|
+ }
|
|
|
+
|
|
|
static cmListFileContext FromListFileFunction(
|
|
|
cmListFileFunction const& lff, std::string const& fileName,
|
|
|
cm::optional<std::string> deferId = {})
|
|
|
@@ -146,38 +158,16 @@ bool operator<(const cmListFileContext& lhs, const cmListFileContext& rhs);
|
|
|
bool operator==(cmListFileContext const& lhs, cmListFileContext const& rhs);
|
|
|
bool operator!=(cmListFileContext const& lhs, cmListFileContext const& rhs);
|
|
|
|
|
|
-// Represent a backtrace (call stack). Provide value semantics
|
|
|
-// but use efficient reference-counting underneath to avoid copies.
|
|
|
+// Represent a backtrace (call stack) with efficient value semantics.
|
|
|
class cmListFileBacktrace
|
|
|
+ : public cmConstStack<cmListFileContext, cmListFileBacktrace>
|
|
|
{
|
|
|
-public:
|
|
|
- // Default-constructed backtrace is empty.
|
|
|
- cmListFileBacktrace() = default;
|
|
|
-
|
|
|
- // Get a backtrace with the given file scope added to the top.
|
|
|
- cmListFileBacktrace Push(std::string const& file) const;
|
|
|
-
|
|
|
- // Get a backtrace with the given call context added to the top.
|
|
|
- cmListFileBacktrace Push(cmListFileContext const& lfc) const;
|
|
|
-
|
|
|
- // Get a backtrace with the top level removed.
|
|
|
- // May not be called until after a matching Push.
|
|
|
- cmListFileBacktrace Pop() const;
|
|
|
-
|
|
|
- // Get the context at the top of the backtrace.
|
|
|
- // This may be called only if Empty() would return false.
|
|
|
- cmListFileContext const& Top() const;
|
|
|
-
|
|
|
- // Return true if this backtrace is empty.
|
|
|
- bool Empty() const;
|
|
|
-
|
|
|
-private:
|
|
|
- struct Entry;
|
|
|
- std::shared_ptr<Entry const> TopEntry;
|
|
|
- cmListFileBacktrace(std::shared_ptr<Entry const> parent,
|
|
|
- cmListFileContext const& lfc);
|
|
|
- cmListFileBacktrace(std::shared_ptr<Entry const> top);
|
|
|
+ using cmConstStack::cmConstStack;
|
|
|
+ friend class cmConstStack<cmListFileContext, cmListFileBacktrace>;
|
|
|
};
|
|
|
+#ifndef cmListFileCache_cxx
|
|
|
+extern template class cmConstStack<cmListFileContext, cmListFileBacktrace>;
|
|
|
+#endif
|
|
|
|
|
|
// Wrap type T as a value with a backtrace. For purposes of
|
|
|
// ordering and equality comparison, only the original value is
|