Add call stack to unused/uninitialized variable warnings
In commit v2.8.4~32^2~14 (Use cmake::IssueMessage for warnings, 2010-12-07) these warnings became formatted. It is more informative to give the full call stack with such warnings. Also it is easier to implement warnings with a full call stack because we do not have to construct a custom backtrace with only the top.
This commit is contained in:
parent
da07c506b9
commit
2faa8b3620
|
@ -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;
|
||||||
|
|
|
@ -1961,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,
|
||||||
|
@ -1987,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);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2919,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);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue