summaryrefslogtreecommitdiffstats
path: root/Source/cmListFileCache.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'Source/cmListFileCache.cxx')
-rw-r--r--Source/cmListFileCache.cxx79
1 files changed, 12 insertions, 67 deletions
diff --git a/Source/cmListFileCache.cxx b/Source/cmListFileCache.cxx
index 3da266d..91157cb 100644
--- a/Source/cmListFileCache.cxx
+++ b/Source/cmListFileCache.cxx
@@ -1,8 +1,8 @@
/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
file Copyright.txt or https://cmake.org/licensing for details. */
+#define cmListFileCache_cxx
#include "cmListFileCache.h"
-#include <cassert>
#include <memory>
#include <sstream>
#include <utility>
@@ -36,10 +36,11 @@ struct cmListFileParser
cmListFile* ListFile;
cmListFileBacktrace Backtrace;
cmMessenger* Messenger;
- const char* FileName;
+ const char* FileName = nullptr;
cmListFileLexer* Lexer;
std::string FunctionName;
long FunctionLine;
+ long FunctionLineEnd;
std::vector<cmListFileArgument> FunctionArguments;
enum
{
@@ -54,7 +55,6 @@ cmListFileParser::cmListFileParser(cmListFile* lf, cmListFileBacktrace lfbt,
: ListFile(lf)
, Backtrace(std::move(lfbt))
, Messenger(messenger)
- , FileName(nullptr)
, Lexer(cmListFileLexer_New())
{
}
@@ -78,7 +78,7 @@ void cmListFileParser::IssueError(const std::string& text) const
cmListFileBacktrace lfbt = this->Backtrace;
lfbt = lfbt.Push(lfc);
this->Messenger->IssueMessage(MessageType::FATAL_ERROR, text, lfbt);
- cmSystemTools::SetFatalErrorOccured();
+ cmSystemTools::SetFatalErrorOccurred();
}
bool cmListFileParser::ParseFile(const char* filename)
@@ -146,7 +146,7 @@ bool cmListFileParser::Parse()
if (this->ParseFunction(token->text, token->line)) {
this->ListFile->Functions.emplace_back(
std::move(this->FunctionName), this->FunctionLine,
- std::move(this->FunctionArguments));
+ this->FunctionLineEnd, std::move(this->FunctionArguments));
} else {
return false;
}
@@ -174,7 +174,7 @@ bool cmListFileParser::Parse()
MessageType::FATAL_ERROR,
"Flow control statements are not properly nested.",
this->Backtrace.Push(*badNesting));
- cmSystemTools::SetFatalErrorOccured();
+ cmSystemTools::SetFatalErrorOccurred();
return false;
}
@@ -259,6 +259,7 @@ bool cmListFileParser::ParseFunction(const char* name, long line)
}
} else if (token->type == cmListFileLexer_Token_ParenRight) {
if (parenDepth == 0) {
+ this->FunctionLineEnd = token->line;
return true;
}
parenDepth--;
@@ -443,64 +444,8 @@ cm::optional<cmListFileContext> cmListFileParser::CheckNesting() const
return cm::nullopt;
}
-// We hold a call/file context.
-struct cmListFileBacktrace::Entry
-{
- Entry(std::shared_ptr<Entry const> parent, cmListFileContext lfc)
- : Context(std::move(lfc))
- , Parent(std::move(parent))
- {
- }
-
- cmListFileContext Context;
- std::shared_ptr<Entry const> Parent;
-};
-
-/* NOLINTNEXTLINE(performance-unnecessary-value-param) */
-cmListFileBacktrace::cmListFileBacktrace(std::shared_ptr<Entry const> parent,
- cmListFileContext const& lfc)
- : TopEntry(std::make_shared<Entry const>(std::move(parent), lfc))
-{
-}
-
-cmListFileBacktrace::cmListFileBacktrace(std::shared_ptr<Entry const> top)
- : TopEntry(std::move(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
-{
- return cmListFileBacktrace(this->TopEntry, lfc);
-}
-
-cmListFileBacktrace cmListFileBacktrace::Pop() const
-{
- assert(this->TopEntry);
- return cmListFileBacktrace(this->TopEntry->Parent);
-}
-
-cmListFileContext const& cmListFileBacktrace::Top() const
-{
- assert(this->TopEntry);
- return this->TopEntry->Context;
-}
-
-bool cmListFileBacktrace::Empty() const
-{
- return !this->TopEntry;
-}
+#include "cmConstStack.tcc"
+template class cmConstStack<cmListFileContext, cmListFileBacktrace>;
std::ostream& operator<<(std::ostream& os, cmListFileContext const& lfc)
{
@@ -539,11 +484,11 @@ std::ostream& operator<<(std::ostream& os, BT<std::string> const& s)
return os << s.Value;
}
-std::vector<BT<std::string>> ExpandListWithBacktrace(
- std::string const& list, cmListFileBacktrace const& bt)
+std::vector<BT<std::string>> cmExpandListWithBacktrace(
+ std::string const& list, cmListFileBacktrace const& bt, bool emptyArgs)
{
std::vector<BT<std::string>> result;
- std::vector<std::string> tmp = cmExpandedList(list);
+ std::vector<std::string> tmp = cmExpandedList(list, emptyArgs);
result.reserve(tmp.size());
for (std::string& i : tmp) {
result.emplace_back(std::move(i), bt);