Просмотр исходного кода

cmMakefile: Add access to the top-level execution context.

This is cheaper than getting the whole backtrace, and the cmListFileBacktrace
will not always be composed of cmListFileContext objects.
Stephen Kelly 10 лет назад
Родитель
Сommit
e17b5e4262
3 измененных файлов с 13 добавлено и 6 удалено
  1. 2 2
      Source/cmConditionEvaluator.cxx
  2. 10 4
      Source/cmMakefile.cxx
  3. 1 0
      Source/cmMakefile.h

+ 2 - 2
Source/cmConditionEvaluator.cxx

@@ -113,7 +113,7 @@ const char* cmConditionEvaluator::GetDefinitionIfUnquoted(
   if(def && argument.WasQuoted() && this->Policy54Status == cmPolicies::WARN)
     {
     bool hasBeenReported = this->Makefile.HasCMP0054AlreadyBeenReported(
-      this->Makefile.GetBacktrace()[0]);
+      this->Makefile.GetExecutionContext());
 
     if(!hasBeenReported)
       {
@@ -162,7 +162,7 @@ bool cmConditionEvaluator::IsKeyword(std::string const& keyword,
     this->Policy54Status == cmPolicies::WARN)
     {
     bool hasBeenReported = this->Makefile.HasCMP0054AlreadyBeenReported(
-      this->Makefile.GetBacktrace()[0]);
+      this->Makefile.GetExecutionContext());
 
     if(!hasBeenReported)
       {

+ 10 - 4
Source/cmMakefile.cxx

@@ -377,6 +377,12 @@ cmListFileBacktrace cmMakefile::GetBacktrace() const
   return backtrace;
 }
 
+//----------------------------------------------------------------------------
+cmListFileContext cmMakefile::GetExecutionContext() const
+{
+  return *this->CallStack.back().Context;
+}
+
 //----------------------------------------------------------------------------
 void cmMakefile::PrintCommandTrace(const cmListFileFunction& lff) const
 {
@@ -1937,9 +1943,9 @@ void cmMakefile::CheckForUnused(const char* reason,
     cmListFileBacktrace bt(this->GetLocalGenerator());
     if (!this->CallStack.empty())
       {
-      const cmListFileContext* file = this->CallStack.back().Context;
-      bt.push_back(*file);
-      path = file->FilePath.c_str();
+      cmListFileContext file = this->GetExecutionContext();
+      bt.push_back(file);
+      path = file.FilePath;
       }
     else
       {
@@ -3410,7 +3416,7 @@ void cmMakefile::AddFunctionBlocker(cmFunctionBlocker* fb)
   if(!this->CallStack.empty())
     {
     // Record the context in which the blocker is created.
-    fb->SetStartingContext(*(this->CallStack.back().Context));
+    fb->SetStartingContext(this->GetExecutionContext());
     }
 
   this->FunctionBlockers.push_back(fb);

+ 1 - 0
Source/cmMakefile.h

@@ -610,6 +610,7 @@ public:
    * Get the current context backtrace.
    */
   cmListFileBacktrace GetBacktrace() const;
+  cmListFileContext GetExecutionContext() const;
 
   /**
    * Get the vector of  files created by this makefile