checkother: improved constness of local variables, no functional change.
This commit is contained in:
parent
a572c0b728
commit
86aa2a27ab
|
@ -667,8 +667,8 @@ void CheckOther::checkRedundantAssignment()
|
||||||
else if (tok2->varId() == tok->varId())
|
else if (tok2->varId() == tok->varId())
|
||||||
error = false;
|
error = false;
|
||||||
else if (Token::Match(tok2, "%var% (") && nonLocal(tok->variable())) { // Called function might use the variable
|
else if (Token::Match(tok2, "%var% (") && nonLocal(tok->variable())) { // Called function might use the variable
|
||||||
const Function* func = tok2->function();
|
const Function* const func = tok2->function();
|
||||||
const Variable* var = tok->variable();
|
const Variable* const var = tok->variable();
|
||||||
if (!var || var->isGlobal() || var->isReference() || ((!func || func->nestedIn) && tok2->strAt(-1) != ".")) // Global variable, or member function
|
if (!var || var->isGlobal() || var->isReference() || ((!func || func->nestedIn) && tok2->strAt(-1) != ".")) // Global variable, or member function
|
||||||
error = false;
|
error = false;
|
||||||
}
|
}
|
||||||
|
@ -699,7 +699,7 @@ void CheckOther::checkRedundantAssignment()
|
||||||
memAssignments.erase(tok->varId());
|
memAssignments.erase(tok->varId());
|
||||||
}
|
}
|
||||||
} else if (Token::Match(tok, "%var% (")) { // Function call. Global variables might be used. Reset their status
|
} else if (Token::Match(tok, "%var% (")) { // Function call. Global variables might be used. Reset their status
|
||||||
bool memfunc = Token::Match(tok, "memcpy|memmove|memset|strcpy|strncpy|sprintf|snprintf|strcat|strncat|wcscpy|wcsncpy|swprintf|wcscat|wcsncat");
|
const bool memfunc = Token::Match(tok, "memcpy|memmove|memset|strcpy|strncpy|sprintf|snprintf|strcat|strncat|wcscpy|wcsncpy|swprintf|wcscat|wcsncat");
|
||||||
if (memfunc) {
|
if (memfunc) {
|
||||||
const Token* param1 = tok->tokAt(2);
|
const Token* param1 = tok->tokAt(2);
|
||||||
writtenArgumentsEnd = param1->next();
|
writtenArgumentsEnd = param1->next();
|
||||||
|
@ -717,7 +717,7 @@ void CheckOther::checkRedundantAssignment()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (scope->type == Scope::eSwitch) { // Avoid false positives if noreturn function is called in switch
|
} else if (scope->type == Scope::eSwitch) { // Avoid false positives if noreturn function is called in switch
|
||||||
const Function* func = tok->function();
|
const Function* const func = tok->function();
|
||||||
if (!func || !func->hasBody) {
|
if (!func || !func->hasBody) {
|
||||||
varAssignments.clear();
|
varAssignments.clear();
|
||||||
memAssignments.clear();
|
memAssignments.clear();
|
||||||
|
|
Loading…
Reference in New Issue