From 7804b28e70acad3b59be57d2a078165bfce57520 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marjam=C3=A4ki?= Date: Sat, 31 Oct 2020 18:57:48 +0100 Subject: [PATCH] AST: Tweaked debug output --- lib/token.cpp | 4 ++-- lib/token.h | 2 +- lib/tokenize.cpp | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/token.cpp b/lib/token.cpp index 3b671b8bd..d3f699fbe 100644 --- a/lib/token.cpp +++ b/lib/token.cpp @@ -1516,7 +1516,7 @@ static void astStringXml(const Token *tok, nonneg int indent, std::ostream &out) } } -void Token::printAst(bool verbose, bool xml, std::ostream &out) const +void Token::printAst(bool verbose, bool xml, const std::vector &fileNames, std::ostream &out) const { if (!xml) out << "\n\n##AST" << std::endl; @@ -1534,7 +1534,7 @@ void Token::printAst(bool verbose, bool xml, std::ostream &out) const astStringXml(tok, 2U, out); out << "" << std::endl; } else if (verbose) - out << "fileIndex " << tok->fileIndex() << " line " << tok->linenr() << std::endl << tok->astStringVerbose() << std::endl; + out << "[" << fileNames[tok->fileIndex()] << ":" << tok->linenr() << "]" << std::endl << tok->astStringVerbose() << std::endl; else out << tok->astString(" ") << std::endl; if (tok->str() == "(") diff --git a/lib/token.h b/lib/token.h index a93e67258..84365930e 100644 --- a/lib/token.h +++ b/lib/token.h @@ -1340,7 +1340,7 @@ public: std::string expressionString() const; - void printAst(bool verbose, bool xml, std::ostream &out) const; + void printAst(bool verbose, bool xml, const std::vector &fileNames, std::ostream &out) const; void printValueFlow(bool xml, std::ostream &out) const; diff --git a/lib/tokenize.cpp b/lib/tokenize.cpp index 803da3fd4..742c86dc1 100644 --- a/lib/tokenize.cpp +++ b/lib/tokenize.cpp @@ -4903,7 +4903,7 @@ void Tokenizer::printDebugOutput(int simplification) const } if (mSettings->verbose) - list.front()->printAst(mSettings->verbose, mSettings->xml, std::cout); + list.front()->printAst(mSettings->verbose, mSettings->xml, list.getFiles(), std::cout); list.front()->printValueFlow(mSettings->xml, std::cout);