From 912319375823ddd2b8ccf4f5e344cafeca73eb29 Mon Sep 17 00:00:00 2001 From: Brad King Date: Mon, 28 Mar 2022 17:35:50 -0400 Subject: cmListFileBacktrace: Clarify call sites that only push a file path This removes the last part of the `cmListFileBacktrace` interface that needs to know the type of data in its stack. --- Source/cmListFileCache.cxx | 11 ----------- Source/cmListFileCache.h | 14 +++++++++++--- Source/cmMakefile.cxx | 9 ++++++--- 3 files changed, 17 insertions(+), 17 deletions(-) diff --git a/Source/cmListFileCache.cxx b/Source/cmListFileCache.cxx index b90af08..941d283 100644 --- a/Source/cmListFileCache.cxx +++ b/Source/cmListFileCache.cxx @@ -470,17 +470,6 @@ cmListFileBacktrace::cmListFileBacktrace(std::shared_ptr top) { } -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 this->Push(lfc); -} - cmListFileBacktrace cmListFileBacktrace::Push( cmListFileContext const& lfc) const { diff --git a/Source/cmListFileCache.h b/Source/cmListFileCache.h index c3da81b..7c19f24 100644 --- a/Source/cmListFileCache.h +++ b/Source/cmListFileCache.h @@ -128,6 +128,17 @@ public: { } + static cmListFileContext FromListFilePath(std::string const& filePath) + { + // 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 = filePath; + return lfc; + } + static cmListFileContext FromListFileFunction( cmListFileFunction const& lff, std::string const& fileName, cm::optional deferId = {}) @@ -154,9 +165,6 @@ public: // Default-constructed backtrace is empty. cmListFileBacktrace() = default; - // Get a backtrace with the given file scope added to the top. - cmListFileBacktrace Push(std::string const& file) const; - // Get a backtrace with the given call context added to the top. cmListFileBacktrace Push(cmListFileContext const& lfc) const; diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index a781d59..91d7ac5 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -491,7 +491,8 @@ cmMakefile::IncludeScope::IncludeScope(cmMakefile* mf, , CheckCMP0011(false) , ReportError(true) { - this->Makefile->Backtrace = this->Makefile->Backtrace.Push(filenametoread); + this->Makefile->Backtrace = this->Makefile->Backtrace.Push( + cmListFileContext::FromListFilePath(filenametoread)); this->Makefile->PushFunctionBlockerBarrier(); @@ -624,7 +625,8 @@ public: : Makefile(mf) , ReportError(true) { - this->Makefile->Backtrace = this->Makefile->Backtrace.Push(filenametoread); + this->Makefile->Backtrace = this->Makefile->Backtrace.Push( + cmListFileContext::FromListFilePath(filenametoread)); this->Makefile->StateSnapshot = this->Makefile->GetState()->CreateInlineListFileSnapshot( @@ -1587,7 +1589,8 @@ void cmMakefile::Configure() // 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); + this->Backtrace = + this->Backtrace.Push(cmListFileContext::FromListFilePath(currentStart)); BuildsystemFileScope scope(this); -- cgit v0.12