Bläddra i källkod

cmConditionEvaluator: Remove extra copy of execution context

The execution context passed to the constructor always matches the top
of the backtrace, so the former can be removed in favor of using only
the latter.
Brad King 5 år sedan
förälder
incheckning
e456dae669

+ 2 - 6
Source/cmConditionEvaluator.cxx

@@ -56,10 +56,8 @@ static std::string const keyVERSION_LESS = "VERSION_LESS";
 static std::string const keyVERSION_LESS_EQUAL = "VERSION_LESS_EQUAL";
 
 cmConditionEvaluator::cmConditionEvaluator(cmMakefile& makefile,
-                                           cmListFileContext context,
                                            cmListFileBacktrace bt)
   : Makefile(makefile)
-  , ExecutionContext(std::move(context))
   , Backtrace(std::move(bt))
   , Policy12Status(makefile.GetPolicyStatus(cmPolicies::CMP0012))
   , Policy54Status(makefile.GetPolicyStatus(cmPolicies::CMP0054))
@@ -147,8 +145,7 @@ cmProp cmConditionEvaluator::GetDefinitionIfUnquoted(
 
   if (def && argument.WasQuoted() &&
       this->Policy54Status == cmPolicies::WARN) {
-    if (!this->Makefile.HasCMP0054AlreadyBeenReported(
-          this->ExecutionContext)) {
+    if (!this->Makefile.HasCMP0054AlreadyBeenReported(this->Backtrace.Top())) {
       std::ostringstream e;
       e << (cmPolicies::GetPolicyWarning(cmPolicies::CMP0054)) << "\n";
       e << "Quoted variables like \"" << argument.GetValue()
@@ -191,8 +188,7 @@ bool cmConditionEvaluator::IsKeyword(std::string const& keyword,
 
   if (isKeyword && argument.WasQuoted() &&
       this->Policy54Status == cmPolicies::WARN) {
-    if (!this->Makefile.HasCMP0054AlreadyBeenReported(
-          this->ExecutionContext)) {
+    if (!this->Makefile.HasCMP0054AlreadyBeenReported(this->Backtrace.Top())) {
       std::ostringstream e;
       e << cmPolicies::GetPolicyWarning(cmPolicies::CMP0054) << "\n";
       e << "Quoted keywords like \"" << argument.GetValue()

+ 1 - 3
Source/cmConditionEvaluator.h

@@ -21,8 +21,7 @@ class cmConditionEvaluator
 public:
   using cmArgumentList = std::list<cmExpandedCommandArgument>;
 
-  cmConditionEvaluator(cmMakefile& makefile, cmListFileContext context,
-                       cmListFileBacktrace bt);
+  cmConditionEvaluator(cmMakefile& makefile, cmListFileBacktrace bt);
 
   // this is a shared function for both If and Else to determine if the
   // arguments were valid, and if so, was the response true. If there is
@@ -79,7 +78,6 @@ private:
                     MessageType& status);
 
   cmMakefile& Makefile;
-  cmListFileContext ExecutionContext;
   cmListFileBacktrace Backtrace;
   cmPolicies::PolicyStatus Policy12Status;
   cmPolicies::PolicyStatus Policy54Status;

+ 2 - 8
Source/cmIfCommand.cxx

@@ -120,12 +120,7 @@ bool cmIfFunctionBlocker::Replay(std::vector<cmListFileFunction> functions,
 
         MessageType messType;
 
-        cmListFileContext conditionContext =
-          cmListFileContext::FromCommandContext(
-            func, this->GetStartingContext().FilePath);
-
-        cmConditionEvaluator conditionEvaluator(mf, conditionContext,
-                                                elseifBT);
+        cmConditionEvaluator conditionEvaluator(mf, elseifBT);
 
         bool isTrue =
           conditionEvaluator.IsTrue(expandedArguments, errorString, messType);
@@ -180,8 +175,7 @@ bool cmIfCommand(std::vector<cmListFileArgument> const& args,
 
   MessageType status;
 
-  cmConditionEvaluator conditionEvaluator(
-    makefile, makefile.GetBacktrace().Top(), makefile.GetBacktrace());
+  cmConditionEvaluator conditionEvaluator(makefile, makefile.GetBacktrace());
 
   bool isTrue =
     conditionEvaluator.IsTrue(expandedArguments, errorString, status);

+ 1 - 2
Source/cmWhileCommand.cxx

@@ -69,8 +69,7 @@ bool cmWhileFunctionBlocker::Replay(std::vector<cmListFileFunction> functions,
 
   cmListFileBacktrace whileBT =
     mf.GetBacktrace().Push(this->GetStartingContext());
-  cmConditionEvaluator conditionEvaluator(mf, this->GetStartingContext(),
-                                          whileBT);
+  cmConditionEvaluator conditionEvaluator(mf, whileBT);
 
   bool isTrue =
     conditionEvaluator.IsTrue(expandedArguments, errorString, messageType);