Renamed ID uninitialized member variables in constructors to "uninitMemberVar" to avoid ambiguity (#2715)
Refactorizations: - Replaced another single-token-pattern - Replaced a "continue" with a "break" statement, because its safe to assume that only one variable with a specific ID can exist in a scope
This commit is contained in:
parent
6f164de609
commit
533db6421f
|
@ -297,7 +297,7 @@ void CheckClass::initializeVarList(const Function &func, std::list<std::string>
|
||||||
if (var->varId() == ftok->next()->varId()) {
|
if (var->varId() == ftok->next()->varId()) {
|
||||||
/** @todo false negative: we assume function changes variable state */
|
/** @todo false negative: we assume function changes variable state */
|
||||||
assignVar(ftok->next()->str(), scope, usage);
|
assignVar(ftok->next()->str(), scope, usage);
|
||||||
continue;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -338,9 +338,10 @@ void CheckClass::initializeVarList(const Function &func, std::list<std::string>
|
||||||
|
|
||||||
// Clearing array..
|
// Clearing array..
|
||||||
else if (Token::Match(ftok, "::| memset ( %var% ,")) {
|
else if (Token::Match(ftok, "::| memset ( %var% ,")) {
|
||||||
const int offset = ftok->str() == "::" ? 1 : 0;
|
if (ftok->str() == "::")
|
||||||
assignVar(ftok->strAt(2 + offset), scope, usage);
|
ftok = ftok->next();
|
||||||
ftok = ftok->linkAt(1 + offset);
|
assignVar(ftok->strAt(2), scope, usage);
|
||||||
|
ftok = ftok->linkAt(1);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -496,7 +497,7 @@ void CheckClass::noConstructorError(const Token *tok, const std::string &classna
|
||||||
|
|
||||||
void CheckClass::uninitVarError(const Token *tok, const std::string &classname, const std::string &varname)
|
void CheckClass::uninitVarError(const Token *tok, const std::string &classname, const std::string &varname)
|
||||||
{
|
{
|
||||||
reportError(tok, Severity::warning, "uninitVar", "Member variable '" + classname + "::" + varname + "' is not initialized in the constructor.");
|
reportError(tok, Severity::warning, "uninitMemberVar", "Member variable '" + classname + "::" + varname + "' is not initialized in the constructor.");
|
||||||
}
|
}
|
||||||
|
|
||||||
void CheckClass::operatorEqVarError(const Token *tok, const std::string &classname, const std::string &varname)
|
void CheckClass::operatorEqVarError(const Token *tok, const std::string &classname, const std::string &varname)
|
||||||
|
@ -1140,7 +1141,7 @@ void CheckClass::thisSubtraction()
|
||||||
if (!tok)
|
if (!tok)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
if (!Token::simpleMatch(tok->previous(), "*"))
|
if (tok->strAt(-1) != "*")
|
||||||
thisSubtractionError(tok);
|
thisSubtractionError(tok);
|
||||||
|
|
||||||
tok = tok->next();
|
tok = tok->next();
|
||||||
|
|
Loading…
Reference in New Issue