added debug output for the value flow

This commit is contained in:
Daniel Marjamäki 2014-01-18 09:58:32 +01:00
parent a7146916b1
commit 498cdb8610
3 changed files with 26 additions and 0 deletions

View File

@ -1213,8 +1213,30 @@ void Token::printAst() const
title = true;
std::cout << tok->astTop()->astString(" ") << std::endl;
print = false;
if (tok->str() == "(")
tok = tok->link();
}
if (Token::Match(tok, "[;{}]"))
print = true;
}
}
void Token::printValueFlow() const
{
int line = -1;
std::cout << "\n\n##Value flow" << std::endl;
for (const Token *tok = this; tok; tok = tok->next()) {
if (tok->values.empty())
continue;
if (line != tok->linenr())
std::cout << "Line " << tok->linenr() << std::endl;
line = tok->linenr();
std::cout << " " << tok->str() << ":{";
for (std::list<ValueFlow::Value>::const_iterator it=tok->values.begin(); it!=tok->values.end(); ++it) {
if (it != tok->values.begin())
std::cout << ",";
std::cout << it->intvalue;
}
std::cout << "}" << std::endl;
}
}

View File

@ -702,6 +702,8 @@ public:
std::string expressionString() const;
void printAst() const;
void printValueFlow() const;
};
/// @}

View File

@ -3651,6 +3651,8 @@ bool Tokenizer::simplifyTokenList2()
_symbolDatabase->printOut("Symbol database");
list.front()->printAst();
list.front()->printValueFlow();
}
if (_settings->debugwarnings) {