Fixed #4722 (Debugging enhancement: Tokenizer::simplifyTokenList() shall continue)

This commit is contained in:
Alexander Mai 2014-03-14 17:48:20 +01:00 committed by Daniel Marjamäki
parent b8a1ca29d1
commit ff5fc82704
1 changed files with 41 additions and 38 deletions

View File

@ -3631,62 +3631,65 @@ bool Tokenizer::simplifyTokenList2()
while (simplifyMathFunctions()) {}; while (simplifyMathFunctions()) {};
if (!validate()) const bool bValidate = validate();
return false; if (bValidate || // either anything is fine here...
(_settings->debug && _settings->_verbose) // or it could be dangerous to proceed, so we demand this combination of flags
) {
list.front()->assignProgressValues();
list.front()->assignProgressValues();
// Create symbol database and then remove const keywords // Create symbol database and then remove const keywords
createSymbolDatabase(); createSymbolDatabase();
for (Token *tok = list.front(); tok; tok = tok->next()) { for (Token *tok = list.front(); tok; tok = tok->next()) {
if (Token::simpleMatch(tok, "* const")) if (Token::simpleMatch(tok, "* const"))
tok->deleteNext(); tok->deleteNext();
} }
list.createAst(); list.createAst();
ValueFlow::setValues(&list, _errorLogger, _settings); ValueFlow::setValues(&list, _errorLogger, _settings);
if (_settings->terminated()) if (_settings->terminated())
return false; return false;
if (_settings->debug) { if (_settings->debug) {
list.front()->printOut(0, list.getFiles()); list.front()->printOut(0, list.getFiles());
if (_settings->_verbose) if (_settings->_verbose)
_symbolDatabase->printOut("Symbol database"); _symbolDatabase->printOut("Symbol database");
list.front()->printAst(_settings->_verbose); list.front()->printAst(_settings->_verbose);
list.front()->printValueFlow(); list.front()->printValueFlow();
} }
if (_settings->debugwarnings) { if (_settings->debugwarnings) {
printUnknownTypes(); printUnknownTypes();
// #5054 - the typeStartToken() should come before typeEndToken() // #5054 - the typeStartToken() should come before typeEndToken()
for (const Token *tok = tokens(); tok; tok = tok->next()) { for (const Token *tok = tokens(); tok; tok = tok->next()) {
if (tok->varId() == 0U) if (tok->varId() == 0U)
continue; continue;
const Variable *var = tok->variable(); const Variable *var = tok->variable();
if (!var) if (!var)
continue; continue;
const Token * typetok = var->typeStartToken(); const Token * typetok = var->typeStartToken();
while (typetok && typetok != var->typeEndToken()) while (typetok && typetok != var->typeEndToken())
typetok = typetok->next(); typetok = typetok->next();
if (typetok != var->typeEndToken()) { if (typetok != var->typeEndToken()) {
reportError(tok, reportError(tok,
Severity::debug, Severity::debug,
"debug", "debug",
"Variable::typeStartToken() is not located before Variable::typeEndToken(). The location of the typeStartToken() is '" + var->typeStartToken()->str() + "' at line " + MathLib::toString(var->typeStartToken()->linenr())); "Variable::typeStartToken() is not located before Variable::typeEndToken(). The location of the typeStartToken() is '" + var->typeStartToken()->str() + "' at line " + MathLib::toString(var->typeStartToken()->linenr()));
}
} }
} }
} }
return true; return bValidate;
} }
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------