diff options
author | Brad King <brad.king@kitware.com> | 2016-04-14 15:24:08 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2016-04-18 13:21:19 (GMT) |
commit | 7c36d2067b00996fcead56310f4fc4fa58434247 (patch) | |
tree | 6f0b8771c11e3cb6b20e91680b0b17114c52bb06 /Source/cmState.cxx | |
parent | 1f6bd8a93f602f9d4dde1c3ea697211897f25827 (diff) | |
download | CMake-7c36d2067b00996fcead56310f4fc4fa58434247.zip CMake-7c36d2067b00996fcead56310f4fc4fa58434247.tar.gz CMake-7c36d2067b00996fcead56310f4fc4fa58434247.tar.bz2 |
cmListFileBacktrace: Refactor storage to provide efficient value semantics
Since commit v3.4.0-rc1~321^2~2 (Genex: Store a backtrace, not a pointer
to one, 2015-07-08) we treat cmListFileBacktrace instances as
lightweight values. This was true at the time only because the
backtrace information was kept in the cmState snapshot hierarchy.
However, that forced us to accumulate a lot of otherwise short-lived
snapshots just to have the backtrace fields available for reference by
cmListFileBacktrace instances. Recent refactoring made backtrace
instances independent of the snapshot hierarchy to avoid accumulating
short-lived snapshots. This came at the cost of making backtrace values
heavy again, leading to lots of string coying and slower execution.
Fix this by refactoring cmListFileBacktrace to provide value semantics
with efficient shared storage underneath. Teach cmMakefile to maintain
its call stack using an instance of cmListFileBacktrace. This approach
allows the current backtrace to be efficiently saved whenever it is
needed.
Also teach cmListFileBacktrace the notion of a file-level scope. This
is useful for messages about the whole file (e.g. during parsing) that
are not specific to any line within it. Push the CMakeLists.txt scope
for each directory and never pop it. This ensures that we always have
some context information and simplifies cmMakefile::IssueMessage.
Push/pop a file-level scope as each included file is processed. This
supersedes cmParseFileScope and improves diagnostic message context
information in a few places. Fix the corresponding test cases to expect
the improved output.
Diffstat (limited to 'Source/cmState.cxx')
-rw-r--r-- | Source/cmState.cxx | 28 |
1 files changed, 2 insertions, 26 deletions
diff --git a/Source/cmState.cxx b/Source/cmState.cxx index bec5682..f4ca113 100644 --- a/Source/cmState.cxx +++ b/Source/cmState.cxx @@ -845,14 +845,10 @@ cmState::Snapshot cmState::CreateBaseSnapshot() } cmState::Snapshot -cmState::CreateBuildsystemDirectorySnapshot(Snapshot originSnapshot, - std::string const& entryPointCommand, - long entryPointLine) +cmState::CreateBuildsystemDirectorySnapshot(Snapshot originSnapshot) { assert(originSnapshot.IsValid()); PositionType pos = this->SnapshotData.Push(originSnapshot.Position); - pos->EntryPointLine = entryPointLine; - pos->EntryPointCommand = entryPointCommand; pos->DirectoryParent = originSnapshot.Position; pos->ScopeParent = originSnapshot.Position; pos->SnapshotType = BuildsystemDirectoryType; @@ -886,15 +882,11 @@ cmState::CreateBuildsystemDirectorySnapshot(Snapshot originSnapshot, cmState::Snapshot cmState::CreateFunctionCallSnapshot(cmState::Snapshot originSnapshot, - std::string const& entryPointCommand, - long entryPointLine, std::string const& fileName) { PositionType pos = this->SnapshotData.Push(originSnapshot.Position, *originSnapshot.Position); pos->ScopeParent = originSnapshot.Position; - pos->EntryPointLine = entryPointLine; - pos->EntryPointCommand = entryPointCommand; pos->SnapshotType = FunctionCallType; pos->Keep = false; pos->ExecutionListFile = this->ExecutionListFiles.Push( @@ -912,14 +904,10 @@ cmState::CreateFunctionCallSnapshot(cmState::Snapshot originSnapshot, cmState::Snapshot cmState::CreateMacroCallSnapshot(cmState::Snapshot originSnapshot, - std::string const& entryPointCommand, - long entryPointLine, std::string const& fileName) { PositionType pos = this->SnapshotData.Push(originSnapshot.Position, *originSnapshot.Position); - pos->EntryPointLine = entryPointLine; - pos->EntryPointCommand = entryPointCommand; pos->SnapshotType = MacroCallType; pos->Keep = false; pos->ExecutionListFile = this->ExecutionListFiles.Push( @@ -932,14 +920,10 @@ cmState::CreateMacroCallSnapshot(cmState::Snapshot originSnapshot, cmState::Snapshot cmState::CreateIncludeFileSnapshot(cmState::Snapshot originSnapshot, - const std::string& entryPointCommand, - long entryPointLine, const std::string& fileName) { PositionType pos = this->SnapshotData.Push(originSnapshot.Position, *originSnapshot.Position); - pos->EntryPointLine = entryPointLine; - pos->EntryPointCommand = entryPointCommand; pos->SnapshotType = IncludeFileType; pos->Keep = true; pos->ExecutionListFile = this->ExecutionListFiles.Push( @@ -951,15 +935,11 @@ cmState::CreateIncludeFileSnapshot(cmState::Snapshot originSnapshot, } cmState::Snapshot -cmState::CreateVariableScopeSnapshot(cmState::Snapshot originSnapshot, - std::string const& entryPointCommand, - long entryPointLine) +cmState::CreateVariableScopeSnapshot(cmState::Snapshot originSnapshot) { PositionType pos = this->SnapshotData.Push(originSnapshot.Position, *originSnapshot.Position); pos->ScopeParent = originSnapshot.Position; - pos->EntryPointLine = entryPointLine; - pos->EntryPointCommand = entryPointCommand; pos->SnapshotType = VariableScopeType; pos->Keep = false; pos->PolicyScope = originSnapshot.Position->Policies; @@ -975,14 +955,10 @@ cmState::CreateVariableScopeSnapshot(cmState::Snapshot originSnapshot, cmState::Snapshot cmState::CreateInlineListFileSnapshot(cmState::Snapshot originSnapshot, - const std::string& entryPointCommand, - long entryPointLine, const std::string& fileName) { PositionType pos = this->SnapshotData.Push(originSnapshot.Position, *originSnapshot.Position); - pos->EntryPointLine = entryPointLine; - pos->EntryPointCommand = entryPointCommand; pos->SnapshotType = InlineListFileType; pos->Keep = true; pos->ExecutionListFile = this->ExecutionListFiles.Push( |