From e456dae6693dc3a79e2708481a969b43cda188cf Mon Sep 17 00:00:00 2001 From: Brad King Date: Fri, 25 Sep 2020 09:17:22 -0400 Subject: 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. --- Source/cmConditionEvaluator.cxx | 8 ++------ Source/cmConditionEvaluator.h | 4 +--- Source/cmIfCommand.cxx | 10 ++-------- Source/cmWhileCommand.cxx | 3 +-- 4 files changed, 6 insertions(+), 19 deletions(-) diff --git a/Source/cmConditionEvaluator.cxx b/Source/cmConditionEvaluator.cxx index 7ada8d8..14f10bd74 100644 --- a/Source/cmConditionEvaluator.cxx +++ b/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() diff --git a/Source/cmConditionEvaluator.h b/Source/cmConditionEvaluator.h index a4cedff..cf00ede 100644 --- a/Source/cmConditionEvaluator.h +++ b/Source/cmConditionEvaluator.h @@ -21,8 +21,7 @@ class cmConditionEvaluator public: using cmArgumentList = std::list; - 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; diff --git a/Source/cmIfCommand.cxx b/Source/cmIfCommand.cxx index 557817c..fc257b1 100644 --- a/Source/cmIfCommand.cxx +++ b/Source/cmIfCommand.cxx @@ -120,12 +120,7 @@ bool cmIfFunctionBlocker::Replay(std::vector 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 const& args, MessageType status; - cmConditionEvaluator conditionEvaluator( - makefile, makefile.GetBacktrace().Top(), makefile.GetBacktrace()); + cmConditionEvaluator conditionEvaluator(makefile, makefile.GetBacktrace()); bool isTrue = conditionEvaluator.IsTrue(expandedArguments, errorString, status); diff --git a/Source/cmWhileCommand.cxx b/Source/cmWhileCommand.cxx index 876ce20..2c7a8a7 100644 --- a/Source/cmWhileCommand.cxx +++ b/Source/cmWhileCommand.cxx @@ -69,8 +69,7 @@ bool cmWhileFunctionBlocker::Replay(std::vector 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); -- cgit v0.12