cmMakefile: Add access to the top-level execution context.

This is cheaper than getting the whole backtrace, and the cmListFileBacktrace
will not always be composed of cmListFileContext objects.
This commit is contained in:
Stephen Kelly 2015-05-18 21:35:29 +02:00
parent 1ec1bf9f07
commit e17b5e4262
3 changed files with 13 additions and 6 deletions

View File

@ -113,7 +113,7 @@ const char* cmConditionEvaluator::GetDefinitionIfUnquoted(
if(def && argument.WasQuoted() && this->Policy54Status == cmPolicies::WARN)
{
bool hasBeenReported = this->Makefile.HasCMP0054AlreadyBeenReported(
this->Makefile.GetBacktrace()[0]);
this->Makefile.GetExecutionContext());
if(!hasBeenReported)
{
@ -162,7 +162,7 @@ bool cmConditionEvaluator::IsKeyword(std::string const& keyword,
this->Policy54Status == cmPolicies::WARN)
{
bool hasBeenReported = this->Makefile.HasCMP0054AlreadyBeenReported(
this->Makefile.GetBacktrace()[0]);
this->Makefile.GetExecutionContext());
if(!hasBeenReported)
{

View File

@ -377,6 +377,12 @@ cmListFileBacktrace cmMakefile::GetBacktrace() const
return backtrace;
}
//----------------------------------------------------------------------------
cmListFileContext cmMakefile::GetExecutionContext() const
{
return *this->CallStack.back().Context;
}
//----------------------------------------------------------------------------
void cmMakefile::PrintCommandTrace(const cmListFileFunction& lff) const
{
@ -1937,9 +1943,9 @@ void cmMakefile::CheckForUnused(const char* reason,
cmListFileBacktrace bt(this->GetLocalGenerator());
if (!this->CallStack.empty())
{
const cmListFileContext* file = this->CallStack.back().Context;
bt.push_back(*file);
path = file->FilePath.c_str();
cmListFileContext file = this->GetExecutionContext();
bt.push_back(file);
path = file.FilePath;
}
else
{
@ -3410,7 +3416,7 @@ void cmMakefile::AddFunctionBlocker(cmFunctionBlocker* fb)
if(!this->CallStack.empty())
{
// Record the context in which the blocker is created.
fb->SetStartingContext(*(this->CallStack.back().Context));
fb->SetStartingContext(this->GetExecutionContext());
}
this->FunctionBlockers.push_back(fb);

View File

@ -610,6 +610,7 @@ public:
* Get the current context backtrace.
*/
cmListFileBacktrace GetBacktrace() const;
cmListFileContext GetExecutionContext() const;
/**
* Get the vector of files created by this makefile