diff --git a/lib/checkclass.cpp b/lib/checkclass.cpp index da3ff5d74..e25d0c836 100644 --- a/lib/checkclass.cpp +++ b/lib/checkclass.cpp @@ -819,7 +819,7 @@ void CheckClass::initializationListUsage() break; if (Token::Match(tok, "try|do {")) break; - if (Token::Match(tok, "%var% = %any%") && tok->strAt(-1) != "*") { + if (Token::Match(tok, "%var% =") && tok->strAt(-1) != "*") { const Variable* var = tok->variable(); if (var && var->scope() == owner && !var->isStatic()) { if (var->isPointer() || var->isReference() || (!var->type() && !var->isStlStringType() && !(Token::Match(var->typeStartToken(), "std :: %type% <") && !Token::simpleMatch(var->typeStartToken()->linkAt(3), "> ::")))) @@ -991,7 +991,7 @@ void CheckClass::checkMemset() for (std::size_t i = 0; i < functions; ++i) { const Scope * scope = symbolDatabase->functionScopes[i]; for (const Token *tok = scope->classStart; tok && tok != scope->classEnd; tok = tok->next()) { - if (Token::Match(tok, "memset|memcpy|memmove ( %any%")) { + if (Token::Match(tok, "memset|memcpy|memmove (")) { const Token* arg1 = tok->tokAt(2); const Token* arg3 = arg1->nextArgument(); if (arg3) diff --git a/lib/checkfunctions.cpp b/lib/checkfunctions.cpp index 1ee90bd83..1432c776a 100644 --- a/lib/checkfunctions.cpp +++ b/lib/checkfunctions.cpp @@ -222,7 +222,7 @@ void CheckFunctions::checkMathFunctions() mathfunctionCallWarning(tok, 2); } // fmod ( x , y) If y is zero, then either a range error will occur or the function will return zero (implementation-defined). - else if (Token::Match(tok, "fmod|fmodf|fmodl ( %any%")) { + else if (Token::Match(tok, "fmod|fmodf|fmodl (")) { const Token* nextArg = tok->tokAt(2)->nextArgument(); if (nextArg && nextArg->isNumber() && MathLib::isNullValue(nextArg->str())) mathfunctionCallWarning(tok, 2); diff --git a/lib/checkio.cpp b/lib/checkio.cpp index fe06f83d2..898abcaaa 100644 --- a/lib/checkio.cpp +++ b/lib/checkio.cpp @@ -498,7 +498,7 @@ void CheckIO::checkWrongPrintfScanfArguments() bool scanf_s = false; int formatStringArgNo = -1; - if (Token::Match(tok->next(), "( %any%") && _settings->library.formatstr_function(tok->str())) { + if (tok->strAt(1) == "(" && _settings->library.formatstr_function(tok->str())) { const std::map& argumentChecks = _settings->library.argumentChecks.at(tok->str()); for (std::map::const_iterator i = argumentChecks.cbegin(); i != argumentChecks.cend(); ++i) { if (i->second.formatstr) { diff --git a/lib/checkmemoryleak.cpp b/lib/checkmemoryleak.cpp index bcf8cad3a..441c26af1 100644 --- a/lib/checkmemoryleak.cpp +++ b/lib/checkmemoryleak.cpp @@ -2094,7 +2094,7 @@ void CheckMemoryLeakInFunction::checkReallocUsage() // Search for the "var = realloc(var, 100" pattern within this function for (const Token *tok = scope->classStart->next(); tok != scope->classEnd; tok = tok->next()) { if (tok->varId() > 0 && - Token::Match(tok, "%name% = realloc|g_try_realloc ( %name% , %any%") && + Token::Match(tok, "%name% = realloc|g_try_realloc ( %name% ,") && tok->varId() == tok->tokAt(4)->varId() && isNoArgument(symbolDatabase, tok->varId())) { // Check that another copy of the pointer wasn't saved earlier in the function @@ -2113,7 +2113,7 @@ void CheckMemoryLeakInFunction::checkReallocUsage() memleakUponReallocFailureError(tok, tok->str()); } else if (tok->next()->varId() > 0 && - (Token::Match(tok, "* %name% = realloc|g_try_realloc ( * %name% , %any%") && + (Token::Match(tok, "* %name% = realloc|g_try_realloc ( * %name% ,") && tok->next()->varId() == tok->tokAt(6)->varId()) && isNoArgument(symbolDatabase, tok->next()->varId())) { // Check that another copy of the pointer wasn't saved earlier in the function diff --git a/lib/checkother.cpp b/lib/checkother.cpp index eaae621bc..90c4b3c97 100644 --- a/lib/checkother.cpp +++ b/lib/checkother.cpp @@ -921,7 +921,7 @@ void CheckOther::checkSuspiciousEqualityComparison() // for (i = 0; i < 10; i == a) if (Token::Match(openParen->next(), "%name% ==")) suspiciousEqualityComparisonError(openParen->tokAt(2)); - if (Token::Match(closeParen->tokAt(-2), "== %any%")) + if (closeParen->strAt(-2) == "==") suspiciousEqualityComparisonError(closeParen->tokAt(-2)); // Skip over for() loop conditions because "for (;running==1;)" @@ -1292,7 +1292,7 @@ bool CheckOther::checkInnerScope(const Token *tok, const Variable* var, bool& us if (Token::Match(tok, "& %varid%", var->declarationId())) // Taking address of variable return false; - if (Token::Match(tok, "%varid% = %any%", var->declarationId())) + if (Token::Match(tok, "%varid% =", var->declarationId())) bFirstAssignment = true; if (!bFirstAssignment && Token::Match(tok, "* %varid%", var->declarationId())) // dereferencing means access to previous content @@ -1793,8 +1793,8 @@ void CheckOther::checkInvalidFree() // If a variable that was previously assigned a newly-allocated memory location is // added or subtracted from when used to free the memory, report an error. - else if (Token::Match(tok, "free|g_free|delete ( %any% +|- %any%") || - Token::Match(tok, "delete [ ] ( %any% +|- %any%") || + else if (Token::Match(tok, "free|g_free|delete ( %any% +|-") || + Token::Match(tok, "delete [ ] ( %any% +|-") || Token::Match(tok, "delete %any% +|- %any%")) { const int varIndex = tok->strAt(1) == "(" ? 2 : diff --git a/lib/checkstl.cpp b/lib/checkstl.cpp index bc47005f3..b995048c1 100644 --- a/lib/checkstl.cpp +++ b/lib/checkstl.cpp @@ -193,7 +193,7 @@ void CheckStl::iterators() } // Reassign the iterator - else if (Token::Match(tok2, "%varid% = %any%", iteratorId)) { + else if (Token::Match(tok2, "%varid% =", iteratorId)) { // Assume that the iterator becomes valid. // TODO: add checking that checks if the iterator becomes valid or not validatingToken = Token::findmatch(tok2->tokAt(2), "[;)]");