cmListFileBacktrace: Hide the context-stack implementation detail.
The backtrace will soon not be implemented in terms of a stack of cmListFileContext objects. Keep the cmListFileContext in the API for convenience for now.
This commit is contained in:
parent
a271f7f177
commit
61d52e6e77
@ -143,7 +143,7 @@ char* cmCommandArgumentParserHelper::ExpandVariable(const char* var)
|
|||||||
cmListFileContext lfc;
|
cmListFileContext lfc;
|
||||||
lfc.FilePath = this->FileName;
|
lfc.FilePath = this->FileName;
|
||||||
lfc.Line = this->FileLine;
|
lfc.Line = this->FileLine;
|
||||||
bt.push_back(lfc);
|
bt.Append(lfc);
|
||||||
msg << "uninitialized variable \'" << var << "\'";
|
msg << "uninitialized variable \'" << var << "\'";
|
||||||
this->Makefile->GetCMakeInstance()->IssueMessage(cmake::AUTHOR_WARNING,
|
this->Makefile->GetCMakeInstance()->IssueMessage(cmake::AUTHOR_WARNING,
|
||||||
msg.str(), bt);
|
msg.str(), bt);
|
||||||
|
@ -400,6 +400,11 @@ bool cmListFileParser::AddArgument(cmListFileLexer_Token* token,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void cmListFileBacktrace::Append(cmListFileContext const& context)
|
||||||
|
{
|
||||||
|
this->push_back(context);
|
||||||
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
void cmListFileBacktrace::MakeRelative()
|
void cmListFileBacktrace::MakeRelative()
|
||||||
{
|
{
|
||||||
@ -416,6 +421,31 @@ void cmListFileBacktrace::MakeRelative()
|
|||||||
this->Relative = true;
|
this->Relative = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void cmListFileBacktrace::PrintTitle(std::ostream& out)
|
||||||
|
{
|
||||||
|
if (this->empty())
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
out << (this->front().Line ? " at " : " in ") << this->front();
|
||||||
|
}
|
||||||
|
|
||||||
|
void cmListFileBacktrace::PrintCallStack(std::ostream& out)
|
||||||
|
{
|
||||||
|
if (size() <= 1)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const_iterator i = this->begin() + 1;
|
||||||
|
out << "Call Stack (most recent call first):\n";
|
||||||
|
while(i != this->end())
|
||||||
|
{
|
||||||
|
cmListFileContext const& lfc = *i;
|
||||||
|
out << " " << lfc << "\n";
|
||||||
|
++i;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
std::ostream& operator<<(std::ostream& os, cmListFileContext const& lfc)
|
std::ostream& operator<<(std::ostream& os, cmListFileContext const& lfc)
|
||||||
|
@ -71,7 +71,7 @@ struct cmListFileFunction: public cmListFileContext
|
|||||||
std::vector<cmListFileArgument> Arguments;
|
std::vector<cmListFileArgument> Arguments;
|
||||||
};
|
};
|
||||||
|
|
||||||
class cmListFileBacktrace: public std::vector<cmListFileContext>
|
class cmListFileBacktrace: private std::vector<cmListFileContext>
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
cmListFileBacktrace(cmLocalGenerator* localGen)
|
cmListFileBacktrace(cmLocalGenerator* localGen)
|
||||||
@ -80,7 +80,12 @@ class cmListFileBacktrace: public std::vector<cmListFileContext>
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Append(cmListFileContext const& context);
|
||||||
|
|
||||||
void MakeRelative();
|
void MakeRelative();
|
||||||
|
|
||||||
|
void PrintTitle(std::ostream& out);
|
||||||
|
void PrintCallStack(std::ostream& out);
|
||||||
private:
|
private:
|
||||||
cmLocalGenerator* LocalGenerator;
|
cmLocalGenerator* LocalGenerator;
|
||||||
bool Relative;
|
bool Relative;
|
||||||
|
@ -358,7 +358,7 @@ void cmMakefile::IssueMessage(cmake::MessageType t,
|
|||||||
lfc.FilePath = this->ListFileStack.back();
|
lfc.FilePath = this->ListFileStack.back();
|
||||||
}
|
}
|
||||||
lfc.Line = 0;
|
lfc.Line = 0;
|
||||||
backtrace.push_back(lfc);
|
backtrace.Append(lfc);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Issue the message.
|
// Issue the message.
|
||||||
@ -372,7 +372,7 @@ cmListFileBacktrace cmMakefile::GetBacktrace() const
|
|||||||
for(CallStackType::const_reverse_iterator i = this->CallStack.rbegin();
|
for(CallStackType::const_reverse_iterator i = this->CallStack.rbegin();
|
||||||
i != this->CallStack.rend(); ++i)
|
i != this->CallStack.rend(); ++i)
|
||||||
{
|
{
|
||||||
backtrace.push_back(*i->Context);
|
backtrace.Append(*i->Context);
|
||||||
}
|
}
|
||||||
return backtrace;
|
return backtrace;
|
||||||
}
|
}
|
||||||
@ -1944,7 +1944,7 @@ void cmMakefile::CheckForUnused(const char* reason,
|
|||||||
if (!this->CallStack.empty())
|
if (!this->CallStack.empty())
|
||||||
{
|
{
|
||||||
cmListFileContext file = this->GetExecutionContext();
|
cmListFileContext file = this->GetExecutionContext();
|
||||||
bt.push_back(file);
|
bt.Append(file);
|
||||||
path = file.FilePath;
|
path = file.FilePath;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -1954,7 +1954,7 @@ void cmMakefile::CheckForUnused(const char* reason,
|
|||||||
cmListFileContext lfc;
|
cmListFileContext lfc;
|
||||||
lfc.FilePath = path;
|
lfc.FilePath = path;
|
||||||
lfc.Line = 0;
|
lfc.Line = 0;
|
||||||
bt.push_back(lfc);
|
bt.Append(lfc);
|
||||||
}
|
}
|
||||||
if (this->CheckSystemVars ||
|
if (this->CheckSystemVars ||
|
||||||
cmSystemTools::IsSubDirectory(path,
|
cmSystemTools::IsSubDirectory(path,
|
||||||
@ -2884,7 +2884,7 @@ cmake::MessageType cmMakefile::ExpandVariablesInStringNew(
|
|||||||
cmListFileContext lfc;
|
cmListFileContext lfc;
|
||||||
lfc.FilePath = filename;
|
lfc.FilePath = filename;
|
||||||
lfc.Line = line;
|
lfc.Line = line;
|
||||||
bt.push_back(lfc);
|
bt.Append(lfc);
|
||||||
msg << "uninitialized variable \'" << lookup << "\'";
|
msg << "uninitialized variable \'" << lookup << "\'";
|
||||||
this->GetCMakeInstance()->IssueMessage(cmake::AUTHOR_WARNING,
|
this->GetCMakeInstance()->IssueMessage(cmake::AUTHOR_WARNING,
|
||||||
msg.str(), bt);
|
msg.str(), bt);
|
||||||
|
@ -2485,13 +2485,7 @@ void cmake::IssueMessage(cmake::MessageType t, std::string const& text,
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Add the immediate context.
|
// Add the immediate context.
|
||||||
cmListFileBacktrace::const_iterator i = backtrace.begin();
|
backtrace.PrintTitle(msg);
|
||||||
if(i != backtrace.end())
|
|
||||||
{
|
|
||||||
cmListFileContext const& lfc = *i;
|
|
||||||
msg << (lfc.Line? " at ": " in ") << lfc;
|
|
||||||
++i;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Add the message text.
|
// Add the message text.
|
||||||
{
|
{
|
||||||
@ -2502,16 +2496,7 @@ void cmake::IssueMessage(cmake::MessageType t, std::string const& text,
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Add the rest of the context.
|
// Add the rest of the context.
|
||||||
if(i != backtrace.end())
|
backtrace.PrintCallStack(msg);
|
||||||
{
|
|
||||||
msg << "Call Stack (most recent call first):\n";
|
|
||||||
while(i != backtrace.end())
|
|
||||||
{
|
|
||||||
cmListFileContext const& lfc = *i;
|
|
||||||
msg << " " << lfc << "\n";
|
|
||||||
++i;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Add a note about warning suppression.
|
// Add a note about warning suppression.
|
||||||
if(t == cmake::AUTHOR_WARNING)
|
if(t == cmake::AUTHOR_WARNING)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user