Skip to content

Commit 20e462a

Browse files
authored
split "varid0" from more generic "debug" messages (danmar#2997)
1 parent b16944b commit 20e462a

File tree

3 files changed

+10
-10
lines changed

3 files changed

+10
-10
lines changed

lib/checkclass.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1889,7 +1889,7 @@ bool CheckClass::isMemberVar(const Scope *scope, const Token *tok) const
18891889
for (const Variable &var : scope->varlist) {
18901890
if (var.name() == tok->str()) {
18911891
if (tok->varId() == 0)
1892-
mSymbolDatabase->debugMessage(tok, "CheckClass::isMemberVar found used member variable \'" + tok->str() + "\' with varid 0");
1892+
mSymbolDatabase->debugMessage(tok, "varid0", "CheckClass::isMemberVar found used member variable \'" + tok->str() + "\' with varid 0");
18931893

18941894
return !var.isStatic();
18951895
}

lib/symboldatabase.cpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -928,7 +928,7 @@ void SymbolDatabase::createSymbolDatabaseNeedInitialization()
928928
if (retry == 100 && mSettings->debugwarnings) {
929929
for (const Scope& scope : scopeList) {
930930
if (scope.isClassOrStruct() && scope.definedType->needInitialization == Type::NeedInitialization::Unknown)
931-
debugMessage(scope.classDef, "SymbolDatabase::SymbolDatabase couldn't resolve all user defined types.");
931+
debugMessage(scope.classDef, "debug", "SymbolDatabase couldn't resolve all user defined types.");
932932
}
933933
}
934934
}
@@ -1744,7 +1744,7 @@ bool SymbolDatabase::isFunction(const Token *tok, const Scope* outerScope, const
17441744
Token::simpleMatch(tok->linkAt(1), ") {") &&
17451745
(!tok->previous() || Token::Match(tok->previous(), ";|}"))) {
17461746
if (mTokenizer->isC()) {
1747-
debugMessage(tok, "SymbolDatabase::isFunction found C function '" + tok->str() + "' without a return type.");
1747+
debugMessage(tok, "debug", "SymbolDatabase::isFunction found C function '" + tok->str() + "' without a return type.");
17481748
*funcStart = tok;
17491749
*argStart = tok->next();
17501750
*declEnd = tok->linkAt(1)->next();
@@ -2977,13 +2977,13 @@ const std::string& Type::name() const
29772977
return emptyString;
29782978
}
29792979

2980-
void SymbolDatabase::debugMessage(const Token *tok, const std::string &msg) const
2980+
void SymbolDatabase::debugMessage(const Token *tok, const std::string &type, const std::string &msg) const
29812981
{
29822982
if (tok && mSettings->debugwarnings) {
29832983
const std::list<const Token*> locationList(1, tok);
29842984
const ErrorMessage errmsg(locationList, &mTokenizer->list,
29852985
Severity::debug,
2986-
"debug",
2986+
type,
29872987
msg,
29882988
false);
29892989
if (mErrorLogger)
@@ -3712,7 +3712,7 @@ void Function::addArguments(const SymbolDatabase *symbolDatabase, const Scope *s
37123712
endTok = nameTok->previous();
37133713

37143714
if (hasBody())
3715-
symbolDatabase->debugMessage(nameTok, "Function::addArguments found argument \'" + nameTok->str() + "\' with varid 0.");
3715+
symbolDatabase->debugMessage(nameTok, "varid0", "Function::addArguments found argument \'" + nameTok->str() + "\' with varid 0.");
37163716
} else
37173717
endTok = typeTok;
37183718
} else
@@ -4140,7 +4140,7 @@ const Token *Scope::checkVariable(const Token *tok, AccessControl varaccess, con
41404140

41414141
if (vartok->varId() == 0) {
41424142
if (!vartok->isBoolean())
4143-
check->debugMessage(vartok, "Scope::checkVariable found variable \'" + vartok->str() + "\' with varid 0.");
4143+
check->debugMessage(vartok, "varid0", "Scope::checkVariable found variable \'" + vartok->str() + "\' with varid 0.");
41444144
return tok;
41454145
}
41464146

@@ -4933,7 +4933,7 @@ const Function* SymbolDatabase::findFunction(const Token *tok) const
49334933
tok1 = tok1->linkAt(-2)->tokAt(-1);
49344934
else {
49354935
if (mSettings->debugwarnings)
4936-
debugMessage(tok1->tokAt(-2), "SymbolDatabase::findFunction found '>' without link.");
4936+
debugMessage(tok1->tokAt(-2), "debug", "SymbolDatabase::findFunction found '>' without link.");
49374937
return nullptr;
49384938
}
49394939
} else
@@ -6344,7 +6344,7 @@ void SymbolDatabase::setValueTypeInTokenList(bool reportDebugWarnings, Token *to
63446344
if (reportDebugWarnings && mSettings->debugwarnings) {
63456345
for (Token *tok = tokens; tok; tok = tok->next()) {
63466346
if (tok->str() == "auto" && !tok->valueType())
6347-
debugMessage(tok, "auto token with no type.");
6347+
debugMessage(tok, "debug", "auto token with no type.");
63486348
}
63496349
}
63506350

lib/symboldatabase.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1319,7 +1319,7 @@ class CPPCHECKLIB SymbolDatabase {
13191319
/**
13201320
* @brief output a debug message
13211321
*/
1322-
void debugMessage(const Token *tok, const std::string &msg) const;
1322+
void debugMessage(const Token *tok, const std::string &type, const std::string &msg) const;
13231323

13241324
void printOut(const char * title = nullptr) const;
13251325
void printVariable(const Variable *var, const char *indent) const;

0 commit comments

Comments
 (0)