diff --git a/lib/checkbufferoverrun.cpp b/lib/checkbufferoverrun.cpp index 4dcb22059..1c2e262bf 100644 --- a/lib/checkbufferoverrun.cpp +++ b/lib/checkbufferoverrun.cpp @@ -375,15 +375,13 @@ static bool for3(const Token * const tok, const bool maxMinFlipped) { assert(tok != 0); - if (Token::Match(tok, "%varid% += %num% )", varid) || - Token::Match(tok, "%varid% = %num% + %varid% )", varid)) { + if (Token::Match(tok, "%varid% = %num% + %varid% )", varid)) { if (!for_maxvalue(tok->tokAt(2), min_value, max_value)) return false; } else if (Token::Match(tok, "%varid% = %varid% + %num% )", varid)) { if (!for_maxvalue(tok->tokAt(4), min_value, max_value)) return false; - } else if (Token::Match(tok, "%varid% -= %num% )", varid) || - Token::Match(tok, "%varid% = %num% - %varid% )", varid)) { + } else if (Token::Match(tok, "%varid% = %num% - %varid% )", varid)) { if (!for_maxvalue(tok->tokAt(2), min_value, max_value)) return false; } 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()) { if (loopTok->varId() == varid) { // Counter variable used inside loop - if (Token::Match(loopTok->next(), "+=|-=|++|--|=") || + if (Token::Match(loopTok->next(), "++|--|=") || (loopTok->previous()->type() == Token::eIncDecOp)) { 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)) 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; // Goto the end parenthesis of the for-statement: "for (x; y; z)" .. diff --git a/lib/checkclass.cpp b/lib/checkclass.cpp index 27ed19f38..38676b0ca 100644 --- a/lib/checkclass.cpp +++ b/lib/checkclass.cpp @@ -997,7 +997,7 @@ void CheckClass::checkReturnPtrThis(const Scope *scope, const Function *func, co } // 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(), "this . operator= (") || (Token::Match(tok->next(), "%type% :: operator= (") && diff --git a/lib/checkmemoryleak.cpp b/lib/checkmemoryleak.cpp index 0664c8542..cccdc77ad 100644 --- a/lib/checkmemoryleak.cpp +++ b/lib/checkmemoryleak.cpp @@ -1251,8 +1251,7 @@ Token *CheckMemoryLeakInFunction::getcode(const Token *tok, std::listtokAt(2)->varId(); else if (Token::Match(tok->tokAt(-2), "%var% ==|!= %var%")) 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(); if (ovarid) { const Variable* var = symbolDatabase->getVariableFromVarId(ovarid); @@ -1168,7 +1168,7 @@ void CheckNullPointer::nullConstantDereference() ovarid = tok->tokAt(2)->varId(); else if (Token::Match(tok, "%var% ==|!= 0")) ovarid = tok->varId(); - else if (Token::Match(tok, "%var% =|+=|+ 0 )|]|,|;|+")) + else if (Token::Match(tok, "%var% =|+ 0 )|]|,|;|+")) ovarid = tok->varId(); if (ovarid) { const Variable* var = symbolDatabase->getVariableFromVarId(ovarid);