MCPcopy Create free account
hub / github.com/cppcheck-opensource/cppcheck / printAst

Method printAst

lib/token.cpp:1666–1689  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1664}
1665
1666void Token::printAst(bool xml, const std::vector<std::string> &fileNames, std::ostream &out) const
1667{
1668 if (!xml)
1669 out << "\n\n##AST" << std::endl;
1670
1671 std::set<const Token *> printed;
1672 for (const Token *tok = this; tok; tok = tok->next()) {
1673 if (!tok->mImpl->mAstParent && tok->mImpl->mAstOperand1) {
1674 if (printed.find(tok) != printed.end())
1675 continue;
1676 printed.insert(tok);
1677
1678 if (xml) {
1679 out << "<ast scope=\"" << tok->scope() << "\" fileIndex=\"" << tok->fileIndex() << "\" linenr=\"" << tok->linenr()
1680 << "\" column=\"" << tok->column() << "\">" << std::endl;
1681 astStringXml(tok, 2U, out);
1682 out << "</ast>" << std::endl;
1683 } else
1684 out << "[" << fileNames[tok->fileIndex()] << ":" << tok->linenr() << "]" << std::endl << tok->astStringVerbose() << std::endl;
1685 if (tok->str() == "(")
1686 tok = tok->link();
1687 }
1688 }
1689}
1690
1691static void indent(std::string &str, const nonneg int indent1, const nonneg int indent2)
1692{

Callers 1

printDebugOutputMethod · 0.80

Calls 9

astStringXmlFunction · 0.85
nextMethod · 0.80
scopeMethod · 0.80
fileIndexMethod · 0.80
columnMethod · 0.80
astStringVerboseMethod · 0.80
findMethod · 0.45
endMethod · 0.45
strMethod · 0.45

Tested by

no test coverage detected