dump: write container information

This commit is contained in:
Daniel Marjamäki 2023-04-12 21:57:37 +02:00
parent e59e34c0eb
commit afb9e43f2a
2 changed files with 16 additions and 0 deletions

View File

@ -7361,6 +7361,7 @@ std::string ValueType::dump() const
break; break;
case CONTAINER: case CONTAINER:
ret << "valueType-type=\"container\""; ret << "valueType-type=\"container\"";
ret << " valueType-containerId=\"" << container << "\"";
break; break;
case ITERATOR: case ITERATOR:
ret << "valueType-type=\"iterator\""; ret << "valueType-type=\"iterator\"";

View File

@ -5725,6 +5725,8 @@ void Tokenizer::dump(std::ostream &out) const
// The idea is not that this will be readable for humans. It's a // The idea is not that this will be readable for humans. It's a
// data dump that 3rd party tools could load and get useful info from. // data dump that 3rd party tools could load and get useful info from.
std::set<const Library::Container*> containers;
// tokens.. // tokens..
out << " <tokenlist>" << std::endl; out << " <tokenlist>" << std::endl;
for (const Token *tok = list.front(); tok; tok = tok->next()) { for (const Token *tok = list.front(); tok; tok = tok->next()) {
@ -5804,6 +5806,7 @@ void Tokenizer::dump(std::ostream &out) const
const std::string vt = tok->valueType()->dump(); const std::string vt = tok->valueType()->dump();
if (!vt.empty()) if (!vt.empty())
out << ' ' << vt; out << ' ' << vt;
containers.insert(tok->valueType()->container);
} }
if (!tok->varId() && tok->scope()->isExecutable() && Token::Match(tok, "%name% (")) { if (!tok->varId() && tok->scope()->isExecutable() && Token::Match(tok, "%name% (")) {
if (mSettings->library.isnoreturn(tok)) if (mSettings->library.isnoreturn(tok))
@ -5815,6 +5818,18 @@ void Tokenizer::dump(std::ostream &out) const
out << " </tokenlist>" << std::endl; out << " </tokenlist>" << std::endl;
mSymbolDatabase->printXml(out); mSymbolDatabase->printXml(out);
containers.erase(nullptr);
if (!containers.empty()) {
out << " <containers>\n";
for (const Library::Container* c: containers) {
out << " <container id=\"" << c << "\" array-like-index-op=\""
<< (c->arrayLike_indexOp ? "true" : "false") << "\" "
<< "std-string-like=\"" << (c->stdStringLike ? "true" : "false") << "\"/>\n";
}
out << " </containers>\n";
}
if (list.front()) if (list.front())
list.front()->printValueFlow(true, out); list.front()->printValueFlow(true, out);