diff options
author | Brad King <brad.king@kitware.com> | 2021-12-07 16:26:58 -0500 |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2021-12-08 10:03:48 -0500 |
commit | 7b677dbb9279a575ec6b5f79daa78acfec241b6a (patch) | |
tree | ab5fd2b922892ea90e153e6f3d082b0447ce4588 | |
parent | 56dc22d48829860b50a441dcc26de14150ad724c (diff) | |
download | cmake-7b677dbb9279a575ec6b5f79daa78acfec241b6a.tar.gz |
cmListFileBacktrace: Remove unused "bottom" entry
All uses of `GetBottom` by clients have been removed, so drop the
method and its supporting infrastructure.
-rw-r--r-- | Source/CTest/cmCTestTestHandler.cxx | 2 | ||||
-rw-r--r-- | Source/cmListFileCache.cxx | 50 | ||||
-rw-r--r-- | Source/cmListFileCache.h | 13 | ||||
-rw-r--r-- | Source/cmMakefile.cxx | 1 |
4 files changed, 6 insertions, 60 deletions
diff --git a/Source/CTest/cmCTestTestHandler.cxx b/Source/CTest/cmCTestTestHandler.cxx index 02db0c6500..75777ab480 100644 --- a/Source/CTest/cmCTestTestHandler.cxx +++ b/Source/CTest/cmCTestTestHandler.cxx @@ -2183,7 +2183,7 @@ bool cmCTestTestHandler::SetTestsProperties( // Ensure we have complete triples otherwise the data is corrupt. if (triples.size() % 3 == 0) { cmState state(cmState::Unknown); - rt.Backtrace = cmListFileBacktrace(state.CreateBaseSnapshot()); + rt.Backtrace = cmListFileBacktrace(); // the first entry represents the top of the trace so we need to // reconstruct the backtrace in reverse diff --git a/Source/cmListFileCache.cxx b/Source/cmListFileCache.cxx index 4c434a3e4b..c167db5ee2 100644 --- a/Source/cmListFileCache.cxx +++ b/Source/cmListFileCache.cxx @@ -443,45 +443,19 @@ cm::optional<cmListFileContext> cmListFileParser::CheckNesting() const return cm::nullopt; } -// We hold either the bottom scope of a directory or a call/file context. -// Discriminate these cases via the parent pointer. +// We hold a call/file context. struct cmListFileBacktrace::Entry { - Entry(cmStateSnapshot bottom) - : Bottom(bottom) - { - } - Entry(std::shared_ptr<Entry const> parent, cmListFileContext lfc) : Context(std::move(lfc)) , Parent(std::move(parent)) { } - ~Entry() - { - if (this->Parent) { - this->Context.~cmListFileContext(); - } else { - this->Bottom.~cmStateSnapshot(); - } - } - - bool IsBottom() const { return !this->Parent; } - - union - { - cmStateSnapshot Bottom; - cmListFileContext Context; - }; + cmListFileContext Context; std::shared_ptr<Entry const> Parent; }; -cmListFileBacktrace::cmListFileBacktrace(cmStateSnapshot const& snapshot) - : TopEntry(std::make_shared<Entry const>(snapshot.GetCallStackBottom())) -{ -} - /* NOLINTNEXTLINE(performance-unnecessary-value-param) */ cmListFileBacktrace::cmListFileBacktrace(std::shared_ptr<Entry const> parent, cmListFileContext const& lfc) @@ -494,18 +468,6 @@ cmListFileBacktrace::cmListFileBacktrace(std::shared_ptr<Entry const> top) { } -cmStateSnapshot cmListFileBacktrace::GetBottom() const -{ - cmStateSnapshot bottom; - if (Entry const* cur = this->TopEntry.get()) { - while (Entry const* parent = cur->Parent.get()) { - cur = parent; - } - bottom = cur->Bottom; - } - return bottom; -} - cmListFileBacktrace cmListFileBacktrace::Push(std::string const& file) const { // We are entering a file-level scope but have not yet reached @@ -520,22 +482,18 @@ cmListFileBacktrace cmListFileBacktrace::Push(std::string const& file) const cmListFileBacktrace cmListFileBacktrace::Push( cmListFileContext const& lfc) const { - assert(this->TopEntry); - assert(!this->TopEntry->IsBottom() || this->TopEntry->Bottom.IsValid()); return cmListFileBacktrace(this->TopEntry, lfc); } cmListFileBacktrace cmListFileBacktrace::Pop() const { assert(this->TopEntry); - assert(!this->TopEntry->IsBottom()); return cmListFileBacktrace(this->TopEntry->Parent); } cmListFileContext const& cmListFileBacktrace::Top() const { assert(this->TopEntry); - assert(!this->TopEntry->IsBottom()); return this->TopEntry->Context; } @@ -543,7 +501,7 @@ size_t cmListFileBacktrace::Depth() const { size_t depth = 0; if (Entry const* cur = this->TopEntry.get()) { - for (; !cur->IsBottom(); cur = cur->Parent.get()) { + for (; cur; cur = cur->Parent.get()) { ++depth; } } @@ -552,7 +510,7 @@ size_t cmListFileBacktrace::Depth() const bool cmListFileBacktrace::Empty() const { - return !this->TopEntry || this->TopEntry->IsBottom(); + return !this->TopEntry; } std::ostream& operator<<(std::ostream& os, cmListFileContext const& lfc) diff --git a/Source/cmListFileCache.h b/Source/cmListFileCache.h index 0e2e299a1c..aaf672c184 100644 --- a/Source/cmListFileCache.h +++ b/Source/cmListFileCache.h @@ -13,7 +13,6 @@ #include <cm/optional> -#include "cmStateSnapshot.h" #include "cmSystemTools.h" /** \class cmListFileCache @@ -164,23 +163,13 @@ private: class cmListFileBacktrace { public: - // Default-constructed backtrace may not be used until after - // set via assignment from a backtrace constructed with a - // valid snapshot. + // Default-constructed backtrace is empty. cmListFileBacktrace() = default; - // Construct an empty backtrace whose bottom sits in the directory - // indicated by the given valid snapshot. - cmListFileBacktrace(cmStateSnapshot const& snapshot); - - cmStateSnapshot GetBottom() const; - // Get a backtrace with the given file scope added to the top. - // May not be called until after construction with a valid snapshot. cmListFileBacktrace Push(std::string const& file) const; // Get a backtrace with the given call context added to the top. - // May not be called until after construction with a valid snapshot. cmListFileBacktrace Push(cmListFileContext const& lfc) const; // Get a backtrace with the top level removed. diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index 661cb05e0b..950fa7b053 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -79,7 +79,6 @@ cmMakefile::cmMakefile(cmGlobalGenerator* globalGenerator, cmStateSnapshot const& snapshot) : GlobalGenerator(globalGenerator) , StateSnapshot(snapshot) - , Backtrace(snapshot) { this->IsSourceFileTryCompile = false; |