Skip to content

Commit d964825

Browse files
committed
ValueType: Add debug output that is shown when --verbose is used
1 parent 1c5eaf8 commit d964825

3 files changed

Lines changed: 27 additions & 1 deletion

File tree

lib/symboldatabase.cpp

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3935,6 +3935,28 @@ void SymbolDatabase::setValueTypeInTokenList(Token *tokens, bool cpp, char defau
39353935
}
39363936
}
39373937

3938+
void SymbolDatabase::debugValueType() const
3939+
{
3940+
unsigned int linenr = 0U;
3941+
std::cout << std::endl << "### ValueType ###" << std::endl;
3942+
for (const Token *tok = _tokenizer->tokens(); tok; tok = tok->next()) {
3943+
if (tok->linenr() != linenr)
3944+
std::cout << std::endl << tok->linenr() << ": ";
3945+
linenr = tok->linenr();
3946+
std::cout << tok->str();
3947+
if (tok->valueType()) {
3948+
std::string t = tok->valueType()->str();
3949+
std::string::size_type pos;
3950+
while ((pos = t.find(" ")) != std::string::npos)
3951+
t[pos] = '_';
3952+
std::cout << ':' << t;
3953+
}
3954+
std::cout << ' ';
3955+
}
3956+
std::cout << std::endl << std::endl;
3957+
}
3958+
3959+
39383960
std::string ValueType::str() const
39393961
{
39403962
std::string ret;

lib/symboldatabase.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1035,6 +1035,8 @@ class CPPCHECKLIB SymbolDatabase {
10351035
/** Set valuetype in provided tokenlist */
10361036
static void setValueTypeInTokenList(Token *tokens, bool cpp, char defaultSignedness);
10371037

1038+
void debugValueType() const;
1039+
10381040
private:
10391041
friend class Scope;
10401042
friend class Function;

lib/tokenize.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3828,8 +3828,10 @@ void Tokenizer::printDebugOutput(unsigned int simplification) const
38283828
if (_symbolDatabase) {
38293829
if (_settings->xml)
38303830
_symbolDatabase->printXml(std::cout);
3831-
else if (_settings->verbose)
3831+
else if (_settings->verbose) {
38323832
_symbolDatabase->printOut("Symbol database");
3833+
_symbolDatabase->debugValueType();
3834+
}
38333835
}
38343836

38353837
if (_settings->verbose)

0 commit comments

Comments
 (0)