show unknown variable types when debug-messages flag is set

This commit is contained in:
Robert Reif 2011-09-27 21:45:06 -04:00
parent 540207533b
commit 989235b509
1 changed files with 77 additions and 3 deletions

View File

@ -4796,16 +4796,90 @@ bool Tokenizer::simplifyTokenList()
removeRedundantAssignment(); removeRedundantAssignment();
simplifyComma(); simplifyComma();
removeRedundantSemicolons();
if (!validate())
return false;
_tokens->assignProgressValues();
if (_settings->debug) if (_settings->debug)
{ {
_tokens->printOut(0, _files); _tokens->printOut(0, _files);
} }
_tokens->assignProgressValues(); if (_settings->debugwarnings)
{
getSymbolDatabase();
removeRedundantSemicolons(); std::set<std::string> unknowns;
return validate(); for (size_t i = 1; i <= _varId; i++)
{
const Variable *var = _symbolDatabase->getVariableFromVarId(i);
// is unknown record type?
if (var && var->isClass() && !var->type())
{
std::string name;
// single token type?
if (var->typeStartToken() == var->typeEndToken())
name = var->typeStartToken()->str();
// complcated type
else
{
const Token *tok = var->typeStartToken();
int level = 0;
while (tok)
{
// skip pointer and reference part of type
if (level == 0 && (tok->str() == "*" || tok->str() == "&"))
break;
name += tok->str();
if (Token::Match(tok, "struct|union"))
name += " ";
// pointers and referennces are OK in template
else if (tok->str() == "<")
level++;
else if (tok->str() == ">")
level--;
if (tok == var->typeEndToken())
break;
tok = tok->next();
}
}
unknowns.insert(name);
}
}
if (!unknowns.empty())
{
std::ostringstream ss;
ss << unknowns.size() << " unknown types:" << std::endl;
std::set<std::string>::const_iterator it;
size_t count = 1;
for (it = unknowns.begin(); it != unknowns.end(); ++it, ++count)
ss << count << ": " << *it << std::endl;
if (_errorLogger)
_errorLogger->reportOut(ss.str());
}
}
return true;
} }
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------