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
This commit is contained in:
commit
ef713503c8
@ -140,15 +140,8 @@ char* cmCommandArgumentParserHelper::ExpandVariable(const char* var)
|
|||||||
this->Makefile->GetHomeOutputDirectory()))
|
this->Makefile->GetHomeOutputDirectory()))
|
||||||
{
|
{
|
||||||
std::ostringstream msg;
|
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 << "\'";
|
msg << "uninitialized variable \'" << var << "\'";
|
||||||
this->Makefile->GetCMakeInstance()->IssueMessage(cmake::AUTHOR_WARNING,
|
this->Makefile->IssueMessage(cmake::AUTHOR_WARNING, msg.str());
|
||||||
msg.str(), lfc);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -203,15 +203,9 @@ bool cmIfCommand
|
|||||||
|
|
||||||
cmake::MessageType status;
|
cmake::MessageType status;
|
||||||
|
|
||||||
cmListFileContext execContext = this->Makefile->GetExecutionContext();
|
|
||||||
|
|
||||||
cmCommandContext commandContext;
|
|
||||||
commandContext.Line = execContext.Line;
|
|
||||||
commandContext.Name = execContext.Name;
|
|
||||||
|
|
||||||
cmConditionEvaluator conditionEvaluator(
|
cmConditionEvaluator conditionEvaluator(
|
||||||
*(this->Makefile), cmListFileContext::FromCommandContext(
|
*(this->Makefile),
|
||||||
commandContext, execContext.FilePath),
|
this->Makefile->GetExecutionContext(),
|
||||||
this->Makefile->GetBacktrace());
|
this->Makefile->GetBacktrace());
|
||||||
|
|
||||||
bool isTrue = conditionEvaluator.IsTrue(
|
bool isTrue = conditionEvaluator.IsTrue(
|
||||||
|
@ -69,17 +69,7 @@ cmLocalGenerator::~cmLocalGenerator()
|
|||||||
void cmLocalGenerator::IssueMessage(cmake::MessageType t,
|
void cmLocalGenerator::IssueMessage(cmake::MessageType t,
|
||||||
std::string const& text) const
|
std::string const& text) const
|
||||||
{
|
{
|
||||||
cmListFileContext lfc;
|
this->Makefile->IssueMessage(t, text);
|
||||||
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);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
@ -1608,7 +1598,7 @@ void cmLocalGenerator::OutputLinkLibraries(std::string& linkLibraries,
|
|||||||
"For compatibility with older versions of CMake, "
|
"For compatibility with older versions of CMake, "
|
||||||
"additional flags may be added to export symbols on all "
|
"additional flags may be added to export symbols on all "
|
||||||
"executables regardless of thier ENABLE_EXPORTS property.";
|
"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:
|
case cmPolicies::OLD:
|
||||||
// OLD behavior is to always add the flags
|
// OLD behavior is to always add the flags
|
||||||
@ -1616,7 +1606,7 @@ void cmLocalGenerator::OutputLinkLibraries(std::string& linkLibraries,
|
|||||||
break;
|
break;
|
||||||
case cmPolicies::REQUIRED_IF_USED:
|
case cmPolicies::REQUIRED_IF_USED:
|
||||||
case cmPolicies::REQUIRED_ALWAYS:
|
case cmPolicies::REQUIRED_ALWAYS:
|
||||||
this->Makefile->IssueMessage(
|
this->IssueMessage(
|
||||||
cmake::FATAL_ERROR,
|
cmake::FATAL_ERROR,
|
||||||
cmPolicies::GetRequiredPolicyError(cmPolicies::CMP0065)
|
cmPolicies::GetRequiredPolicyError(cmPolicies::CMP0065)
|
||||||
);
|
);
|
||||||
|
@ -222,6 +222,26 @@ void cmMakefile::PrintCommandTrace(const cmListFileFunction& lff) const
|
|||||||
cmSystemTools::Message(msg.str().c_str());
|
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,
|
bool cmMakefile::ExecuteCommand(const cmListFileFunction& lff,
|
||||||
cmExecutionStatus &status)
|
cmExecutionStatus &status)
|
||||||
@ -1941,21 +1961,15 @@ void cmMakefile::LogUnused(const char* reason,
|
|||||||
if (this->WarnUnused)
|
if (this->WarnUnused)
|
||||||
{
|
{
|
||||||
std::string path;
|
std::string path;
|
||||||
cmListFileContext lfc;
|
|
||||||
if (!this->ExecutionStatusStack.empty())
|
if (!this->ExecutionStatusStack.empty())
|
||||||
{
|
{
|
||||||
lfc = this->GetExecutionContext();
|
path = this->GetExecutionContext().FilePath;
|
||||||
path = lfc.FilePath;
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
path = this->GetCurrentSourceDirectory();
|
path = this->GetCurrentSourceDirectory();
|
||||||
path += "/CMakeLists.txt";
|
path += "/CMakeLists.txt";
|
||||||
lfc.FilePath = path;
|
|
||||||
lfc.Line = 0;
|
|
||||||
}
|
}
|
||||||
cmOutputConverter converter(this->StateSnapshot);
|
|
||||||
lfc.FilePath = converter.Convert(lfc.FilePath, cmOutputConverter::HOME);
|
|
||||||
|
|
||||||
if (this->CheckSystemVars ||
|
if (this->CheckSystemVars ||
|
||||||
cmSystemTools::IsSubDirectory(path,
|
cmSystemTools::IsSubDirectory(path,
|
||||||
@ -1967,9 +1981,7 @@ void cmMakefile::LogUnused(const char* reason,
|
|||||||
{
|
{
|
||||||
std::ostringstream msg;
|
std::ostringstream msg;
|
||||||
msg << "unused variable (" << reason << ") \'" << name << "\'";
|
msg << "unused variable (" << reason << ") \'" << name << "\'";
|
||||||
this->GetCMakeInstance()->IssueMessage(cmake::AUTHOR_WARNING,
|
this->IssueMessage(cmake::AUTHOR_WARNING, msg.str());
|
||||||
msg.str(),
|
|
||||||
lfc);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -2899,14 +2911,8 @@ cmake::MessageType cmMakefile::ExpandVariablesInStringNew(
|
|||||||
this->GetHomeOutputDirectory()))
|
this->GetHomeOutputDirectory()))
|
||||||
{
|
{
|
||||||
std::ostringstream msg;
|
std::ostringstream msg;
|
||||||
cmListFileContext lfc;
|
|
||||||
cmOutputConverter converter(this->StateSnapshot);
|
|
||||||
lfc.FilePath =
|
|
||||||
converter.Convert(filename, cmOutputConverter::HOME);
|
|
||||||
lfc.Line = line;
|
|
||||||
msg << "uninitialized variable \'" << lookup << "\'";
|
msg << "uninitialized variable \'" << lookup << "\'";
|
||||||
this->GetCMakeInstance()->IssueMessage(cmake::AUTHOR_WARNING,
|
this->IssueMessage(cmake::AUTHOR_WARNING, msg.str());
|
||||||
msg.str(), lfc);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -5148,16 +5154,3 @@ cmMakefile::MacroPushPop::~MacroPushPop()
|
|||||||
{
|
{
|
||||||
this->Makefile->PopMacroScope(this->ReportError);
|
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;
|
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
|
#endif
|
||||||
|
@ -22,6 +22,7 @@
|
|||||||
cmOutputConverter::cmOutputConverter(cmState::Snapshot snapshot)
|
cmOutputConverter::cmOutputConverter(cmState::Snapshot snapshot)
|
||||||
: StateSnapshot(snapshot), LinkScriptShell(false)
|
: StateSnapshot(snapshot), LinkScriptShell(false)
|
||||||
{
|
{
|
||||||
|
assert(this->StateSnapshot.IsValid());
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
|
@ -55,13 +55,9 @@ IsFunctionBlocked(const cmListFileFunction& lff, cmMakefile &mf,
|
|||||||
commandContext.Line = execContext.Line;
|
commandContext.Line = execContext.Line;
|
||||||
commandContext.Name = execContext.Name;
|
commandContext.Name = execContext.Name;
|
||||||
|
|
||||||
cmListFileContext conditionContext =
|
|
||||||
cmListFileContext::FromCommandContext(
|
|
||||||
commandContext,
|
|
||||||
this->GetStartingContext().FilePath);
|
|
||||||
|
|
||||||
cmConditionEvaluator conditionEvaluator(
|
cmConditionEvaluator conditionEvaluator(
|
||||||
mf, conditionContext,
|
mf,
|
||||||
|
this->GetStartingContext(),
|
||||||
mf.GetBacktrace(commandContext));
|
mf.GetBacktrace(commandContext));
|
||||||
|
|
||||||
bool isTrue = conditionEvaluator.IsTrue(
|
bool isTrue = conditionEvaluator.IsTrue(
|
||||||
|
Loading…
x
Reference in New Issue
Block a user