瀏覽代碼

cmListFileBacktrace: Remove unused "bottom" entry

All uses of `GetBottom` by clients have been removed, so drop the
method and its supporting infrastructure.
Brad King 4 年之前
父節點
當前提交
7b677dbb92
共有 4 個文件被更改,包括 6 次插入60 次删除
  1. 1 1
      Source/CTest/cmCTestTestHandler.cxx
  2. 4 46
      Source/cmListFileCache.cxx
  3. 1 12
      Source/cmListFileCache.h
  4. 0 1
      Source/cmMakefile.cxx

+ 1 - 1
Source/CTest/cmCTestTestHandler.cxx

@@ -2183,7 +2183,7 @@ bool cmCTestTestHandler::SetTestsProperties(
             // Ensure we have complete triples otherwise the data is corrupt.
             // Ensure we have complete triples otherwise the data is corrupt.
             if (triples.size() % 3 == 0) {
             if (triples.size() % 3 == 0) {
               cmState state(cmState::Unknown);
               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
               // the first entry represents the top of the trace so we need to
               // reconstruct the backtrace in reverse
               // reconstruct the backtrace in reverse

+ 4 - 46
Source/cmListFileCache.cxx

@@ -443,45 +443,19 @@ cm::optional<cmListFileContext> cmListFileParser::CheckNesting() const
   return cm::nullopt;
   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
 struct cmListFileBacktrace::Entry
 {
 {
-  Entry(cmStateSnapshot bottom)
-    : Bottom(bottom)
-  {
-  }
-
   Entry(std::shared_ptr<Entry const> parent, cmListFileContext lfc)
   Entry(std::shared_ptr<Entry const> parent, cmListFileContext lfc)
     : Context(std::move(lfc))
     : Context(std::move(lfc))
     , Parent(std::move(parent))
     , 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;
   std::shared_ptr<Entry const> Parent;
 };
 };
 
 
-cmListFileBacktrace::cmListFileBacktrace(cmStateSnapshot const& snapshot)
-  : TopEntry(std::make_shared<Entry const>(snapshot.GetCallStackBottom()))
-{
-}
-
 /* NOLINTNEXTLINE(performance-unnecessary-value-param) */
 /* NOLINTNEXTLINE(performance-unnecessary-value-param) */
 cmListFileBacktrace::cmListFileBacktrace(std::shared_ptr<Entry const> parent,
 cmListFileBacktrace::cmListFileBacktrace(std::shared_ptr<Entry const> parent,
                                          cmListFileContext const& lfc)
                                          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
 cmListFileBacktrace cmListFileBacktrace::Push(std::string const& file) const
 {
 {
   // We are entering a file-level scope but have not yet reached
   // 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(
 cmListFileBacktrace cmListFileBacktrace::Push(
   cmListFileContext const& lfc) const
   cmListFileContext const& lfc) const
 {
 {
-  assert(this->TopEntry);
-  assert(!this->TopEntry->IsBottom() || this->TopEntry->Bottom.IsValid());
   return cmListFileBacktrace(this->TopEntry, lfc);
   return cmListFileBacktrace(this->TopEntry, lfc);
 }
 }
 
 
 cmListFileBacktrace cmListFileBacktrace::Pop() const
 cmListFileBacktrace cmListFileBacktrace::Pop() const
 {
 {
   assert(this->TopEntry);
   assert(this->TopEntry);
-  assert(!this->TopEntry->IsBottom());
   return cmListFileBacktrace(this->TopEntry->Parent);
   return cmListFileBacktrace(this->TopEntry->Parent);
 }
 }
 
 
 cmListFileContext const& cmListFileBacktrace::Top() const
 cmListFileContext const& cmListFileBacktrace::Top() const
 {
 {
   assert(this->TopEntry);
   assert(this->TopEntry);
-  assert(!this->TopEntry->IsBottom());
   return this->TopEntry->Context;
   return this->TopEntry->Context;
 }
 }
 
 
@@ -543,7 +501,7 @@ size_t cmListFileBacktrace::Depth() const
 {
 {
   size_t depth = 0;
   size_t depth = 0;
   if (Entry const* cur = this->TopEntry.get()) {
   if (Entry const* cur = this->TopEntry.get()) {
-    for (; !cur->IsBottom(); cur = cur->Parent.get()) {
+    for (; cur; cur = cur->Parent.get()) {
       ++depth;
       ++depth;
     }
     }
   }
   }
@@ -552,7 +510,7 @@ size_t cmListFileBacktrace::Depth() const
 
 
 bool cmListFileBacktrace::Empty() const
 bool cmListFileBacktrace::Empty() const
 {
 {
-  return !this->TopEntry || this->TopEntry->IsBottom();
+  return !this->TopEntry;
 }
 }
 
 
 std::ostream& operator<<(std::ostream& os, cmListFileContext const& lfc)
 std::ostream& operator<<(std::ostream& os, cmListFileContext const& lfc)

+ 1 - 12
Source/cmListFileCache.h

@@ -13,7 +13,6 @@
 
 
 #include <cm/optional>
 #include <cm/optional>
 
 
-#include "cmStateSnapshot.h"
 #include "cmSystemTools.h"
 #include "cmSystemTools.h"
 
 
 /** \class cmListFileCache
 /** \class cmListFileCache
@@ -164,23 +163,13 @@ private:
 class cmListFileBacktrace
 class cmListFileBacktrace
 {
 {
 public:
 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;
   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.
   // 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;
   cmListFileBacktrace Push(std::string const& file) const;
 
 
   // Get a backtrace with the given call context added to the top.
   // 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;
   cmListFileBacktrace Push(cmListFileContext const& lfc) const;
 
 
   // Get a backtrace with the top level removed.
   // Get a backtrace with the top level removed.

+ 0 - 1
Source/cmMakefile.cxx

@@ -79,7 +79,6 @@ cmMakefile::cmMakefile(cmGlobalGenerator* globalGenerator,
                        cmStateSnapshot const& snapshot)
                        cmStateSnapshot const& snapshot)
   : GlobalGenerator(globalGenerator)
   : GlobalGenerator(globalGenerator)
   , StateSnapshot(snapshot)
   , StateSnapshot(snapshot)
-  , Backtrace(snapshot)
 {
 {
   this->IsSourceFileTryCompile = false;
   this->IsSourceFileTryCompile = false;