Commit ef713503 authored by Brad King's avatar Brad King Committed by Kitware Robot

Merge topic 'minor-cleanups'

2faa8b36 Add call stack to unused/uninitialized variable warnings
da07c506 cmLocalGenerator: Simplify IssueMessage implementation
cc7aed77 cmLocalGenerator: Use own IssueMessage method
c50285de cmOutputConverter: Assert construction with a valid snapshot
b6ed71b1 cmMakefile: Move cmMakefileCall to .cxx file
a559f0f6 cmWhileCommand: Simplify context construction
7503deb2 cmIfCommand: Simplify execution context construction
parents 0256ea55 2faa8b36
......@@ -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;
......
......@@ -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(
......
......@@ -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)
);
......
......@@ -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();
}
......@@ -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
......@@ -22,6 +22,7 @@
cmOutputConverter::cmOutputConverter(cmState::Snapshot snapshot)
: StateSnapshot(snapshot), LinkScriptShell(false)
{
assert(this->StateSnapshot.IsValid());
}
//----------------------------------------------------------------------------
......
......@@ -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(
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment