diff options
author | Brad King <brad.king@kitware.com> | 2020-09-29 09:58:20 (GMT) |
---|---|---|
committer | Kitware Robot <kwrobot@kitware.com> | 2020-09-29 09:58:25 (GMT) |
commit | 39677de5e209445c8cbc5957c1e79088d5d2a03a (patch) | |
tree | 899f1c5fb22cc2dffc81758b1654964faecee3ac /Source/cmIfCommand.cxx | |
parent | 1382002ae2e78ea8bcda7f97be9130246ea40b11 (diff) | |
parent | 07c1bdda3d42b255ddf9d7145e0aa952f87ee978 (diff) | |
download | CMake-39677de5e209445c8cbc5957c1e79088d5d2a03a.zip CMake-39677de5e209445c8cbc5957c1e79088d5d2a03a.tar.gz CMake-39677de5e209445c8cbc5957c1e79088d5d2a03a.tar.bz2 |
Merge topic 'simplify-execution-context'
07c1bdda3d cmMakefile: Replace GetExecutionFilePath with the top of the Backtrace
727ed0c403 cmMakefile: Simplify ExpandArguments signature
e456dae669 cmConditionEvaluator: Remove extra copy of execution context
0100a4943e cmMakefile: Remove now-unused overload of GetBacktrace
dc49abcb89 if,while: Clarify condition backtrace construction
68af831505 cmMakefile: Inline GetExecutionContext at call sites
280f3918f3 cmMakefile: Simplify GetExecutionContext implementation
0e59b45dfc cmListFileCache: Add explicit constructors
Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !5276
Diffstat (limited to 'Source/cmIfCommand.cxx')
-rw-r--r-- | Source/cmIfCommand.cxx | 24 |
1 files changed, 10 insertions, 14 deletions
diff --git a/Source/cmIfCommand.cxx b/Source/cmIfCommand.cxx index 5808f90..fc257b1 100644 --- a/Source/cmIfCommand.cxx +++ b/Source/cmIfCommand.cxx @@ -75,10 +75,12 @@ bool cmIfFunctionBlocker::Replay(std::vector<cmListFileFunction> 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<cmListFileFunction> 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; } @@ -117,12 +120,7 @@ bool cmIfFunctionBlocker::Replay(std::vector<cmListFileFunction> functions, MessageType messType; - cmListFileContext conditionContext = - cmListFileContext::FromCommandContext( - func, this->GetStartingContext().FilePath); - - cmConditionEvaluator conditionEvaluator(mf, conditionContext, - mf.GetBacktrace(func)); + cmConditionEvaluator conditionEvaluator(mf, elseifBT); bool isTrue = conditionEvaluator.IsTrue(expandedArguments, errorString, messType); @@ -130,8 +128,7 @@ bool cmIfFunctionBlocker::Replay(std::vector<cmListFileFunction> 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; @@ -178,8 +175,7 @@ bool cmIfCommand(std::vector<cmListFileArgument> const& args, MessageType status; - cmConditionEvaluator conditionEvaluator( - makefile, makefile.GetExecutionContext(), makefile.GetBacktrace()); + cmConditionEvaluator conditionEvaluator(makefile, makefile.GetBacktrace()); bool isTrue = conditionEvaluator.IsTrue(expandedArguments, errorString, status); |