Fixed five new true positives in cppcheck, silenced one new false positive (see #5618)
This commit is contained in:
parent
7e4081f7f5
commit
e8c7a723f5
|
@ -1480,7 +1480,7 @@ void CheckOther::invalidFunctionUsage()
|
||||||
for (const Token* tok = scope->classStart->next(); tok != scope->classEnd; tok = tok->next()) {
|
for (const Token* tok = scope->classStart->next(); tok != scope->classEnd; tok = tok->next()) {
|
||||||
if (!Token::Match(tok, "%var% ( !!)"))
|
if (!Token::Match(tok, "%var% ( !!)"))
|
||||||
continue;
|
continue;
|
||||||
const std::string functionName = tok->str();
|
const std::string& functionName = tok->str();
|
||||||
int argnr = 1;
|
int argnr = 1;
|
||||||
const Token *argtok = tok->tokAt(2);
|
const Token *argtok = tok->tokAt(2);
|
||||||
while (argtok && argtok->str() != ")") {
|
while (argtok && argtok->str() != ")") {
|
||||||
|
@ -3048,8 +3048,8 @@ void CheckOther::checkComparisonFunctionIsAlwaysTrueOrFalse(void)
|
||||||
const Scope * scope = symbolDatabase->functionScopes[i];
|
const Scope * scope = symbolDatabase->functionScopes[i];
|
||||||
for (const Token* tok = scope->classStart->next(); tok != scope->classEnd; tok = tok->next()) {
|
for (const Token* tok = scope->classStart->next(); tok != scope->classEnd; tok = tok->next()) {
|
||||||
if (tok->isName() && Token::Match(tok, "isgreater|isless|islessgreater|isgreaterequal|islessequal ( %var% , %var% )")) {
|
if (tok->isName() && Token::Match(tok, "isgreater|isless|islessgreater|isgreaterequal|islessequal ( %var% , %var% )")) {
|
||||||
const std::string functionName = tok->str(); // store function name
|
const std::string& functionName = tok->str(); // store function name
|
||||||
const std::string varNameLeft = tok->tokAt(2)->str(); // get the left variable name
|
const std::string& varNameLeft = tok->tokAt(2)->str(); // get the left variable name
|
||||||
const unsigned int varidLeft = tok->tokAt(2)->varId();// get the left varid
|
const unsigned int varidLeft = tok->tokAt(2)->varId();// get the left varid
|
||||||
const unsigned int varidRight = tok->tokAt(4)->varId();// get the right varid
|
const unsigned int varidRight = tok->tokAt(4)->varId();// get the right varid
|
||||||
// compare varids: if they are not zero but equal
|
// compare varids: if they are not zero but equal
|
||||||
|
|
|
@ -107,14 +107,14 @@ void CheckUnusedFunctions::parseTokens(const Tokenizer &tokenizer, const char Fi
|
||||||
while (qPropToken && qPropToken->str() != ")") {
|
while (qPropToken && qPropToken->str() != ")") {
|
||||||
if (settings->library.isexportedprefix(tok->str(), qPropToken->str())) {
|
if (settings->library.isexportedprefix(tok->str(), qPropToken->str())) {
|
||||||
const Token* qNextPropToken = qPropToken->next();
|
const Token* qNextPropToken = qPropToken->next();
|
||||||
const std::string value = qNextPropToken->str();
|
const std::string& value = qNextPropToken->str();
|
||||||
if (_functions.find(value) != _functions.end()) {
|
if (_functions.find(value) != _functions.end()) {
|
||||||
_functions[value].usedOtherFile = true;
|
_functions[value].usedOtherFile = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (settings->library.isexportedsuffix(tok->str(), qPropToken->str())) {
|
if (settings->library.isexportedsuffix(tok->str(), qPropToken->str())) {
|
||||||
const Token* qNextPropToken = qPropToken->previous();
|
const Token* qNextPropToken = qPropToken->previous();
|
||||||
const std::string value = qNextPropToken->str();
|
const std::string& value = qNextPropToken->str();
|
||||||
if (value != ")" && _functions.find(value) != _functions.end()) {
|
if (value != ")" && _functions.find(value) != _functions.end()) {
|
||||||
_functions[value].usedOtherFile = true;
|
_functions[value].usedOtherFile = true;
|
||||||
}
|
}
|
||||||
|
@ -130,7 +130,7 @@ void CheckUnusedFunctions::parseTokens(const Tokenizer &tokenizer, const char Fi
|
||||||
if (qPropToken->next()) {
|
if (qPropToken->next()) {
|
||||||
qPropToken = qPropToken->next();
|
qPropToken = qPropToken->next();
|
||||||
while (qPropToken && qPropToken->str() != ")") {
|
while (qPropToken && qPropToken->str() != ")") {
|
||||||
const std::string value = qPropToken->str();
|
const std::string& value = qPropToken->str();
|
||||||
if (!value.empty()) {
|
if (!value.empty()) {
|
||||||
_functions[value].usedOtherFile = true;
|
_functions[value].usedOtherFile = true;
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -1936,7 +1936,7 @@ void Tokenizer::simplifyArrayAccessSyntax()
|
||||||
// 0[a] -> a[0]
|
// 0[a] -> a[0]
|
||||||
for (Token *tok = list.front(); tok; tok = tok->next()) {
|
for (Token *tok = list.front(); tok; tok = tok->next()) {
|
||||||
if (Token::Match(tok, "%num% [ %var% ]")) {
|
if (Token::Match(tok, "%num% [ %var% ]")) {
|
||||||
const std::string temp = tok->str();
|
std::string temp = tok->str();
|
||||||
tok->str(tok->strAt(2));
|
tok->str(tok->strAt(2));
|
||||||
tok->tokAt(2)->str(temp);
|
tok->tokAt(2)->str(temp);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue