summaryrefslogtreecommitdiffstats
path: root/Source/cmConditionEvaluator.cxx
diff options
context:
space:
mode:
authorStephen Kelly <steveire@gmail.com>2015-10-20 17:13:52 (GMT)
committerStephen Kelly <steveire@gmail.com>2015-10-20 21:40:12 (GMT)
commitd6a03b475e023da9b7532a5b8735caec36b5de86 (patch)
tree5a7fce28bcc989ae6a841118b2031f162ae3b705 /Source/cmConditionEvaluator.cxx
parent22bfb39dea2476df8f7aa5ed5c773a7a6720c4bc (diff)
downloadCMake-d6a03b475e023da9b7532a5b8735caec36b5de86.zip
CMake-d6a03b475e023da9b7532a5b8735caec36b5de86.tar.gz
CMake-d6a03b475e023da9b7532a5b8735caec36b5de86.tar.bz2
cmIfCommand: Issue CMP0054 warning with appropriate context. (#15802)
Commit v3.4.0-rc1~494^2~4 (cmMakefile: Add API for elseif to create backtrace., 2015-05-29) removed the use of cmMakefileCall to push/pop execution context in favor of a new way to create backtraces. However, a call to cmMakefile::GetExecutionContext is still invoked to issue a contextual CMP0054 warning through cmConditionEvaluator. As the elseif is not part of the call stack, this resulted in trying to access an empty vector. Avoid the attempt at getting execution context when evaluating elseif by constructing a context and backtrace on behalf of the cmConditionEvaluator in all cases.
Diffstat (limited to 'Source/cmConditionEvaluator.cxx')
-rw-r--r--Source/cmConditionEvaluator.cxx40
1 files changed, 35 insertions, 5 deletions
diff --git a/Source/cmConditionEvaluator.cxx b/Source/cmConditionEvaluator.cxx
index 7874803..5330acd 100644
--- a/Source/cmConditionEvaluator.cxx
+++ b/Source/cmConditionEvaluator.cxx
@@ -11,9 +11,14 @@
============================================================================*/
#include "cmConditionEvaluator.h"
+#include "cmOutputConverter.h"
-cmConditionEvaluator::cmConditionEvaluator(cmMakefile& makefile):
+cmConditionEvaluator::cmConditionEvaluator(cmMakefile& makefile,
+ const cmListFileContext &context,
+ const cmListFileBacktrace& bt):
Makefile(makefile),
+ ExecutionContext(context),
+ Backtrace(bt),
Policy12Status(makefile.GetPolicyStatus(cmPolicies::CMP0012)),
Policy54Status(makefile.GetPolicyStatus(cmPolicies::CMP0054)),
Policy57Status(makefile.GetPolicyStatus(cmPolicies::CMP0057)),
@@ -98,6 +103,25 @@ bool cmConditionEvaluator::IsTrue(
errorString, status, true);
}
+cmListFileContext cmConditionEvaluator::GetConditionContext(
+ cmMakefile* mf,
+ const cmCommandContext& command,
+ const std::string& filePath)
+{
+ cmListFileContext context =
+ cmListFileContext::FromCommandContext(
+ command,
+ filePath);
+
+ if(!mf->GetCMakeInstance()->GetIsInTryCompile())
+ {
+ cmOutputConverter converter(mf->GetStateSnapshot());
+ context.FilePath = converter.Convert(context.FilePath,
+ cmOutputConverter::HOME);
+ }
+ return context;
+}
+
//=========================================================================
const char* cmConditionEvaluator::GetDefinitionIfUnquoted(
cmExpandedCommandArgument const& argument) const
@@ -113,7 +137,8 @@ const char* cmConditionEvaluator::GetDefinitionIfUnquoted(
if(def && argument.WasQuoted() && this->Policy54Status == cmPolicies::WARN)
{
- if(!this->Makefile.HasCMP0054AlreadyBeenReported())
+ if(!this->Makefile.HasCMP0054AlreadyBeenReported(
+ this->ExecutionContext))
{
std::ostringstream e;
e << (cmPolicies::GetPolicyWarning(cmPolicies::CMP0054)) << "\n";
@@ -122,7 +147,9 @@ const char* cmConditionEvaluator::GetDefinitionIfUnquoted(
"when the policy is set to NEW. "
"Since the policy is not set the OLD behavior will be used.";
- this->Makefile.IssueMessage(cmake::AUTHOR_WARNING, e.str());
+ this->Makefile.GetCMakeInstance()
+ ->IssueMessage(cmake::AUTHOR_WARNING, e.str(),
+ this->Backtrace);
}
}
@@ -159,7 +186,8 @@ bool cmConditionEvaluator::IsKeyword(std::string const& keyword,
if(isKeyword && argument.WasQuoted() &&
this->Policy54Status == cmPolicies::WARN)
{
- if(!this->Makefile.HasCMP0054AlreadyBeenReported())
+ if(!this->Makefile.HasCMP0054AlreadyBeenReported(
+ this->ExecutionContext))
{
std::ostringstream e;
e << cmPolicies::GetPolicyWarning(cmPolicies::CMP0054) << "\n";
@@ -168,7 +196,9 @@ bool cmConditionEvaluator::IsKeyword(std::string const& keyword,
"when the policy is set to NEW. "
"Since the policy is not set the OLD behavior will be used.";
- this->Makefile.IssueMessage(cmake::AUTHOR_WARNING, e.str());
+ this->Makefile.GetCMakeInstance()
+ ->IssueMessage(cmake::AUTHOR_WARNING, e.str(),
+ this->Backtrace);
}
}