From 0e59b45dfce89ea72e07eb5076f1e12326a3f761 Mon Sep 17 00:00:00 2001 From: Brad King Date: Mon, 28 Sep 2020 09:35:08 -0400 Subject: cmListFileCache: Add explicit constructors In order to construct with an initializer list in pure C++11, add the explicit constructors. --- Source/cmListFileCache.h | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/Source/cmListFileCache.h b/Source/cmListFileCache.h index c9556ab..5773e6a 100644 --- a/Source/cmListFileCache.h +++ b/Source/cmListFileCache.h @@ -73,6 +73,14 @@ public: std::string FilePath; long Line = 0; + cmListFileContext() = default; + cmListFileContext(std::string name, std::string filePath, long line) + : Name(std::move(name)) + , FilePath(std::move(filePath)) + , Line(line) + { + } + static cmListFileContext FromCommandContext(cmCommandContext const& lfcc, std::string const& fileName) { -- cgit v0.12 From 280f3918f3a731f64c94b2b7c912c58d714fc676 Mon Sep 17 00:00:00 2001 From: Brad King Date: Fri, 25 Sep 2020 07:22:42 -0400 Subject: cmMakefile: Simplify GetExecutionContext implementation This method takes the function name and line from the top of the current backtrace and then gets the file path from the state's `GetExecutionListFile`. This exactly matches what the `cmMakefileCall` constructor does to create the top of the current backtrace anyway, so we can just take that directly. --- Source/cmMakefile.cxx | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index d77c4af..1c9aa52 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -285,12 +285,7 @@ cmListFileBacktrace cmMakefile::GetBacktrace(cmCommandContext const& cc) const cmListFileContext cmMakefile::GetExecutionContext() const { - cmListFileContext const& cur = this->Backtrace.Top(); - cmListFileContext lfc; - lfc.Name = cur.Name; - lfc.Line = cur.Line; - lfc.FilePath = this->StateSnapshot.GetExecutionListFile(); - return lfc; + return this->Backtrace.Top(); } void cmMakefile::PrintCommandTrace(const cmListFileFunction& lff) const -- cgit v0.12 From 68af831505450a34ddd4bf767844bc3890eb52e5 Mon Sep 17 00:00:00 2001 From: Brad King Date: Fri, 25 Sep 2020 07:40:42 -0400 Subject: cmMakefile: Inline GetExecutionContext at call sites The method only had one line, and its implementation is more clear at the call sites than the method name. --- Source/cmCMakeLanguageCommand.cxx | 2 +- Source/cmIfCommand.cxx | 2 +- Source/cmMakefile.cxx | 7 +------ Source/cmMakefile.h | 1 - Source/cmTargetLinkLibrariesCommand.cxx | 3 ++- 5 files changed, 5 insertions(+), 10 deletions(-) diff --git a/Source/cmCMakeLanguageCommand.cxx b/Source/cmCMakeLanguageCommand.cxx index eb9269f..d513611 100644 --- a/Source/cmCMakeLanguageCommand.cxx +++ b/Source/cmCMakeLanguageCommand.cxx @@ -39,7 +39,7 @@ bool cmCMakeLanguageCommand(std::vector const& args, } cmMakefile& makefile = status.GetMakefile(); - cmListFileContext context = makefile.GetExecutionContext(); + cmListFileContext context = makefile.GetBacktrace().Top(); bool result = false; diff --git a/Source/cmIfCommand.cxx b/Source/cmIfCommand.cxx index 5808f90..9930a85 100644 --- a/Source/cmIfCommand.cxx +++ b/Source/cmIfCommand.cxx @@ -179,7 +179,7 @@ bool cmIfCommand(std::vector const& args, MessageType status; cmConditionEvaluator conditionEvaluator( - makefile, makefile.GetExecutionContext(), makefile.GetBacktrace()); + makefile, makefile.GetBacktrace().Top(), makefile.GetBacktrace()); bool isTrue = conditionEvaluator.IsTrue(expandedArguments, errorString, status); diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index 1c9aa52..3721056 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -283,11 +283,6 @@ cmListFileBacktrace cmMakefile::GetBacktrace(cmCommandContext const& cc) const return this->Backtrace.Push(lfc); } -cmListFileContext cmMakefile::GetExecutionContext() const -{ - return this->Backtrace.Top(); -} - void cmMakefile::PrintCommandTrace(const cmListFileFunction& lff) const { // Check if current file in the list of requested to trace... @@ -3419,7 +3414,7 @@ void cmMakefile::AddFunctionBlocker(std::unique_ptr fb) { if (!this->ExecutionStatusStack.empty()) { // Record the context in which the blocker is created. - fb->SetStartingContext(this->GetExecutionContext()); + fb->SetStartingContext(this->Backtrace.Top()); } this->FunctionBlockers.push(std::move(fb)); diff --git a/Source/cmMakefile.h b/Source/cmMakefile.h index 0a6e6e2..6236129 100644 --- a/Source/cmMakefile.h +++ b/Source/cmMakefile.h @@ -641,7 +641,6 @@ public: */ cmListFileBacktrace GetBacktrace() const; cmListFileBacktrace GetBacktrace(cmCommandContext const& lfc) const; - cmListFileContext GetExecutionContext() const; /** * Get the vector of files created by this makefile diff --git a/Source/cmTargetLinkLibrariesCommand.cxx b/Source/cmTargetLinkLibrariesCommand.cxx index 7db2c46..aecc18e 100644 --- a/Source/cmTargetLinkLibrariesCommand.cxx +++ b/Source/cmTargetLinkLibrariesCommand.cxx @@ -10,6 +10,7 @@ #include "cmExecutionStatus.h" #include "cmGeneratorExpression.h" #include "cmGlobalGenerator.h" +#include "cmListFileCache.h" #include "cmMakefile.h" #include "cmMessageType.h" #include "cmPolicies.h" @@ -386,7 +387,7 @@ bool TLL::HandleLibrary(ProcessingState currentProcessingState, ? cmTarget::KeywordTLLSignature : cmTarget::PlainTLLSignature; if (!this->Target->PushTLLCommandTrace( - sig, this->Makefile.GetExecutionContext())) { + sig, this->Makefile.GetBacktrace().Top())) { std::ostringstream e; const char* modal = nullptr; MessageType messageType = MessageType::AUTHOR_WARNING; -- cgit v0.12 From dc49abcb89d7c5a99f7955f16f9b0ccaadc585be Mon Sep 17 00:00:00 2001 From: Brad King Date: Fri, 25 Sep 2020 08:52:55 -0400 Subject: if,while: Clarify condition backtrace construction Evaluation of the `elseif`, `else`, and `while` commands takes place during function blocker evaluation before any actual command execution takes place. Therefore they do not have an entry in the backtrace stack. Each of their implementations needs to construct an extra backtrace entry to use in error messages and such. Each of them used a slightly different approach due to evolution over time. Clean up their construction of the extra backtrace entry and use a named variable to contain it for clarity. --- Source/cmIfCommand.cxx | 16 +++++++++------- Source/cmWhileCommand.cxx | 13 +++++-------- 2 files changed, 14 insertions(+), 15 deletions(-) diff --git a/Source/cmIfCommand.cxx b/Source/cmIfCommand.cxx index 9930a85..557817c 100644 --- a/Source/cmIfCommand.cxx +++ b/Source/cmIfCommand.cxx @@ -75,10 +75,12 @@ bool cmIfFunctionBlocker::Replay(std::vector functions, if (scopeDepth == 0 && func.Name.Lower == "else") { if (this->ElseSeen) { - cmListFileBacktrace bt = mf.GetBacktrace(func); + cmListFileBacktrace elseBT = mf.GetBacktrace().Push( + cmListFileContext{ func.Name.Original, + this->GetStartingContext().FilePath, func.Line }); mf.GetCMakeInstance()->IssueMessage( MessageType::FATAL_ERROR, - "A duplicate ELSE command was found inside an IF block.", bt); + "A duplicate ELSE command was found inside an IF block.", elseBT); cmSystemTools::SetFatalErrorOccured(); return true; } @@ -93,11 +95,12 @@ bool cmIfFunctionBlocker::Replay(std::vector functions, mf.PrintCommandTrace(func); } } else if (scopeDepth == 0 && func.Name.Lower == "elseif") { + cmListFileBacktrace elseifBT = mf.GetBacktrace().Push(cmListFileContext{ + func.Name.Original, this->GetStartingContext().FilePath, func.Line }); if (this->ElseSeen) { - cmListFileBacktrace bt = mf.GetBacktrace(func); mf.GetCMakeInstance()->IssueMessage( MessageType::FATAL_ERROR, - "An ELSEIF command was found after an ELSE command.", bt); + "An ELSEIF command was found after an ELSE command.", elseifBT); cmSystemTools::SetFatalErrorOccured(); return true; } @@ -122,7 +125,7 @@ bool cmIfFunctionBlocker::Replay(std::vector functions, func, this->GetStartingContext().FilePath); cmConditionEvaluator conditionEvaluator(mf, conditionContext, - mf.GetBacktrace(func)); + elseifBT); bool isTrue = conditionEvaluator.IsTrue(expandedArguments, errorString, messType); @@ -130,8 +133,7 @@ bool cmIfFunctionBlocker::Replay(std::vector functions, if (!errorString.empty()) { std::string err = cmStrCat(cmIfCommandError(expandedArguments), errorString); - cmListFileBacktrace bt = mf.GetBacktrace(func); - mf.GetCMakeInstance()->IssueMessage(messType, err, bt); + mf.GetCMakeInstance()->IssueMessage(messType, err, elseifBT); if (messType == MessageType::FATAL_ERROR) { cmSystemTools::SetFatalErrorOccured(); return true; diff --git a/Source/cmWhileCommand.cxx b/Source/cmWhileCommand.cxx index 0d8e894..876ce20 100644 --- a/Source/cmWhileCommand.cxx +++ b/Source/cmWhileCommand.cxx @@ -17,6 +17,7 @@ #include "cmMakefile.h" #include "cmMessageType.h" #include "cmSystemTools.h" +#include "cmake.h" class cmWhileFunctionBlocker : public cmFunctionBlocker { @@ -66,14 +67,10 @@ bool cmWhileFunctionBlocker::Replay(std::vector functions, mf.ExpandArguments(this->Args, expandedArguments); MessageType messageType; - cmListFileContext execContext = this->GetStartingContext(); - - cmCommandContext commandContext; - commandContext.Line = execContext.Line; - commandContext.Name = execContext.Name; - + cmListFileBacktrace whileBT = + mf.GetBacktrace().Push(this->GetStartingContext()); cmConditionEvaluator conditionEvaluator(mf, this->GetStartingContext(), - mf.GetBacktrace(commandContext)); + whileBT); bool isTrue = conditionEvaluator.IsTrue(expandedArguments, errorString, messageType); @@ -90,7 +87,7 @@ bool cmWhileFunctionBlocker::Replay(std::vector functions, err += "("; err += errorString; err += ")."; - mf.IssueMessage(messageType, err); + mf.GetCMakeInstance()->IssueMessage(messageType, err, whileBT); if (messageType == MessageType::FATAL_ERROR) { cmSystemTools::SetFatalErrorOccured(); return true; -- cgit v0.12 From 0100a4943eb862409ad0cf9619eca93e170dea4a Mon Sep 17 00:00:00 2001 From: Brad King Date: Fri, 25 Sep 2020 09:16:41 -0400 Subject: cmMakefile: Remove now-unused overload of GetBacktrace --- Source/cmMakefile.cxx | 9 --------- Source/cmMakefile.h | 1 - 2 files changed, 10 deletions(-) diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index 3721056..e529896 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -274,15 +274,6 @@ cmListFileBacktrace cmMakefile::GetBacktrace() const return this->Backtrace; } -cmListFileBacktrace cmMakefile::GetBacktrace(cmCommandContext const& cc) const -{ - cmListFileContext lfc; - lfc.Name = cc.Name.Original; - lfc.Line = cc.Line; - lfc.FilePath = this->StateSnapshot.GetExecutionListFile(); - return this->Backtrace.Push(lfc); -} - void cmMakefile::PrintCommandTrace(const cmListFileFunction& lff) const { // Check if current file in the list of requested to trace... diff --git a/Source/cmMakefile.h b/Source/cmMakefile.h index 6236129..bd7753a 100644 --- a/Source/cmMakefile.h +++ b/Source/cmMakefile.h @@ -640,7 +640,6 @@ public: * Get the current context backtrace. */ cmListFileBacktrace GetBacktrace() const; - cmListFileBacktrace GetBacktrace(cmCommandContext const& lfc) const; /** * Get the vector of files created by this makefile -- cgit v0.12 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 From 727ed0c403ad87c5cae84222d7d69b95b665b63f Mon Sep 17 00:00:00 2001 From: Brad King Date: Fri, 25 Sep 2020 10:12:20 -0400 Subject: cmMakefile: Simplify ExpandArguments signature The only call sites that pass the explicit file name argument are in function blocker `ArgumentsMatch` methods for `function` and `macro`. We already ensure that they are balanced within a file scope, and the RAII helpers `BuildsystemFileScope` and `ListFileScope` ensure that the backtrace and execution list file stacks unwind to the matching level. Therefore we can assume that the file name where we are checking for matching arguments matches starting file name where those arguments first appeared, and do not need to pass it explicitly. --- Source/cmFunctionCommand.cxx | 3 +-- Source/cmMacroCommand.cxx | 3 +-- Source/cmMakefile.cxx | 23 ++++++++--------------- Source/cmMakefile.h | 7 ++----- 4 files changed, 12 insertions(+), 24 deletions(-) diff --git a/Source/cmFunctionCommand.cxx b/Source/cmFunctionCommand.cxx index b6f58bd..46bd057 100644 --- a/Source/cmFunctionCommand.cxx +++ b/Source/cmFunctionCommand.cxx @@ -147,8 +147,7 @@ bool cmFunctionFunctionBlocker::ArgumentsMatch(cmListFileFunction const& lff, cmMakefile& mf) const { std::vector expandedArguments; - mf.ExpandArguments(lff.Arguments, expandedArguments, - this->GetStartingContext().FilePath.c_str()); + mf.ExpandArguments(lff.Arguments, expandedArguments); return expandedArguments.empty() || expandedArguments.front() == this->Args.front(); } diff --git a/Source/cmMacroCommand.cxx b/Source/cmMacroCommand.cxx index c88b343..91a600e 100644 --- a/Source/cmMacroCommand.cxx +++ b/Source/cmMacroCommand.cxx @@ -157,8 +157,7 @@ bool cmMacroFunctionBlocker::ArgumentsMatch(cmListFileFunction const& lff, cmMakefile& mf) const { std::vector expandedArguments; - mf.ExpandArguments(lff.Arguments, expandedArguments, - this->GetStartingContext().FilePath.c_str()); + mf.ExpandArguments(lff.Arguments, expandedArguments); return expandedArguments.empty() || expandedArguments[0] == this->Args[0]; } diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index e529896..2147026 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -3335,13 +3335,9 @@ std::string const& cmMakefile::GetExecutionFilePath() const } bool cmMakefile::ExpandArguments(std::vector const& inArgs, - std::vector& outArgs, - const char* filename) const + std::vector& outArgs) const { - if (!filename) { - auto const& efp = this->GetExecutionFilePath(); - filename = efp.c_str(); - } + std::string const& filename = this->GetExecutionFilePath(); std::string value; outArgs.reserve(inArgs.size()); for (cmListFileArgument const& i : inArgs) { @@ -3352,8 +3348,8 @@ bool cmMakefile::ExpandArguments(std::vector const& inArgs, } // Expand the variables in the argument. value = i.Value; - this->ExpandVariablesInString(value, false, false, false, filename, i.Line, - false, false); + this->ExpandVariablesInString(value, false, false, false, filename.c_str(), + i.Line, false, false); // If the argument is quoted, it should be one argument. // Otherwise, it may be a list of arguments. @@ -3368,12 +3364,9 @@ bool cmMakefile::ExpandArguments(std::vector const& inArgs, bool cmMakefile::ExpandArguments( std::vector const& inArgs, - std::vector& outArgs, const char* filename) const + std::vector& outArgs) const { - if (!filename) { - auto const& efp = this->GetExecutionFilePath(); - filename = efp.c_str(); - } + std::string const& filename = this->GetExecutionFilePath(); std::string value; outArgs.reserve(inArgs.size()); for (cmListFileArgument const& i : inArgs) { @@ -3384,8 +3377,8 @@ bool cmMakefile::ExpandArguments( } // Expand the variables in the argument. value = i.Value; - this->ExpandVariablesInString(value, false, false, false, filename, i.Line, - false, false); + this->ExpandVariablesInString(value, false, false, false, filename.c_str(), + i.Line, false, false); // If the argument is quoted, it should be one argument. // Otherwise, it may be a list of arguments. diff --git a/Source/cmMakefile.h b/Source/cmMakefile.h index bd7753a..022c029 100644 --- a/Source/cmMakefile.h +++ b/Source/cmMakefile.h @@ -732,12 +732,9 @@ public: * variable replacement and list expansion. */ bool ExpandArguments(std::vector const& inArgs, - std::vector& outArgs, - const char* filename = nullptr) const; - + std::vector& outArgs) const; bool ExpandArguments(std::vector const& inArgs, - std::vector& outArgs, - const char* filename = nullptr) const; + std::vector& outArgs) const; /** * Get the instance -- cgit v0.12 From 07c1bdda3d42b255ddf9d7145e0aa952f87ee978 Mon Sep 17 00:00:00 2001 From: Brad King Date: Fri, 25 Sep 2020 10:26:01 -0400 Subject: cmMakefile: Replace GetExecutionFilePath with the top of the Backtrace The execution file path stack and the backtrace stack are kept in sync. At all call sites of `GetExecutionFilePath`, the execution file path matches the path in the context at the top of the backtrace stack. --- Source/cmMakefile.cxx | 16 +++++----------- Source/cmMakefile.h | 2 -- 2 files changed, 5 insertions(+), 13 deletions(-) diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index 2147026..c8b2133 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -279,7 +279,7 @@ void cmMakefile::PrintCommandTrace(const cmListFileFunction& lff) const // Check if current file in the list of requested to trace... std::vector const& trace_only_this_files = this->GetCMakeInstance()->GetTraceSources(); - std::string const& full_path = this->GetExecutionFilePath(); + std::string const& full_path = this->GetBacktrace().Top().FilePath; std::string const& only_filename = cmSystemTools::GetFilenameName(full_path); bool trace = trace_only_this_files.empty(); if (!trace) { @@ -578,7 +578,7 @@ void cmMakefile::IncludeScope::EnforceCMP0011() std::ostringstream w; w << cmPolicies::GetPolicyWarning(cmPolicies::CMP0011) << "\n" << "The included script\n " - << this->Makefile->GetExecutionFilePath() << "\n" + << this->Makefile->GetBacktrace().Top().FilePath << "\n" << "affects policy settings. " << "CMake is implying the NO_POLICY_SCOPE option for compatibility, " << "so the effects are applied to the including context."; @@ -591,7 +591,7 @@ void cmMakefile::IncludeScope::EnforceCMP0011() /* clang-format off */ e << cmPolicies::GetRequiredPolicyError(cmPolicies::CMP0011) << "\n" << "The included script\n " - << this->Makefile->GetExecutionFilePath() << "\n" + << this->Makefile->GetBacktrace().Top().FilePath << "\n" << "affects policy settings, so it requires this policy to be set."; /* clang-format on */ this->Makefile->IssueMessage(MessageType::FATAL_ERROR, e.str()); @@ -3328,16 +3328,10 @@ bool cmMakefile::IsLoopBlock() const return !this->LoopBlockCounter.empty() && this->LoopBlockCounter.top() > 0; } -std::string const& cmMakefile::GetExecutionFilePath() const -{ - assert(this->StateSnapshot.IsValid()); - return this->StateSnapshot.GetExecutionListFile(); -} - bool cmMakefile::ExpandArguments(std::vector const& inArgs, std::vector& outArgs) const { - std::string const& filename = this->GetExecutionFilePath(); + std::string const& filename = this->GetBacktrace().Top().FilePath; std::string value; outArgs.reserve(inArgs.size()); for (cmListFileArgument const& i : inArgs) { @@ -3366,7 +3360,7 @@ bool cmMakefile::ExpandArguments( std::vector const& inArgs, std::vector& outArgs) const { - std::string const& filename = this->GetExecutionFilePath(); + std::string const& filename = this->GetBacktrace().Top().FilePath; std::string value; outArgs.reserve(inArgs.size()); for (cmListFileArgument const& i : inArgs) { diff --git a/Source/cmMakefile.h b/Source/cmMakefile.h index 022c029..7c3348d 100644 --- a/Source/cmMakefile.h +++ b/Source/cmMakefile.h @@ -937,8 +937,6 @@ public: const char* GetDefineFlagsCMP0059() const; - std::string const& GetExecutionFilePath() const; - void EnforceDirectoryLevelRules() const; void AddEvaluationFile( -- cgit v0.12