diff options
author | Brad King <brad.king@kitware.com> | 2020-09-25 12:52:55 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2020-09-28 13:49:08 (GMT) |
commit | dc49abcb89d7c5a99f7955f16f9b0ccaadc585be (patch) | |
tree | 156e6b3cc53472b38ac820f75bd3a5a1c9f5c047 /Source/cmWhileCommand.cxx | |
parent | 68af831505450a34ddd4bf767844bc3890eb52e5 (diff) | |
download | CMake-dc49abcb89d7c5a99f7955f16f9b0ccaadc585be.zip CMake-dc49abcb89d7c5a99f7955f16f9b0ccaadc585be.tar.gz CMake-dc49abcb89d7c5a99f7955f16f9b0ccaadc585be.tar.bz2 |
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.
Diffstat (limited to 'Source/cmWhileCommand.cxx')
-rw-r--r-- | Source/cmWhileCommand.cxx | 13 |
1 files changed, 5 insertions, 8 deletions
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<cmListFileFunction> 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<cmListFileFunction> functions, err += "("; err += errorString; err += ")."; - mf.IssueMessage(messageType, err); + mf.GetCMakeInstance()->IssueMessage(messageType, err, whileBT); if (messageType == MessageType::FATAL_ERROR) { cmSystemTools::SetFatalErrorOccured(); return true; |