Merge topic 'refactor-cmListFileBacktrace'

0f96ef00 Remove unused cmake::IssueMessage overload
563bf9dd cmState: Remove unused entry point fields from snapshot data
7c36d206 cmListFileBacktrace: Refactor storage to provide efficient value semantics
1f6bd8a9 cmState: Avoid accumulating snapshot storage for backtraces
18b6676b cmState: Add Snapshot method to get bottom of call stack
This commit is contained in:
Brad King 2016-04-18 11:07:07 -04:00 committed by CMake Topic Stage
commit fa4ae9fb12
15 changed files with 268 additions and 247 deletions

View File

@ -398,65 +398,173 @@ bool cmListFileParser::AddArgument(cmListFileLexer_Token* token,
} }
} }
cmListFileBacktrace::cmListFileBacktrace(cmState::Snapshot snapshot, struct cmListFileBacktrace::Entry: public cmListFileContext
cmCommandContext const& cc)
: Context(cc)
, Snapshot(snapshot)
{ {
if (this->Snapshot.IsValid()) Entry(cmListFileContext const& lfc, Entry* up):
cmListFileContext(lfc), Up(up), RefCount(0)
{ {
this->Snapshot.Keep(); if (this->Up)
{
this->Up->Ref();
} }
} }
~Entry()
{
if (this->Up)
{
this->Up->Unref();
}
}
void Ref()
{
++this->RefCount;
}
void Unref()
{
if (--this->RefCount == 0)
{
delete this;
}
}
Entry* Up;
unsigned int RefCount;
};
cmListFileBacktrace::cmListFileBacktrace(cmState::Snapshot bottom,
Entry* up,
cmListFileContext const& lfc):
Bottom(bottom), Cur(new Entry(lfc, up))
{
assert(this->Bottom.IsValid());
this->Cur->Ref();
}
cmListFileBacktrace::cmListFileBacktrace(cmState::Snapshot bottom, Entry* cur):
Bottom(bottom), Cur(cur)
{
if (this->Cur)
{
assert(this->Bottom.IsValid());
this->Cur->Ref();
}
}
cmListFileBacktrace::cmListFileBacktrace(): Bottom(), Cur(0)
{
}
cmListFileBacktrace::cmListFileBacktrace(cmState::Snapshot snapshot):
Bottom(snapshot.GetCallStackBottom()), Cur(0)
{
}
cmListFileBacktrace::cmListFileBacktrace(cmListFileBacktrace const& r):
Bottom(r.Bottom), Cur(r.Cur)
{
if (this->Cur)
{
assert(this->Bottom.IsValid());
this->Cur->Ref();
}
}
cmListFileBacktrace&
cmListFileBacktrace::operator=(cmListFileBacktrace const& r)
{
cmListFileBacktrace tmp(r);
std::swap(this->Cur, tmp.Cur);
std::swap(this->Bottom, tmp.Bottom);
return *this;
}
cmListFileBacktrace::~cmListFileBacktrace() cmListFileBacktrace::~cmListFileBacktrace()
{ {
if (this->Cur)
{
this->Cur->Unref();
}
}
cmListFileBacktrace
cmListFileBacktrace::Push(std::string const& file) const
{
// We are entering a file-level scope but have not yet reached
// any specific line or command invocation within it. This context
// is useful to print when it is at the top but otherwise can be
// skipped during call stack printing.
cmListFileContext lfc;
lfc.FilePath = file;
return cmListFileBacktrace(this->Bottom, this->Cur, lfc);
}
cmListFileBacktrace
cmListFileBacktrace::Push(cmListFileContext const& lfc) const
{
return cmListFileBacktrace(this->Bottom, this->Cur, lfc);
}
cmListFileBacktrace cmListFileBacktrace::Pop() const
{
assert(this->Cur);
return cmListFileBacktrace(this->Bottom, this->Cur->Up);
}
cmListFileContext const& cmListFileBacktrace::Top() const
{
if (this->Cur)
{
return *this->Cur;
}
else
{
static cmListFileContext const empty;
return empty;
}
} }
void cmListFileBacktrace::PrintTitle(std::ostream& out) const void cmListFileBacktrace::PrintTitle(std::ostream& out) const
{ {
if (!this->Snapshot.IsValid()) if (!this->Cur)
{ {
return; return;
} }
cmOutputConverter converter(this->Snapshot); cmOutputConverter converter(this->Bottom);
cmListFileContext lfc = cmListFileContext lfc = *this->Cur;
cmListFileContext::FromCommandContext( if (!this->Bottom.GetState()->GetIsInTryCompile())
this->Context, this->Snapshot.GetExecutionListFile()); {
lfc.FilePath = converter.Convert(lfc.FilePath, cmOutputConverter::HOME); lfc.FilePath = converter.Convert(lfc.FilePath, cmOutputConverter::HOME);
}
out << (lfc.Line ? " at " : " in ") << lfc; out << (lfc.Line ? " at " : " in ") << lfc;
} }
void cmListFileBacktrace::PrintCallStack(std::ostream& out) const void cmListFileBacktrace::PrintCallStack(std::ostream& out) const
{ {
if (!this->Snapshot.IsValid()) if (!this->Cur || !this->Cur->Up)
{
return;
}
cmState::Snapshot parent = this->Snapshot.GetCallStackParent();
if (!parent.IsValid() || parent.GetExecutionListFile().empty())
{ {
return; return;
} }
cmOutputConverter converter(this->Snapshot); bool first = true;
std::string commandName = this->Snapshot.GetEntryPointCommand(); cmOutputConverter converter(this->Bottom);
long commandLine = this->Snapshot.GetEntryPointLine(); for (Entry* i = this->Cur->Up; i; i = i->Up)
{
if (i->Name.empty())
{
// Skip this whole-file scope. When we get here we already will
// have printed a more-specific context within the file.
continue;
}
if (first)
{
first = false;
out << "Call Stack (most recent call first):\n"; out << "Call Stack (most recent call first):\n";
while(parent.IsValid()) }
cmListFileContext lfc = *i;
if (!this->Bottom.GetState()->GetIsInTryCompile())
{ {
cmListFileContext lfc; lfc.FilePath = converter.Convert(lfc.FilePath, cmOutputConverter::HOME);
lfc.Name = commandName; }
lfc.Line = commandLine;
lfc.FilePath = converter.Convert(parent.GetExecutionListFile(),
cmOutputConverter::HOME);
out << " " << lfc << "\n"; out << " " << lfc << "\n";
commandName = parent.GetEntryPointCommand();
commandLine = parent.GetEntryPointLine();
parent = parent.GetCallStackParent();
} }
} }

View File

@ -87,18 +87,53 @@ struct cmListFileFunction: public cmCommandContext
std::vector<cmListFileArgument> Arguments; std::vector<cmListFileArgument> Arguments;
}; };
// Represent a backtrace (call stack). Provide value semantics
// but use efficient reference-counting underneath to avoid copies.
class cmListFileBacktrace class cmListFileBacktrace
{ {
public: public:
cmListFileBacktrace(cmState::Snapshot snapshot = cmState::Snapshot(), // Default-constructed backtrace may not be used until after
cmCommandContext const& cc = cmCommandContext()); // set via assignment from a backtrace constructed with a
// valid snapshot.
cmListFileBacktrace();
// Construct an empty backtrace whose bottom sits in the directory
// indicated by the given valid snapshot.
cmListFileBacktrace(cmState::Snapshot snapshot);
// Backtraces may be copied and assigned as values.
cmListFileBacktrace(cmListFileBacktrace const& r);
cmListFileBacktrace& operator=(cmListFileBacktrace const& r);
~cmListFileBacktrace(); ~cmListFileBacktrace();
// Get a backtrace with the given file scope added to the top.
// May not be called until after construction with a valid snapshot.
cmListFileBacktrace Push(std::string const& file) const;
// Get a backtrace with the given call context added to the top.
// May not be called until after construction with a valid snapshot.
cmListFileBacktrace Push(cmListFileContext const& lfc) const;
// Get a backtrace with the top level removed.
// May not be called until after a matching Push.
cmListFileBacktrace Pop() const;
// Get the context at the top of the backtrace.
// Returns an empty context if the backtrace is empty.
cmListFileContext const& Top() const;
// Print the top of the backtrace.
void PrintTitle(std::ostream& out) const; void PrintTitle(std::ostream& out) const;
// Print the call stack below the top of the backtrace.
void PrintCallStack(std::ostream& out) const; void PrintCallStack(std::ostream& out) const;
private: private:
cmCommandContext Context; struct Entry;
cmState::Snapshot Snapshot; cmState::Snapshot Bottom;
Entry* Cur;
cmListFileBacktrace(cmState::Snapshot bottom, Entry* up,
cmListFileContext const& lfc);
cmListFileBacktrace(cmState::Snapshot bottom, Entry* cur);
}; };
struct cmListFile struct cmListFile

View File

@ -46,7 +46,8 @@
cmMakefile::cmMakefile(cmGlobalGenerator* globalGenerator, cmMakefile::cmMakefile(cmGlobalGenerator* globalGenerator,
cmState::Snapshot const& snapshot) cmState::Snapshot const& snapshot)
: GlobalGenerator(globalGenerator), : GlobalGenerator(globalGenerator),
StateSnapshot(snapshot) StateSnapshot(snapshot),
Backtrace(snapshot)
{ {
this->IsSourceFileTryCompile = false; this->IsSourceFileTryCompile = false;
@ -115,24 +116,8 @@ void cmMakefile::IssueMessage(cmake::MessageType t,
{ {
this->ExecutionStatusStack.back()->SetNestedError(true); this->ExecutionStatusStack.back()->SetNestedError(true);
} }
this->GetCMakeInstance()->IssueMessage(t, text, this->GetBacktrace(),
force);
}
else
{
cmListFileContext lfc;
// We are not currently executing a command. Add whatever context
// information we have.
lfc.FilePath = this->GetExecutionFilePath();
if(!this->GetCMakeInstance()->GetIsInTryCompile())
{
cmOutputConverter converter(this->StateSnapshot);
lfc.FilePath = converter.Convert(lfc.FilePath, cmOutputConverter::HOME);
}
lfc.Line = 0;
this->GetCMakeInstance()->IssueMessage(t, text, lfc, force);
} }
this->GetCMakeInstance()->IssueMessage(t, text, this->GetBacktrace(), force);
} }
cmStringRange cmMakefile::GetIncludeDirectoriesEntries() const cmStringRange cmMakefile::GetIncludeDirectoriesEntries() const
@ -170,29 +155,28 @@ cmBacktraceRange cmMakefile::GetCompileDefinitionsBacktraces() const
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
cmListFileBacktrace cmMakefile::GetBacktrace() const cmListFileBacktrace cmMakefile::GetBacktrace() const
{ {
cmListFileBacktrace backtrace; return this->Backtrace;
if (!this->ContextStack.empty())
{
backtrace = cmListFileBacktrace(this->StateSnapshot,
*this->ContextStack.back());
}
return backtrace;
} }
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
cmListFileBacktrace cmListFileBacktrace cmMakefile::GetBacktrace(cmCommandContext const& cc) const
cmMakefile::GetBacktrace(cmCommandContext const& cc) const
{ {
cmState::Snapshot snp = this->StateSnapshot; cmListFileContext lfc;
return cmListFileBacktrace(snp, cc); lfc.Name = cc.Name;
lfc.Line = cc.Line;
lfc.FilePath = this->StateSnapshot.GetExecutionListFile();
return this->Backtrace.Push(lfc);
} }
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
cmListFileContext cmMakefile::GetExecutionContext() const cmListFileContext cmMakefile::GetExecutionContext() const
{ {
return cmListFileContext::FromCommandContext( cmListFileContext const& cur = this->Backtrace.Top();
*this->ContextStack.back(), cmListFileContext lfc;
this->StateSnapshot.GetExecutionListFile()); lfc.Name = cur.Name;
lfc.Line = cur.Line;
lfc.FilePath = this->StateSnapshot.GetExecutionListFile();
return lfc;
} }
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
@ -226,17 +210,20 @@ void cmMakefile::PrintCommandTrace(const cmListFileFunction& lff) const
class cmMakefileCall class cmMakefileCall
{ {
public: public:
cmMakefileCall(cmMakefile* mf, const cmCommandContext& lfc, cmMakefileCall(cmMakefile* mf, cmCommandContext const& cc,
cmExecutionStatus& status): Makefile(mf) cmExecutionStatus& status): Makefile(mf)
{ {
this->Makefile->ContextStack.push_back(&lfc); cmListFileContext const& lfc =
cmListFileContext::FromCommandContext(
cc, this->Makefile->StateSnapshot.GetExecutionListFile());
this->Makefile->Backtrace = this->Makefile->Backtrace.Push(lfc);
this->Makefile->ExecutionStatusStack.push_back(&status); this->Makefile->ExecutionStatusStack.push_back(&status);
} }
~cmMakefileCall() ~cmMakefileCall()
{ {
this->Makefile->ExecutionStatusStack.pop_back(); this->Makefile->ExecutionStatusStack.pop_back();
this->Makefile->ContextStack.pop_back(); this->Makefile->Backtrace = this->Makefile->Backtrace.Pop();
} }
private: private:
cmMakefile* Makefile; cmMakefile* Makefile;
@ -350,13 +337,14 @@ cmMakefile::IncludeScope::IncludeScope(cmMakefile* mf,
Makefile(mf), NoPolicyScope(noPolicyScope), Makefile(mf), NoPolicyScope(noPolicyScope),
CheckCMP0011(false), ReportError(true) CheckCMP0011(false), ReportError(true)
{ {
this->Makefile->Backtrace =
this->Makefile->Backtrace.Push(filenametoread);
this->Makefile->PushFunctionBlockerBarrier(); this->Makefile->PushFunctionBlockerBarrier();
this->Makefile->StateSnapshot = this->Makefile->StateSnapshot =
this->Makefile->GetState()->CreateIncludeFileSnapshot( this->Makefile->GetState()->CreateIncludeFileSnapshot(
this->Makefile->StateSnapshot, this->Makefile->StateSnapshot,
this->Makefile->ContextStack.back()->Name,
this->Makefile->ContextStack.back()->Line,
filenametoread); filenametoread);
if(!this->NoPolicyScope) if(!this->NoPolicyScope)
{ {
@ -416,6 +404,8 @@ cmMakefile::IncludeScope::~IncludeScope()
this->Makefile->PopSnapshot(this->ReportError); this->Makefile->PopSnapshot(this->ReportError);
this->Makefile->PopFunctionBlockerBarrier(this->ReportError); this->Makefile->PopFunctionBlockerBarrier(this->ReportError);
this->Makefile->Backtrace = this->Makefile->Backtrace.Pop();
} }
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
@ -458,25 +448,6 @@ void cmMakefile::IncludeScope::EnforceCMP0011()
} }
} }
class cmParseFileScope
{
public:
cmParseFileScope(cmMakefile* mf)
: Makefile(mf)
{
this->Makefile->ContextStack.push_back(&this->Context);
}
~cmParseFileScope()
{
this->Makefile->ContextStack.pop_back();
}
private:
cmMakefile* Makefile;
cmCommandContext Context;
};
bool cmMakefile::ReadDependentFile(const char* filename, bool noPolicyScope) bool cmMakefile::ReadDependentFile(const char* filename, bool noPolicyScope)
{ {
this->AddDefinition("CMAKE_PARENT_LIST_FILE", this->AddDefinition("CMAKE_PARENT_LIST_FILE",
@ -488,13 +459,10 @@ bool cmMakefile::ReadDependentFile(const char* filename, bool noPolicyScope)
IncludeScope incScope(this, filenametoread, noPolicyScope); IncludeScope incScope(this, filenametoread, noPolicyScope);
cmListFile listFile; cmListFile listFile;
{
cmParseFileScope pfs(this);
if (!listFile.ParseFile(filenametoread.c_str(), false, this)) if (!listFile.ParseFile(filenametoread.c_str(), false, this))
{ {
return false; return false;
} }
}
this->ReadListFile(listFile, filenametoread); this->ReadListFile(listFile, filenametoread);
if(cmSystemTools::GetFatalErrorOccured()) if(cmSystemTools::GetFatalErrorOccured())
@ -510,16 +478,12 @@ public:
ListFileScope(cmMakefile* mf, std::string const& filenametoread) ListFileScope(cmMakefile* mf, std::string const& filenametoread)
: Makefile(mf), ReportError(true) : Makefile(mf), ReportError(true)
{ {
long line = 0; this->Makefile->Backtrace =
std::string name; this->Makefile->Backtrace.Push(filenametoread);
if (!this->Makefile->ContextStack.empty())
{
line = this->Makefile->ContextStack.back()->Line;
name = this->Makefile->ContextStack.back()->Name;
}
this->Makefile->StateSnapshot = this->Makefile->StateSnapshot =
this->Makefile->GetState()->CreateInlineListFileSnapshot( this->Makefile->GetState()->CreateInlineListFileSnapshot(
this->Makefile->StateSnapshot, name, line, filenametoread); this->Makefile->StateSnapshot, filenametoread);
assert(this->Makefile->StateSnapshot.IsValid()); assert(this->Makefile->StateSnapshot.IsValid());
this->Makefile->PushFunctionBlockerBarrier(); this->Makefile->PushFunctionBlockerBarrier();
@ -529,6 +493,7 @@ public:
{ {
this->Makefile->PopSnapshot(this->ReportError); this->Makefile->PopSnapshot(this->ReportError);
this->Makefile->PopFunctionBlockerBarrier(this->ReportError); this->Makefile->PopFunctionBlockerBarrier(this->ReportError);
this->Makefile->Backtrace = this->Makefile->Backtrace.Pop();
} }
void Quiet() { this->ReportError = false; } void Quiet() { this->ReportError = false; }
@ -546,13 +511,10 @@ bool cmMakefile::ReadListFile(const char* filename)
ListFileScope scope(this, filenametoread); ListFileScope scope(this, filenametoread);
cmListFile listFile; cmListFile listFile;
{
cmParseFileScope pfs(this);
if (!listFile.ParseFile(filenametoread.c_str(), false, this)) if (!listFile.ParseFile(filenametoread.c_str(), false, this))
{ {
return false; return false;
} }
}
this->ReadListFile(listFile, filenametoread); this->ReadListFile(listFile, filenametoread);
if(cmSystemTools::GetFatalErrorOccured()) if(cmSystemTools::GetFatalErrorOccured())
@ -1525,9 +1487,7 @@ void cmMakefile::PushFunctionScope(std::string const& fileName,
{ {
this->StateSnapshot = this->StateSnapshot =
this->GetState()->CreateFunctionCallSnapshot( this->GetState()->CreateFunctionCallSnapshot(
this->StateSnapshot, this->StateSnapshot, fileName);
this->ContextStack.back()->Name, this->ContextStack.back()->Line,
fileName);
assert(this->StateSnapshot.IsValid()); assert(this->StateSnapshot.IsValid());
this->PushLoopBlockBarrier(); this->PushLoopBlockBarrier();
@ -1563,9 +1523,7 @@ void cmMakefile::PushMacroScope(std::string const& fileName,
{ {
this->StateSnapshot = this->StateSnapshot =
this->GetState()->CreateMacroCallSnapshot( this->GetState()->CreateMacroCallSnapshot(
this->StateSnapshot, this->StateSnapshot, fileName);
this->ContextStack.back()->Name, this->ContextStack.back()->Line,
fileName);
assert(this->StateSnapshot.IsValid()); assert(this->StateSnapshot.IsValid());
this->PushFunctionBlockerBarrier(); this->PushFunctionBlockerBarrier();
@ -1633,6 +1591,15 @@ private:
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
void cmMakefile::Configure() void cmMakefile::Configure()
{ {
std::string currentStart =
this->StateSnapshot.GetDirectory().GetCurrentSource();
currentStart += "/CMakeLists.txt";
// Add the bottom of all backtraces within this directory.
// We will never pop this scope because it should be available
// for messages during the generate step too.
this->Backtrace = this->Backtrace.Push(currentStart);
BuildsystemFileScope scope(this); BuildsystemFileScope scope(this);
// make sure the CMakeFiles dir is there // make sure the CMakeFiles dir is there
@ -1640,20 +1607,14 @@ void cmMakefile::Configure()
filesDir += cmake::GetCMakeFilesDirectory(); filesDir += cmake::GetCMakeFilesDirectory();
cmSystemTools::MakeDirectory(filesDir.c_str()); cmSystemTools::MakeDirectory(filesDir.c_str());
std::string currentStart =
this->StateSnapshot.GetDirectory().GetCurrentSource();
currentStart += "/CMakeLists.txt";
assert(cmSystemTools::FileExists(currentStart.c_str(), true)); assert(cmSystemTools::FileExists(currentStart.c_str(), true));
this->AddDefinition("CMAKE_PARENT_LIST_FILE", currentStart.c_str()); this->AddDefinition("CMAKE_PARENT_LIST_FILE", currentStart.c_str());
cmListFile listFile; cmListFile listFile;
{
cmParseFileScope pfs(this);
if (!listFile.ParseFile(currentStart.c_str(), this->IsRootMakefile(), this)) if (!listFile.ParseFile(currentStart.c_str(), this->IsRootMakefile(), this))
{ {
return; return;
} }
}
this->ReadListFile(listFile, currentStart); this->ReadListFile(listFile, currentStart);
if(cmSystemTools::GetFatalErrorOccured()) if(cmSystemTools::GetFatalErrorOccured())
{ {
@ -1740,9 +1701,7 @@ void cmMakefile::AddSubDirectory(const std::string& srcPath,
} }
cmState::Snapshot newSnapshot = this->GetState() cmState::Snapshot newSnapshot = this->GetState()
->CreateBuildsystemDirectorySnapshot(this->StateSnapshot, ->CreateBuildsystemDirectorySnapshot(this->StateSnapshot);
this->ContextStack.back()->Name,
this->ContextStack.back()->Line);
newSnapshot.GetDirectory().SetCurrentSource(srcPath); newSnapshot.GetDirectory().SetCurrentSource(srcPath);
newSnapshot.GetDirectory().SetCurrentBinary(binPath); newSnapshot.GetDirectory().SetCurrentBinary(binPath);
@ -4128,17 +4087,8 @@ std::string cmMakefile::FormatListFileStack() const
void cmMakefile::PushScope() void cmMakefile::PushScope()
{ {
std::string commandName;
long line = 0;
if (!this->ContextStack.empty())
{
commandName = this->ContextStack.back()->Name;
line = this->ContextStack.back()->Line;
}
this->StateSnapshot = this->GetState()->CreateVariableScopeSnapshot( this->StateSnapshot = this->GetState()->CreateVariableScopeSnapshot(
this->StateSnapshot, this->StateSnapshot);
commandName,
line);
this->PushLoopBlockBarrier(); this->PushLoopBlockBarrier();
#if defined(CMAKE_BUILD_WITH_CMAKE) #if defined(CMAKE_BUILD_WITH_CMAKE)

View File

@ -835,6 +835,7 @@ private:
cmMakefile& operator=(const cmMakefile& mf); cmMakefile& operator=(const cmMakefile& mf);
cmState::Snapshot StateSnapshot; cmState::Snapshot StateSnapshot;
cmListFileBacktrace Backtrace;
void ReadListFile(cmListFile const& listFile, void ReadListFile(cmListFile const& listFile,
const std::string& filenametoread); const std::string& filenametoread);
@ -862,7 +863,6 @@ private:
std::vector<cmGeneratorExpressionEvaluationFile*> EvaluationFiles; std::vector<cmGeneratorExpressionEvaluationFile*> EvaluationFiles;
std::vector<cmCommandContext const*> ContextStack;
std::vector<cmExecutionStatus*> ExecutionStatusStack; std::vector<cmExecutionStatus*> ExecutionStatusStack;
friend class cmMakefileCall; friend class cmMakefileCall;
friend class cmParseFileScope; friend class cmParseFileScope;

View File

@ -35,8 +35,6 @@ struct cmState::SnapshotDataType
cmLinkedTree<cmDefinitions>::iterator Vars; cmLinkedTree<cmDefinitions>::iterator Vars;
cmLinkedTree<cmDefinitions>::iterator Root; cmLinkedTree<cmDefinitions>::iterator Root;
cmLinkedTree<cmDefinitions>::iterator Parent; cmLinkedTree<cmDefinitions>::iterator Parent;
std::string EntryPointCommand;
long EntryPointLine;
std::vector<std::string>::size_type IncludeDirectoryPosition; std::vector<std::string>::size_type IncludeDirectoryPosition;
std::vector<std::string>::size_type CompileDefinitionsPosition; std::vector<std::string>::size_type CompileDefinitionsPosition;
std::vector<std::string>::size_type CompileOptionsPosition; std::vector<std::string>::size_type CompileOptionsPosition;
@ -845,14 +843,10 @@ cmState::Snapshot cmState::CreateBaseSnapshot()
} }
cmState::Snapshot cmState::Snapshot
cmState::CreateBuildsystemDirectorySnapshot(Snapshot originSnapshot, cmState::CreateBuildsystemDirectorySnapshot(Snapshot originSnapshot)
std::string const& entryPointCommand,
long entryPointLine)
{ {
assert(originSnapshot.IsValid()); assert(originSnapshot.IsValid());
PositionType pos = this->SnapshotData.Push(originSnapshot.Position); PositionType pos = this->SnapshotData.Push(originSnapshot.Position);
pos->EntryPointLine = entryPointLine;
pos->EntryPointCommand = entryPointCommand;
pos->DirectoryParent = originSnapshot.Position; pos->DirectoryParent = originSnapshot.Position;
pos->ScopeParent = originSnapshot.Position; pos->ScopeParent = originSnapshot.Position;
pos->SnapshotType = BuildsystemDirectoryType; pos->SnapshotType = BuildsystemDirectoryType;
@ -886,15 +880,11 @@ cmState::CreateBuildsystemDirectorySnapshot(Snapshot originSnapshot,
cmState::Snapshot cmState::Snapshot
cmState::CreateFunctionCallSnapshot(cmState::Snapshot originSnapshot, cmState::CreateFunctionCallSnapshot(cmState::Snapshot originSnapshot,
std::string const& entryPointCommand,
long entryPointLine,
std::string const& fileName) std::string const& fileName)
{ {
PositionType pos = this->SnapshotData.Push(originSnapshot.Position, PositionType pos = this->SnapshotData.Push(originSnapshot.Position,
*originSnapshot.Position); *originSnapshot.Position);
pos->ScopeParent = originSnapshot.Position; pos->ScopeParent = originSnapshot.Position;
pos->EntryPointLine = entryPointLine;
pos->EntryPointCommand = entryPointCommand;
pos->SnapshotType = FunctionCallType; pos->SnapshotType = FunctionCallType;
pos->Keep = false; pos->Keep = false;
pos->ExecutionListFile = this->ExecutionListFiles.Push( pos->ExecutionListFile = this->ExecutionListFiles.Push(
@ -912,14 +902,10 @@ cmState::CreateFunctionCallSnapshot(cmState::Snapshot originSnapshot,
cmState::Snapshot cmState::Snapshot
cmState::CreateMacroCallSnapshot(cmState::Snapshot originSnapshot, cmState::CreateMacroCallSnapshot(cmState::Snapshot originSnapshot,
std::string const& entryPointCommand,
long entryPointLine,
std::string const& fileName) std::string const& fileName)
{ {
PositionType pos = this->SnapshotData.Push(originSnapshot.Position, PositionType pos = this->SnapshotData.Push(originSnapshot.Position,
*originSnapshot.Position); *originSnapshot.Position);
pos->EntryPointLine = entryPointLine;
pos->EntryPointCommand = entryPointCommand;
pos->SnapshotType = MacroCallType; pos->SnapshotType = MacroCallType;
pos->Keep = false; pos->Keep = false;
pos->ExecutionListFile = this->ExecutionListFiles.Push( pos->ExecutionListFile = this->ExecutionListFiles.Push(
@ -932,14 +918,10 @@ cmState::CreateMacroCallSnapshot(cmState::Snapshot originSnapshot,
cmState::Snapshot cmState::Snapshot
cmState::CreateIncludeFileSnapshot(cmState::Snapshot originSnapshot, cmState::CreateIncludeFileSnapshot(cmState::Snapshot originSnapshot,
const std::string& entryPointCommand,
long entryPointLine,
const std::string& fileName) const std::string& fileName)
{ {
PositionType pos = this->SnapshotData.Push(originSnapshot.Position, PositionType pos = this->SnapshotData.Push(originSnapshot.Position,
*originSnapshot.Position); *originSnapshot.Position);
pos->EntryPointLine = entryPointLine;
pos->EntryPointCommand = entryPointCommand;
pos->SnapshotType = IncludeFileType; pos->SnapshotType = IncludeFileType;
pos->Keep = true; pos->Keep = true;
pos->ExecutionListFile = this->ExecutionListFiles.Push( pos->ExecutionListFile = this->ExecutionListFiles.Push(
@ -951,15 +933,11 @@ cmState::CreateIncludeFileSnapshot(cmState::Snapshot originSnapshot,
} }
cmState::Snapshot cmState::Snapshot
cmState::CreateVariableScopeSnapshot(cmState::Snapshot originSnapshot, cmState::CreateVariableScopeSnapshot(cmState::Snapshot originSnapshot)
std::string const& entryPointCommand,
long entryPointLine)
{ {
PositionType pos = this->SnapshotData.Push(originSnapshot.Position, PositionType pos = this->SnapshotData.Push(originSnapshot.Position,
*originSnapshot.Position); *originSnapshot.Position);
pos->ScopeParent = originSnapshot.Position; pos->ScopeParent = originSnapshot.Position;
pos->EntryPointLine = entryPointLine;
pos->EntryPointCommand = entryPointCommand;
pos->SnapshotType = VariableScopeType; pos->SnapshotType = VariableScopeType;
pos->Keep = false; pos->Keep = false;
pos->PolicyScope = originSnapshot.Position->Policies; pos->PolicyScope = originSnapshot.Position->Policies;
@ -975,14 +953,10 @@ cmState::CreateVariableScopeSnapshot(cmState::Snapshot originSnapshot,
cmState::Snapshot cmState::Snapshot
cmState::CreateInlineListFileSnapshot(cmState::Snapshot originSnapshot, cmState::CreateInlineListFileSnapshot(cmState::Snapshot originSnapshot,
const std::string& entryPointCommand,
long entryPointLine,
const std::string& fileName) const std::string& fileName)
{ {
PositionType pos = this->SnapshotData.Push(originSnapshot.Position, PositionType pos = this->SnapshotData.Push(originSnapshot.Position,
*originSnapshot.Position); *originSnapshot.Position);
pos->EntryPointLine = entryPointLine;
pos->EntryPointCommand = entryPointCommand;
pos->SnapshotType = InlineListFileType; pos->SnapshotType = InlineListFileType;
pos->Keep = true; pos->Keep = true;
pos->ExecutionListFile = this->ExecutionListFiles.Push( pos->ExecutionListFile = this->ExecutionListFiles.Push(
@ -1098,11 +1072,6 @@ void cmState::Directory::SetCurrentBinary(std::string const& dir)
this->Snapshot_.SetDefinition("CMAKE_CURRENT_BINARY_DIR", loc.c_str()); this->Snapshot_.SetDefinition("CMAKE_CURRENT_BINARY_DIR", loc.c_str());
} }
void cmState::Snapshot::Keep()
{
this->Position->Keep = true;
}
void cmState::Snapshot::SetListFile(const std::string& listfile) void cmState::Snapshot::SetListFile(const std::string& listfile)
{ {
*this->Position->ExecutionListFile = listfile; *this->Position->ExecutionListFile = listfile;
@ -1145,16 +1114,6 @@ std::string cmState::Snapshot::GetExecutionListFile() const
return *this->Position->ExecutionListFile; return *this->Position->ExecutionListFile;
} }
std::string cmState::Snapshot::GetEntryPointCommand() const
{
return this->Position->EntryPointCommand;
}
long cmState::Snapshot::GetEntryPointLine() const
{
return this->Position->EntryPointLine;
}
bool cmState::Snapshot::IsValid() const bool cmState::Snapshot::IsValid() const
{ {
return this->State && this->Position.IsValid() return this->State && this->Position.IsValid()
@ -1213,6 +1172,21 @@ cmState::Snapshot cmState::Snapshot::GetCallStackParent() const
return snapshot; return snapshot;
} }
cmState::Snapshot cmState::Snapshot::GetCallStackBottom() const
{
assert(this->State);
assert(this->Position != this->State->SnapshotData.Root());
PositionType pos = this->Position;
while (pos->SnapshotType != cmState::BaseType &&
pos->SnapshotType != cmState::BuildsystemDirectoryType &&
pos != this->State->SnapshotData.Root())
{
++pos;
}
return Snapshot(this->State, pos);
}
void cmState::Snapshot::PushPolicy(cmPolicies::PolicyMap entry, bool weak) void cmState::Snapshot::PushPolicy(cmPolicies::PolicyMap entry, bool weak)
{ {
PositionType pos = this->Position; PositionType pos = this->Position;

View File

@ -63,18 +63,16 @@ public:
std::vector<std::string> ClosureKeys() const; std::vector<std::string> ClosureKeys() const;
bool RaiseScope(std::string const& var, const char* varDef); bool RaiseScope(std::string const& var, const char* varDef);
void Keep();
void SetListFile(std::string const& listfile); void SetListFile(std::string const& listfile);
std::string GetExecutionListFile() const; std::string GetExecutionListFile() const;
std::vector<Snapshot> GetChildren(); std::vector<Snapshot> GetChildren();
std::string GetEntryPointCommand() const;
long GetEntryPointLine() const;
bool IsValid() const; bool IsValid() const;
Snapshot GetBuildsystemDirectoryParent() const; Snapshot GetBuildsystemDirectoryParent() const;
Snapshot GetCallStackParent() const; Snapshot GetCallStackParent() const;
Snapshot GetCallStackBottom() const;
SnapshotType GetType() const; SnapshotType GetType() const;
void SetPolicy(cmPolicies::PolicyID id, cmPolicies::PolicyStatus status); void SetPolicy(cmPolicies::PolicyID id, cmPolicies::PolicyStatus status);
@ -192,27 +190,15 @@ public:
Snapshot CreateBaseSnapshot(); Snapshot CreateBaseSnapshot();
Snapshot Snapshot
CreateBuildsystemDirectorySnapshot(Snapshot originSnapshot, CreateBuildsystemDirectorySnapshot(Snapshot originSnapshot);
std::string const& entryPointCommand,
long entryPointLine);
Snapshot CreateFunctionCallSnapshot(Snapshot originSnapshot, Snapshot CreateFunctionCallSnapshot(Snapshot originSnapshot,
std::string const& entryPointCommand,
long entryPointLine,
std::string const& fileName); std::string const& fileName);
Snapshot CreateMacroCallSnapshot(Snapshot originSnapshot, Snapshot CreateMacroCallSnapshot(Snapshot originSnapshot,
std::string const& entryPointCommand,
long entryPointLine,
std::string const& fileName); std::string const& fileName);
Snapshot CreateIncludeFileSnapshot(Snapshot originSnapshot, Snapshot CreateIncludeFileSnapshot(Snapshot originSnapshot,
std::string const& entryPointCommand,
long entryPointLine,
std::string const& fileName); std::string const& fileName);
Snapshot CreateVariableScopeSnapshot(Snapshot originSnapshot, Snapshot CreateVariableScopeSnapshot(Snapshot originSnapshot);
std::string const& entryPointCommand,
long entryPointLine);
Snapshot CreateInlineListFileSnapshot(Snapshot originSnapshot, Snapshot CreateInlineListFileSnapshot(Snapshot originSnapshot,
const std::string& entryPointCommand,
long entryPointLine,
std::string const& fileName); std::string const& fileName);
Snapshot CreatePolicyScopeSnapshot(Snapshot originSnapshot); Snapshot CreatePolicyScopeSnapshot(Snapshot originSnapshot);
Snapshot Pop(Snapshot originSnapshot); Snapshot Pop(Snapshot originSnapshot);

View File

@ -2784,41 +2784,6 @@ void cmake::IssueMessage(cmake::MessageType t, std::string const& text,
displayMessage(t, msg); displayMessage(t, msg);
} }
//----------------------------------------------------------------------------
void cmake::IssueMessage(cmake::MessageType t, std::string const& text,
cmListFileContext const& lfc,
bool force)
{
if (!force)
{
// override the message type, if needed, for warnings and errors
cmake::MessageType override = this->ConvertMessageType(t);
if (override != t)
{
t = override;
force = true;
}
}
if (!force && !this->IsMessageTypeVisible(t))
{
return;
}
std::ostringstream msg;
if (!this->PrintMessagePreamble(t, msg))
{
return;
}
// Add the immediate context.
msg << (lfc.Line ? " at " : " in ") << lfc;
printMessageText(msg, text);
displayMessage(t, msg);
}
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
std::vector<std::string> cmake::GetDebugConfigs() std::vector<std::string> cmake::GetDebugConfigs()
{ {

View File

@ -358,9 +358,6 @@ class cmake
void IssueMessage(cmake::MessageType t, std::string const& text, void IssueMessage(cmake::MessageType t, std::string const& text,
cmListFileBacktrace const& backtrace = cmListFileBacktrace(), cmListFileBacktrace const& backtrace = cmListFileBacktrace(),
bool force = false); bool force = false);
void IssueMessage(cmake::MessageType t, std::string const& text,
cmListFileContext const& lfc,
bool force = false);
///! run the --build option ///! run the --build option
int Build(const std::string& dir, int Build(const std::string& dir,

View File

@ -1,4 +1,4 @@
^CMake Error at NotClosed.cmake:[0-9]+ \(include\): ^CMake Error in NotClosed.cmake:
cmake_policy PUSH without matching POP cmake_policy PUSH without matching POP
Call Stack \(most recent call first\): Call Stack \(most recent call first\):
CMakeLists.txt:[0-9]+ \(include\)$ CMakeLists.txt:[0-9]+ \(include\)$

View File

@ -1,6 +1,8 @@
^CMake Error at CMakeLists.txt:[0-9]+ \(include\): ^CMake Error in FunctionUnmatched.cmake:
A logical block opening on the line A logical block opening on the line
.*/Tests/RunCMake/Syntax/FunctionUnmatched.cmake:[0-9]+ \(function\) .*/Tests/RunCMake/Syntax/FunctionUnmatched.cmake:[0-9]+ \(function\)
is not closed.$ is not closed.
Call Stack \(most recent call first\):
CMakeLists.txt:[0-9]+ \(include\)$

View File

@ -1,6 +1,8 @@
^CMake Error at CMakeLists.txt:[0-9]+ \(include\): ^CMake Error in MacroUnmatched.cmake:
A logical block opening on the line A logical block opening on the line
.*/Tests/RunCMake/Syntax/MacroUnmatched.cmake:[0-9]+ \(macro\) .*/Tests/RunCMake/Syntax/MacroUnmatched.cmake:[0-9]+ \(macro\)
is not closed.$ is not closed.
Call Stack \(most recent call first\):
CMakeLists.txt:[0-9]+ \(include\)$

View File

@ -25,7 +25,7 @@ Call Stack \(most recent call first\):
OriginDebugIDE.cmake:4 \(include\) OriginDebugIDE.cmake:4 \(include\)
CMakeLists.txt:3 \(include\) CMakeLists.txt:3 \(include\)
+ +
CMake Debug Log: CMake Debug Log in CMakeLists.txt:
Used sources for target OriginDebug: Used sources for target OriginDebug:
* .*CMakeLists.txt * .*CMakeLists.txt

View File

@ -1,4 +1,4 @@
^CMake Error at PolicyPush/PolicyPushConfigVersion.cmake:1 \(find_package\): ^CMake Error in PolicyPush/PolicyPushConfigVersion.cmake:
cmake_policy PUSH without matching POP cmake_policy PUSH without matching POP
Call Stack \(most recent call first\): Call Stack \(most recent call first\):
PolicyPush.cmake:1 \(find_package\) PolicyPush.cmake:1 \(find_package\)

View File

@ -1,4 +1,4 @@
^CMake Warning \(dev\) at EndMismatch.cmake:3 \(include\): ^CMake Warning \(dev\) in EndMismatch.cmake:
A logical block opening on the line A logical block opening on the line
.*/Tests/RunCMake/while/EndMismatch.cmake:1 \(while\) .*/Tests/RunCMake/while/EndMismatch.cmake:1 \(while\)

View File

@ -1,6 +1,8 @@
^CMake Error at CMakeLists.txt:3 \(include\): ^CMake Error in EndMissing.cmake:
A logical block opening on the line A logical block opening on the line
.*/Tests/RunCMake/while/EndMissing.cmake:1 \(while\) .*/Tests/RunCMake/while/EndMissing.cmake:1 \(while\)
is not closed.$ is not closed.
Call Stack \(most recent call first\):
CMakeLists.txt:[0-9]+ \(include\)$