Improve --debug-warnings output for 'auto' tokens without type. Do not report that prematurely before the type is set properly.
This commit is contained in:
parent
20278d9c92
commit
ebcca4edd1
|
@ -59,7 +59,7 @@ SymbolDatabase::SymbolDatabase(const Tokenizer *tokenizer, const Settings *setti
|
||||||
createSymbolDatabaseVariableSymbolTable();
|
createSymbolDatabaseVariableSymbolTable();
|
||||||
createSymbolDatabaseSetScopePointers();
|
createSymbolDatabaseSetScopePointers();
|
||||||
createSymbolDatabaseSetVariablePointers();
|
createSymbolDatabaseSetVariablePointers();
|
||||||
setValueTypeInTokenList();
|
setValueTypeInTokenList(false);
|
||||||
createSymbolDatabaseSetFunctionPointers(true);
|
createSymbolDatabaseSetFunctionPointers(true);
|
||||||
createSymbolDatabaseSetTypePointers();
|
createSymbolDatabaseSetTypePointers();
|
||||||
createSymbolDatabaseEnums();
|
createSymbolDatabaseEnums();
|
||||||
|
@ -5395,7 +5395,7 @@ static const Function *getOperatorFunction(const Token * const tok)
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SymbolDatabase::setValueTypeInTokenList()
|
void SymbolDatabase::setValueTypeInTokenList(bool reportDebugWarnings)
|
||||||
{
|
{
|
||||||
Token * tokens = const_cast<Tokenizer *>(mTokenizer)->list.front();
|
Token * tokens = const_cast<Tokenizer *>(mTokenizer)->list.front();
|
||||||
|
|
||||||
|
@ -5605,7 +5605,7 @@ void SymbolDatabase::setValueTypeInTokenList()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mSettings->debugwarnings) {
|
if (reportDebugWarnings && mSettings->debugwarnings) {
|
||||||
for (Token *tok = tokens; tok; tok = tok->next()) {
|
for (Token *tok = tokens; tok; tok = tok->next()) {
|
||||||
if (tok->str() == "auto" && !tok->valueType())
|
if (tok->str() == "auto" && !tok->valueType())
|
||||||
debugMessage(tok, "auto token with no type.");
|
debugMessage(tok, "auto token with no type.");
|
||||||
|
|
|
@ -1238,7 +1238,7 @@ public:
|
||||||
void validateVariables() const;
|
void validateVariables() const;
|
||||||
|
|
||||||
/** Set valuetype in provided tokenlist */
|
/** Set valuetype in provided tokenlist */
|
||||||
void setValueTypeInTokenList();
|
void setValueTypeInTokenList(bool reportDebugWarnings);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Calculates sizeof value for given type.
|
* Calculates sizeof value for given type.
|
||||||
|
|
|
@ -2315,9 +2315,9 @@ bool Tokenizer::simplifyTokens1(const std::string &configuration)
|
||||||
|
|
||||||
if (mTimerResults) {
|
if (mTimerResults) {
|
||||||
Timer t("Tokenizer::simplifyTokens1::setValueType", mSettings->showtime, mTimerResults);
|
Timer t("Tokenizer::simplifyTokens1::setValueType", mSettings->showtime, mTimerResults);
|
||||||
mSymbolDatabase->setValueTypeInTokenList();
|
mSymbolDatabase->setValueTypeInTokenList(true);
|
||||||
} else {
|
} else {
|
||||||
mSymbolDatabase->setValueTypeInTokenList();
|
mSymbolDatabase->setValueTypeInTokenList(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mTimerResults) {
|
if (mTimerResults) {
|
||||||
|
@ -4762,7 +4762,7 @@ bool Tokenizer::simplifyTokenList2()
|
||||||
|
|
||||||
// Create symbol database and then remove const keywords
|
// Create symbol database and then remove const keywords
|
||||||
createSymbolDatabase();
|
createSymbolDatabase();
|
||||||
mSymbolDatabase->setValueTypeInTokenList();
|
mSymbolDatabase->setValueTypeInTokenList(true);
|
||||||
|
|
||||||
ValueFlow::setValues(&list, mSymbolDatabase, mErrorLogger, mSettings);
|
ValueFlow::setValues(&list, mSymbolDatabase, mErrorLogger, mSettings);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue