Cleanup: Removed += and -= patterns from the checks. These should be simplified.
This commit is contained in:
parent
82223227bd
commit
1c4afbce8c
|
@ -375,15 +375,13 @@ static bool for3(const Token * const tok,
|
||||||
const bool maxMinFlipped)
|
const bool maxMinFlipped)
|
||||||
{
|
{
|
||||||
assert(tok != 0);
|
assert(tok != 0);
|
||||||
if (Token::Match(tok, "%varid% += %num% )", varid) ||
|
if (Token::Match(tok, "%varid% = %num% + %varid% )", varid)) {
|
||||||
Token::Match(tok, "%varid% = %num% + %varid% )", varid)) {
|
|
||||||
if (!for_maxvalue(tok->tokAt(2), min_value, max_value))
|
if (!for_maxvalue(tok->tokAt(2), min_value, max_value))
|
||||||
return false;
|
return false;
|
||||||
} else if (Token::Match(tok, "%varid% = %varid% + %num% )", varid)) {
|
} else if (Token::Match(tok, "%varid% = %varid% + %num% )", varid)) {
|
||||||
if (!for_maxvalue(tok->tokAt(4), min_value, max_value))
|
if (!for_maxvalue(tok->tokAt(4), min_value, max_value))
|
||||||
return false;
|
return false;
|
||||||
} else if (Token::Match(tok, "%varid% -= %num% )", varid) ||
|
} else if (Token::Match(tok, "%varid% = %num% - %varid% )", varid)) {
|
||||||
Token::Match(tok, "%varid% = %num% - %varid% )", varid)) {
|
|
||||||
if (!for_maxvalue(tok->tokAt(2), min_value, max_value))
|
if (!for_maxvalue(tok->tokAt(2), min_value, max_value))
|
||||||
return false;
|
return false;
|
||||||
} else if (Token::Match(tok, "%varid% = %varid% - %num% )", varid)) {
|
} else if (Token::Match(tok, "%varid% = %varid% - %num% )", varid)) {
|
||||||
|
@ -418,7 +416,7 @@ static bool for_bailout(const Token * const tok1, unsigned int varid)
|
||||||
for (const Token *loopTok = tok1; loopTok && loopTok != tok1->link(); loopTok = loopTok->next()) {
|
for (const Token *loopTok = tok1; loopTok && loopTok != tok1->link(); loopTok = loopTok->next()) {
|
||||||
if (loopTok->varId() == varid) {
|
if (loopTok->varId() == varid) {
|
||||||
// Counter variable used inside loop
|
// Counter variable used inside loop
|
||||||
if (Token::Match(loopTok->next(), "+=|-=|++|--|=") ||
|
if (Token::Match(loopTok->next(), "++|--|=") ||
|
||||||
(loopTok->previous()->type() == Token::eIncDecOp)) {
|
(loopTok->previous()->type() == Token::eIncDecOp)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -764,7 +762,7 @@ void CheckBufferOverrun::checkScopeForBody(const Token *tok, const ArrayInfo &ar
|
||||||
if (!for3(tok2->next(), counter_varid, min_counter_value, max_counter_value, maxMinFlipped))
|
if (!for3(tok2->next(), counter_varid, min_counter_value, max_counter_value, maxMinFlipped))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (Token::Match(tok2->next(), "%var% =|+=|-=") && MathLib::toLongNumber(max_counter_value) <= size)
|
if (Token::Match(tok2->next(), "%var% =") && MathLib::toLongNumber(max_counter_value) <= size)
|
||||||
condition_out_of_bounds = false;
|
condition_out_of_bounds = false;
|
||||||
|
|
||||||
// Goto the end parenthesis of the for-statement: "for (x; y; z)" ..
|
// Goto the end parenthesis of the for-statement: "for (x; y; z)" ..
|
||||||
|
|
|
@ -997,7 +997,7 @@ void CheckClass::checkReturnPtrThis(const Scope *scope, const Function *func, co
|
||||||
}
|
}
|
||||||
|
|
||||||
// check if *this is returned
|
// check if *this is returned
|
||||||
else if (!(Token::Match(tok->next(), "(| * this ;|=|+=") ||
|
else if (!(Token::Match(tok->next(), "(| * this ;|=") ||
|
||||||
Token::simpleMatch(tok->next(), "operator= (") ||
|
Token::simpleMatch(tok->next(), "operator= (") ||
|
||||||
Token::simpleMatch(tok->next(), "this . operator= (") ||
|
Token::simpleMatch(tok->next(), "this . operator= (") ||
|
||||||
(Token::Match(tok->next(), "%type% :: operator= (") &&
|
(Token::Match(tok->next(), "%type% :: operator= (") &&
|
||||||
|
|
|
@ -1251,8 +1251,7 @@ Token *CheckMemoryLeakInFunction::getcode(const Token *tok, std::list<const Toke
|
||||||
}
|
}
|
||||||
if (Token::Match(tok, "[)=] %varid% [+;)]", varid) ||
|
if (Token::Match(tok, "[)=] %varid% [+;)]", varid) ||
|
||||||
Token::Match(tok, "%var% + %varid%", varid) ||
|
Token::Match(tok, "%var% + %varid%", varid) ||
|
||||||
Token::Match(tok, "%varid% +=|-=", varid) ||
|
Token::Match(tok, "<< %varid% ;", varid) ||
|
||||||
Token::Match(tok, "+=|<< %varid% ;", varid) ||
|
|
||||||
Token::Match(tok, "= strcpy|strcat|memmove|memcpy ( %varid% ,", varid) ||
|
Token::Match(tok, "= strcpy|strcat|memmove|memcpy ( %varid% ,", varid) ||
|
||||||
Token::Match(tok, "[;{}] %var% [ %varid% ]", varid)) {
|
Token::Match(tok, "[;{}] %var% [ %varid% ]", varid)) {
|
||||||
addtoken(&rettail, tok, "use");
|
addtoken(&rettail, tok, "use");
|
||||||
|
|
|
@ -379,7 +379,7 @@ bool CheckNullPointer::isPointerDeRef(const Token *tok, bool &unknown, const Sym
|
||||||
ovarid = tok->tokAt(2)->varId();
|
ovarid = tok->tokAt(2)->varId();
|
||||||
else if (Token::Match(tok->tokAt(-2), "%var% ==|!= %var%"))
|
else if (Token::Match(tok->tokAt(-2), "%var% ==|!= %var%"))
|
||||||
ovarid = tok->tokAt(-2)->varId();
|
ovarid = tok->tokAt(-2)->varId();
|
||||||
else if (Token::Match(tok->tokAt(-2), "%var% =|+=|+ %var% )|]|,|;|+"))
|
else if (Token::Match(tok->tokAt(-2), "%var% =|+ %var% )|]|,|;|+"))
|
||||||
ovarid = tok->tokAt(-2)->varId();
|
ovarid = tok->tokAt(-2)->varId();
|
||||||
if (ovarid) {
|
if (ovarid) {
|
||||||
const Variable* var = symbolDatabase->getVariableFromVarId(ovarid);
|
const Variable* var = symbolDatabase->getVariableFromVarId(ovarid);
|
||||||
|
@ -1168,7 +1168,7 @@ void CheckNullPointer::nullConstantDereference()
|
||||||
ovarid = tok->tokAt(2)->varId();
|
ovarid = tok->tokAt(2)->varId();
|
||||||
else if (Token::Match(tok, "%var% ==|!= 0"))
|
else if (Token::Match(tok, "%var% ==|!= 0"))
|
||||||
ovarid = tok->varId();
|
ovarid = tok->varId();
|
||||||
else if (Token::Match(tok, "%var% =|+=|+ 0 )|]|,|;|+"))
|
else if (Token::Match(tok, "%var% =|+ 0 )|]|,|;|+"))
|
||||||
ovarid = tok->varId();
|
ovarid = tok->varId();
|
||||||
if (ovarid) {
|
if (ovarid) {
|
||||||
const Variable* var = symbolDatabase->getVariableFromVarId(ovarid);
|
const Variable* var = symbolDatabase->getVariableFromVarId(ovarid);
|
||||||
|
|
Loading…
Reference in New Issue