ValueType: Add debug output that is shown when --verbose is used

This commit is contained in:
Daniel Marjamäki 2016-02-15 16:18:24 +01:00
parent 1c5eaf8cf9
commit d964825c9f
3 changed files with 27 additions and 1 deletions

View File

@ -3935,6 +3935,28 @@ void SymbolDatabase::setValueTypeInTokenList(Token *tokens, bool cpp, char defau
}
}
void SymbolDatabase::debugValueType() const
{
unsigned int linenr = 0U;
std::cout << std::endl << "### ValueType ###" << std::endl;
for (const Token *tok = _tokenizer->tokens(); tok; tok = tok->next()) {
if (tok->linenr() != linenr)
std::cout << std::endl << tok->linenr() << ": ";
linenr = tok->linenr();
std::cout << tok->str();
if (tok->valueType()) {
std::string t = tok->valueType()->str();
std::string::size_type pos;
while ((pos = t.find(" ")) != std::string::npos)
t[pos] = '_';
std::cout << ':' << t;
}
std::cout << ' ';
}
std::cout << std::endl << std::endl;
}
std::string ValueType::str() const
{
std::string ret;

View File

@ -1035,6 +1035,8 @@ public:
/** Set valuetype in provided tokenlist */
static void setValueTypeInTokenList(Token *tokens, bool cpp, char defaultSignedness);
void debugValueType() const;
private:
friend class Scope;
friend class Function;

View File

@ -3828,8 +3828,10 @@ void Tokenizer::printDebugOutput(unsigned int simplification) const
if (_symbolDatabase) {
if (_settings->xml)
_symbolDatabase->printXml(std::cout);
else if (_settings->verbose)
else if (_settings->verbose) {
_symbolDatabase->printOut("Symbol database");
_symbolDatabase->debugValueType();
}
}
if (_settings->verbose)