diff --git a/Source/cmCommandArgumentParserHelper.cxx b/Source/cmCommandArgumentParserHelper.cxx index 14e9e5661..15ab74609 100644 --- a/Source/cmCommandArgumentParserHelper.cxx +++ b/Source/cmCommandArgumentParserHelper.cxx @@ -140,15 +140,8 @@ char* cmCommandArgumentParserHelper::ExpandVariable(const char* var) this->Makefile->GetHomeOutputDirectory())) { std::ostringstream msg; - cmListFileContext lfc; - cmOutputConverter converter(this->Makefile->GetStateSnapshot()); - lfc.FilePath = converter.Convert(this->FileName, - cmOutputConverter::HOME); - - lfc.Line = this->FileLine; msg << "uninitialized variable \'" << var << "\'"; - this->Makefile->GetCMakeInstance()->IssueMessage(cmake::AUTHOR_WARNING, - msg.str(), lfc); + this->Makefile->IssueMessage(cmake::AUTHOR_WARNING, msg.str()); } } return 0; diff --git a/Source/cmIfCommand.cxx b/Source/cmIfCommand.cxx index 9a07dded4..fc54ca5aa 100644 --- a/Source/cmIfCommand.cxx +++ b/Source/cmIfCommand.cxx @@ -203,15 +203,9 @@ bool cmIfCommand cmake::MessageType status; - cmListFileContext execContext = this->Makefile->GetExecutionContext(); - - cmCommandContext commandContext; - commandContext.Line = execContext.Line; - commandContext.Name = execContext.Name; - cmConditionEvaluator conditionEvaluator( - *(this->Makefile), cmListFileContext::FromCommandContext( - commandContext, execContext.FilePath), + *(this->Makefile), + this->Makefile->GetExecutionContext(), this->Makefile->GetBacktrace()); bool isTrue = conditionEvaluator.IsTrue( diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx index 0195b9e3e..b93fc21e5 100644 --- a/Source/cmLocalGenerator.cxx +++ b/Source/cmLocalGenerator.cxx @@ -69,17 +69,7 @@ cmLocalGenerator::~cmLocalGenerator() void cmLocalGenerator::IssueMessage(cmake::MessageType t, std::string const& text) const { - cmListFileContext lfc; - lfc.FilePath = this->StateSnapshot.GetDirectory().GetCurrentSource(); - lfc.FilePath += "/CMakeLists.txt"; - - if(!this->GlobalGenerator->GetCMakeInstance()->GetIsInTryCompile()) - { - cmOutputConverter converter(this->StateSnapshot); - lfc.FilePath = converter.Convert(lfc.FilePath, cmLocalGenerator::HOME); - } - lfc.Line = 0; - this->GlobalGenerator->GetCMakeInstance()->IssueMessage(t, text, lfc); + this->Makefile->IssueMessage(t, text); } //---------------------------------------------------------------------------- @@ -1608,7 +1598,7 @@ void cmLocalGenerator::OutputLinkLibraries(std::string& linkLibraries, "For compatibility with older versions of CMake, " "additional flags may be added to export symbols on all " "executables regardless of thier ENABLE_EXPORTS property."; - this->Makefile->IssueMessage(cmake::AUTHOR_WARNING, w.str()); + this->IssueMessage(cmake::AUTHOR_WARNING, w.str()); } case cmPolicies::OLD: // OLD behavior is to always add the flags @@ -1616,7 +1606,7 @@ void cmLocalGenerator::OutputLinkLibraries(std::string& linkLibraries, break; case cmPolicies::REQUIRED_IF_USED: case cmPolicies::REQUIRED_ALWAYS: - this->Makefile->IssueMessage( + this->IssueMessage( cmake::FATAL_ERROR, cmPolicies::GetRequiredPolicyError(cmPolicies::CMP0065) ); diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index 7be6b8823..13bcdac4a 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -222,6 +222,26 @@ void cmMakefile::PrintCommandTrace(const cmListFileFunction& lff) const cmSystemTools::Message(msg.str().c_str()); } +// Helper class to make sure the call stack is valid. +class cmMakefileCall +{ +public: + cmMakefileCall(cmMakefile* mf, const cmCommandContext& lfc, + cmExecutionStatus& status): Makefile(mf) + { + this->Makefile->ContextStack.push_back(&lfc); + this->Makefile->ExecutionStatusStack.push_back(&status); + } + + ~cmMakefileCall() + { + this->Makefile->ExecutionStatusStack.pop_back(); + this->Makefile->ContextStack.pop_back(); + } +private: + cmMakefile* Makefile; +}; + //---------------------------------------------------------------------------- bool cmMakefile::ExecuteCommand(const cmListFileFunction& lff, cmExecutionStatus &status) @@ -1941,21 +1961,15 @@ void cmMakefile::LogUnused(const char* reason, if (this->WarnUnused) { std::string path; - cmListFileContext lfc; if (!this->ExecutionStatusStack.empty()) { - lfc = this->GetExecutionContext(); - path = lfc.FilePath; + path = this->GetExecutionContext().FilePath; } else { path = this->GetCurrentSourceDirectory(); path += "/CMakeLists.txt"; - lfc.FilePath = path; - lfc.Line = 0; } - cmOutputConverter converter(this->StateSnapshot); - lfc.FilePath = converter.Convert(lfc.FilePath, cmOutputConverter::HOME); if (this->CheckSystemVars || cmSystemTools::IsSubDirectory(path, @@ -1967,9 +1981,7 @@ void cmMakefile::LogUnused(const char* reason, { std::ostringstream msg; msg << "unused variable (" << reason << ") \'" << name << "\'"; - this->GetCMakeInstance()->IssueMessage(cmake::AUTHOR_WARNING, - msg.str(), - lfc); + this->IssueMessage(cmake::AUTHOR_WARNING, msg.str()); } } } @@ -2899,14 +2911,8 @@ cmake::MessageType cmMakefile::ExpandVariablesInStringNew( this->GetHomeOutputDirectory())) { std::ostringstream msg; - cmListFileContext lfc; - cmOutputConverter converter(this->StateSnapshot); - lfc.FilePath = - converter.Convert(filename, cmOutputConverter::HOME); - lfc.Line = line; msg << "uninitialized variable \'" << lookup << "\'"; - this->GetCMakeInstance()->IssueMessage(cmake::AUTHOR_WARNING, - msg.str(), lfc); + this->IssueMessage(cmake::AUTHOR_WARNING, msg.str()); } } } @@ -5148,16 +5154,3 @@ cmMakefile::MacroPushPop::~MacroPushPop() { this->Makefile->PopMacroScope(this->ReportError); } - -cmMakefileCall::cmMakefileCall(cmMakefile* mf, const cmCommandContext& lfc, - cmExecutionStatus& status): Makefile(mf) -{ - this->Makefile->ContextStack.push_back(&lfc); - this->Makefile->ExecutionStatusStack.push_back(&status); -} - -cmMakefileCall::~cmMakefileCall() -{ - this->Makefile->ExecutionStatusStack.pop_back(); - this->Makefile->ContextStack.pop_back(); -} diff --git a/Source/cmMakefile.h b/Source/cmMakefile.h index 45f2efb92..72179442f 100644 --- a/Source/cmMakefile.h +++ b/Source/cmMakefile.h @@ -959,17 +959,4 @@ private: mutable bool SuppressWatches; }; -//---------------------------------------------------------------------------- -// Helper class to make sure the call stack is valid. -class cmMakefileCall -{ -public: - cmMakefileCall(cmMakefile* mf, - cmCommandContext const& lfc, - cmExecutionStatus& status); - ~cmMakefileCall(); -private: - cmMakefile* Makefile; -}; - #endif diff --git a/Source/cmOutputConverter.cxx b/Source/cmOutputConverter.cxx index 5acae2f82..59fb2e9e1 100644 --- a/Source/cmOutputConverter.cxx +++ b/Source/cmOutputConverter.cxx @@ -22,6 +22,7 @@ cmOutputConverter::cmOutputConverter(cmState::Snapshot snapshot) : StateSnapshot(snapshot), LinkScriptShell(false) { + assert(this->StateSnapshot.IsValid()); } //---------------------------------------------------------------------------- diff --git a/Source/cmWhileCommand.cxx b/Source/cmWhileCommand.cxx index aabbe2715..7bb78bf8a 100644 --- a/Source/cmWhileCommand.cxx +++ b/Source/cmWhileCommand.cxx @@ -55,13 +55,9 @@ IsFunctionBlocked(const cmListFileFunction& lff, cmMakefile &mf, commandContext.Line = execContext.Line; commandContext.Name = execContext.Name; - cmListFileContext conditionContext = - cmListFileContext::FromCommandContext( - commandContext, - this->GetStartingContext().FilePath); - cmConditionEvaluator conditionEvaluator( - mf, conditionContext, + mf, + this->GetStartingContext(), mf.GetBacktrace(commandContext)); bool isTrue = conditionEvaluator.IsTrue(