diff --git a/lib/checkbufferoverrun.cpp b/lib/checkbufferoverrun.cpp index bbea60903..1d78f3df4 100644 --- a/lib/checkbufferoverrun.cpp +++ b/lib/checkbufferoverrun.cpp @@ -1172,7 +1172,7 @@ void CheckBufferOverrun::valueFlowCheckArrayIndex(const Token * const tok, const const Token *tok2 = tok->astParent(); while (Token::Match(tok2, "%var%|.|::|[")) tok2 = tok2->astParent(); - addressOf = Token::Match(tok2, "&") && !(tok2->astOperand1() && tok2->astOperand2()); + addressOf = tok2 && tok2->str() == "&" && !(tok2->astOperand1() && tok2->astOperand2()); } // Look for errors first diff --git a/lib/checkinternal.cpp b/lib/checkinternal.cpp index 9dd83f9b7..bbb669dbe 100644 --- a/lib/checkinternal.cpp +++ b/lib/checkinternal.cpp @@ -142,8 +142,14 @@ void CheckInternal::checkTokenSimpleMatchPatterns() } // Check for real errors - if (pattern.find_first_of("%") != std::string::npos || pattern.find("!!") != std::string::npos) - complexPatternError(tok, pattern, funcname); + if (pattern.length() > 1) { + for (size_t i = 0; i < pattern.length() - 1; i++) { + if (pattern[i] == '%' && pattern[i + 1] != ' ') + complexPatternError(tok, pattern, funcname); + else if (pattern[i] == '!' && pattern[i + 1] == '!') + complexPatternError(tok, pattern, funcname); + } + } } } diff --git a/lib/checkother.cpp b/lib/checkother.cpp index 11b0e214c..2b032e91c 100644 --- a/lib/checkother.cpp +++ b/lib/checkother.cpp @@ -2966,7 +2966,7 @@ void CheckOther::checkComparisonFunctionIsAlwaysTrueOrFalse() 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% )")) { 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->strAt(2); // get the left variable name const unsigned int varidLeft = tok->tokAt(2)->varId();// get the left varid const unsigned int varidRight = tok->tokAt(4)->varId();// get the right varid // compare varids: if they are not zero but equal diff --git a/lib/checksizeof.cpp b/lib/checksizeof.cpp index 1258edfab..fa7d35c60 100644 --- a/lib/checksizeof.cpp +++ b/lib/checksizeof.cpp @@ -299,15 +299,15 @@ void CheckSizeof::sizeofVoid() while (Token::simpleMatch(tok2->previous(), ".")) { isMember = true; if (Token::simpleMatch(tok2->tokAt(-2), ")")) - tok2 = tok2->tokAt(-2)->link(); + tok2 = tok2->linkAt(-2); else if (Token::simpleMatch(tok2->tokAt(-2), "]")) - tok2 = tok2->tokAt(-2)->link()->previous(); + tok2 = tok2->linkAt(-2)->previous(); else tok2 = tok2->tokAt(-2); } if (isMember) { // Get 'struct.member' complete name (without spaces) - varname = tok2->stringifyList(tok->tokAt(index)->next()); + varname = tok2->stringifyList(tok->tokAt(index+1)); varname.erase(remove_if(varname.begin(), varname.end(), static_cast(std::isspace)), varname.end()); } diff --git a/lib/checkuninitvar.cpp b/lib/checkuninitvar.cpp index b7be4a5f0..fc6402984 100644 --- a/lib/checkuninitvar.cpp +++ b/lib/checkuninitvar.cpp @@ -1873,7 +1873,7 @@ bool CheckUninitVar::isMemberVariableAssignment(const Token *tok, const std::str return false; } - else if (Token::Match(ftok ? ftok->previous() : nullptr, "= * (")) + else if (Token::simpleMatch(ftok ? ftok->previous() : nullptr, "= * (")) return false; } return true; diff --git a/lib/symboldatabase.cpp b/lib/symboldatabase.cpp index ebc668c1d..fd0aa7f15 100644 --- a/lib/symboldatabase.cpp +++ b/lib/symboldatabase.cpp @@ -502,8 +502,8 @@ SymbolDatabase::SymbolDatabase(const Tokenizer *tokenizer, const Settings *setti // throw() // const throw() else if (Token::Match(end, ") const| throw (") && - (end->next()->str() == "const" ? Token::Match(end->linkAt(3), ") ;") : - Token::Match(end->linkAt(2), ") ;"))) { + (end->next()->str() == "const" ? Token::simpleMatch(end->linkAt(3), ") ;") : + Token::simpleMatch(end->linkAt(2), ") ;"))) { function.isThrow = true; if (end->next()->str() == "const") { @@ -1099,7 +1099,7 @@ bool SymbolDatabase::isFunction(const Token *tok, const Scope* outerScope, const Token::Match(tok2, "= delete|default ;") || Token::Match(tok2, "const| noexcept const| {|:|;") || (Token::Match(tok2, "const| noexcept|throw (") && - tok2->str() == "const" ? (tok2->tokAt(2) && Token::Match(tok2->tokAt(2)->link(), ") const| {|:|;")) : + tok2->str() == "const" ? (tok2->tokAt(2) && Token::Match(tok2->linkAt(2), ") const| {|:|;")) : (tok2->next() && Token::Match(tok2->next()->link(), ") const| {|:|;"))))) { *funcStart = tok; *argStart = tok->next(); @@ -1111,7 +1111,7 @@ bool SymbolDatabase::isFunction(const Token *tok, const Scope* outerScope, const else if (outerScope->type == Scope::eGlobal && Token::Match(tok, "%var% (") && tok->isUpperCaseName() && - Token::Match(tok->linkAt(1), ") {") && + Token::simpleMatch(tok->linkAt(1), ") {") && (!tok->previous() || Token::Match(tok->previous(), "[;{}]"))) { *funcStart = tok; *argStart = tok->next(); diff --git a/lib/templatesimplifier.cpp b/lib/templatesimplifier.cpp index 3f06253f3..09bca97a7 100644 --- a/lib/templatesimplifier.cpp +++ b/lib/templatesimplifier.cpp @@ -241,13 +241,13 @@ unsigned int TemplateSimplifier::templateParameters(const Token *tok) tok = tok->next(); // Skip 'typename...' (Ticket #5774) - if (Token::Match(tok, "typename . . .")) { + if (Token::simpleMatch(tok, "typename . . .")) { tok = tok->tokAt(4); continue; } // Skip '=' - if (Token::Match(tok, "=")) + if (tok && tok->str() == "=") tok = tok->next(); if (!tok) return 0; diff --git a/lib/tokenize.cpp b/lib/tokenize.cpp index 803897355..789399262 100644 --- a/lib/tokenize.cpp +++ b/lib/tokenize.cpp @@ -5148,7 +5148,7 @@ void Tokenizer:: simplifyFunctionPointers() if (!Token::Match(tok2, "%var% ) (") && !Token::Match(tok2, "%var% [ ] ) (") && - !(Token::Match(tok2, "%var% (") && Token::Match(tok2->linkAt(1), ") ) ("))) + !(Token::Match(tok2, "%var% (") && Token::simpleMatch(tok2->linkAt(1), ") ) ("))) continue; while (tok->str() != "(") @@ -6135,7 +6135,7 @@ bool Tokenizer::simplifyCAlternativeTokens() } if (Token::Match(tok2, "not|compl %var%|(") && !Token::Match(tok2->previous(), "[;{}]")) { // Don't simplify 'not p;' (in case 'not' is a type) - tok2->str(Token::Match(tok2, "not") ? "!" : "~"); + tok2->str((tok2->str() == "not") ? "!" : "~"); ret = true; } } @@ -6421,7 +6421,7 @@ bool Tokenizer::simplifyKnownVariables() // Insert a "%var% = %num% ;" at the beginning of the scope as simplifyKnownVariablesSimplify might compute an updated value Token *scopeStart = tok2->tokAt(5); - scopeStart->insertToken(tok2->tokAt(1)->str()); + scopeStart->insertToken(tok2->strAt(1)); scopeStart = scopeStart->next(); Token* artificialAssignment = scopeStart; scopeStart->insertToken("="); @@ -6434,7 +6434,7 @@ bool Tokenizer::simplifyKnownVariables() ret |= simplifyKnownVariablesSimplify(&artificialAssignment, tok2->tokAt(6), varid, structname, value, valueIsPointer, valueVarId, valueToken, -1); // Remove the artificial assignment if no modification was done - if (artificialAssignment->tokAt(2)->str() == savedValue) { + if (artificialAssignment->strAt(2) == savedValue) { Token::eraseTokens(tok2->tokAt(5), scopeStart->next()); } } @@ -8373,7 +8373,7 @@ bool Tokenizer::simplifyMathFunctions() tok->deleteNext(2); // delete "std ::" } // get number string - std::string strNumber(tok->tokAt(2)->str()); + std::string strNumber(tok->strAt(2)); // is the string negative? if (!strNumber.empty() && strNumber[0] == '-') { strNumber = strNumber.substr(1); // remove '-' sign @@ -8384,9 +8384,9 @@ bool Tokenizer::simplifyMathFunctions() } else if (Token::Match(tok, "fma|fmaf|fmal ( %any% , %any% , %any% )")) { // Simplify: fma(a,b,c) == > ( a ) * ( b ) + ( c ) // get parameters - const std::string a(tok->tokAt(2)->str()); - const std::string b(tok->tokAt(4)->str()); - const std::string c(tok->tokAt(6)->str()); + const std::string a(tok->strAt(2)); + const std::string b(tok->strAt(4)); + const std::string c(tok->strAt(6)); if (!a.empty() && !b.empty() && !c.empty()) { tok->deleteNext(7); // delete fma call tok->str("( " + a + " ) * ( " + b + " ) + ( " + c + " )"); // insert result into token list @@ -8396,7 +8396,7 @@ bool Tokenizer::simplifyMathFunctions() // Simplify: sqrt(0) = 0 and cbrt(0) == 0 // sqrt(1) = 1 and cbrt(1) == 1 // get number string - const std::string parameter(tok->tokAt(2)->str()); + const std::string parameter(tok->strAt(2)); // is parameter 0 ? if (isZeroNumber(parameter)) { tok->deleteNext(3); // delete tokens @@ -8412,7 +8412,7 @@ bool Tokenizer::simplifyMathFunctions() // cosh[f|l](0) = 1 and cos[f|l](0) = 1 // erfc[f|l](0) = 1 // get number string - const std::string parameter(tok->tokAt(2)->str()); + const std::string parameter(tok->strAt(2)); // is parameter 0 ? if (isZeroNumber(parameter)) { tok->deleteNext(3); // delete tokens @@ -8427,7 +8427,7 @@ bool Tokenizer::simplifyMathFunctions() // atan[f|l](0) = 0 and atanh[f|l](0)= 0 // expm1[f|l](0) = 0 // get number string - const std::string parameter(tok->tokAt(2)->str()); + const std::string parameter(tok->strAt(2)); // is parameter 0 ? if (isZeroNumber(parameter)) { tok->deleteNext(3); // delete tokens @@ -8440,7 +8440,7 @@ bool Tokenizer::simplifyMathFunctions() // acosh[f|l](1) = 0 , acos[f|l](1) = 0 // ilogb[f|l](1) = 0 // get number string - const std::string parameter(tok->tokAt(2)->str()); + const std::string parameter(tok->strAt(2)); // is parameter 1 ? if (isOneNumber(parameter)) { tok->deleteNext(3); // delete tokens @@ -8451,8 +8451,8 @@ bool Tokenizer::simplifyMathFunctions() // @todo if one of the parameters is NaN the other is returned // e.g. printf ("fmin (NaN, -1.0) = %f\n", fmin(NaN,-1.0)); // e.g. printf ("fmin (-1.0, NaN) = %f\n", fmin(-1.0,NaN)); - const std::string strLeftNumber(tok->tokAt(2)->str()); - const std::string strRightNumber(tok->tokAt(4)->str()); + const std::string strLeftNumber(tok->strAt(2)); + const std::string strRightNumber(tok->strAt(4)); const bool isLessEqual = MathLib::isLessEqual(strLeftNumber, strRightNumber); // case: left <= right ==> insert left if (!strLeftNumber.empty() && !strRightNumber.empty() && isLessEqual) { @@ -8468,8 +8468,8 @@ bool Tokenizer::simplifyMathFunctions() // @todo if one of the parameters is NaN the other is returned // e.g. printf ("fmax (NaN, -1.0) = %f\n", fmax(NaN,-1.0)); // e.g. printf ("fmax (-1.0, NaN) = %f\n", fmax(-1.0,NaN)); - const std::string strLeftNumber(tok->tokAt(2)->str()); - const std::string strRightNumber(tok->tokAt(4)->str()); + const std::string strLeftNumber(tok->strAt(2)); + const std::string strRightNumber(tok->strAt(4)); const bool isLessEqual = MathLib::isLessEqual(strLeftNumber, strRightNumber); // case: left <= right ==> insert right if (!strLeftNumber.empty() && !strRightNumber.empty() && isLessEqual) { @@ -8484,8 +8484,8 @@ bool Tokenizer::simplifyMathFunctions() } else if (Token::Match(tok, "isgreater ( %num% , %num% )")) { // The isgreater(x,y) function is the same as calculating (x)>(y). // It returns true (1) if x is greater than y and false (0) otherwise. - const std::string strLeftNumber(tok->tokAt(2)->str()); // get left number - const std::string strRightNumber(tok->tokAt(4)->str()); // get right number + const std::string strLeftNumber(tok->strAt(2)); // get left number + const std::string strRightNumber(tok->strAt(4)); // get right number if (!strRightNumber.empty() && !strLeftNumber.empty()) { const bool isGreater = MathLib::isGreater(strLeftNumber, strRightNumber); // compare numbers tok->deleteNext(5); // delete tokens @@ -8496,8 +8496,8 @@ bool Tokenizer::simplifyMathFunctions() // The isgreaterequal(x,y) function is the same as calculating (x)>=(y). // It returns true (1) if x is greater than or equal to y. // False (0) is returned otherwise. - const std::string strLeftNumber(tok->tokAt(2)->str()); // get left number - const std::string strRightNumber(tok->tokAt(4)->str()); // get right number + const std::string strLeftNumber(tok->strAt(2)); // get left number + const std::string strRightNumber(tok->strAt(4)); // get right number if (!strRightNumber.empty() && !strLeftNumber.empty()) { const bool isGreaterEqual = MathLib::isGreaterEqual(strLeftNumber, strRightNumber); // compare numbers tok->deleteNext(5); // delete tokens @@ -8508,8 +8508,8 @@ bool Tokenizer::simplifyMathFunctions() // Calling this function is the same as calculating (x)<(y). // It returns true (1) if x is less than y. // False (0) is returned otherwise. - const std::string strLeftNumber(tok->tokAt(2)->str()); // get left number - const std::string strRightNumber(tok->tokAt(4)->str()); // get right number + const std::string strLeftNumber(tok->strAt(2)); // get left number + const std::string strRightNumber(tok->strAt(4)); // get right number if (!strRightNumber.empty() && !strLeftNumber.empty()) { const bool isLess = MathLib::isLess(strLeftNumber, strRightNumber); // compare numbers tok->deleteNext(5); // delete tokens @@ -8520,8 +8520,8 @@ bool Tokenizer::simplifyMathFunctions() // Calling this function is the same as calculating (x)<=(y). // It returns true (1) if x is less or equal to y. // False (0) is returned otherwise. - const std::string strLeftNumber(tok->tokAt(2)->str()); // get left number - const std::string strRightNumber(tok->tokAt(4)->str()); // get right number + const std::string strLeftNumber(tok->strAt(2)); // get left number + const std::string strRightNumber(tok->strAt(4)); // get right number if (!strRightNumber.empty() && !strLeftNumber.empty()) { const bool isLessEqual = MathLib::isLessEqual(strLeftNumber, strRightNumber); // compare numbers tok->deleteNext(5); // delete tokens @@ -8532,8 +8532,8 @@ bool Tokenizer::simplifyMathFunctions() // Calling this function is the same as calculating (x)<(y) || (x)>(y). // It returns true (1) if x is less than y or x is greater than y. // False (0) is returned otherwise. - const std::string strLeftNumber(tok->tokAt(2)->str()); // get left number - const std::string strRightNumber(tok->tokAt(4)->str()); // get right number + const std::string strLeftNumber(tok->strAt(2)); // get left number + const std::string strRightNumber(tok->strAt(4)); // get right number if (!strRightNumber.empty() && !strLeftNumber.empty()) { const bool isLessOrGreater(MathLib::isLess(strLeftNumber, strRightNumber) || MathLib::isGreater(strLeftNumber, strRightNumber)); // compare numbers @@ -8544,8 +8544,8 @@ bool Tokenizer::simplifyMathFunctions() } else if (Token::Match(tok, "div|ldiv|lldiv ( %any% , %num% )")) { // Calling the function 'div(x,y)' is the same as calculating (x)/(y). In case y has the value 1 // (the identity element), the call can be simplified to (x). - const std::string leftParameter(tok->tokAt(2)->str()); // get the left parameter - const std::string rightNumber(tok->tokAt(4)->str()); // get right number + const std::string leftParameter(tok->strAt(2)); // get the left parameter + const std::string rightNumber(tok->strAt(4)); // get right number if (!rightNumber.empty() && !leftParameter.empty()) { if (isOneNumber(rightNumber)) { tok->deleteNext(5); // delete tokens @@ -8558,8 +8558,8 @@ bool Tokenizer::simplifyMathFunctions() // In case of pow ( 0 , anyNumber > 0): It can be simplified to 0 // In case of pow ( 0 , 0 ): It simplified to 1 // In case of pow ( 1 , anyNumber ): It simplified to 1 - const std::string leftNumber(tok->tokAt(2)->str()); // get the left parameter - const std::string rightNumber(tok->tokAt(4)->str()); // get the right parameter + const std::string leftNumber(tok->strAt(2)); // get the left parameter + const std::string rightNumber(tok->strAt(4)); // get the right parameter if (!leftNumber.empty() && !rightNumber.empty()) { const bool isLeftNumberZero = isZeroNumber(leftNumber); const bool isLeftNumberOne = isOneNumber(leftNumber); @@ -8581,8 +8581,8 @@ bool Tokenizer::simplifyMathFunctions() } if (tok && Token::Match(tok->tokAt(2), "%any% , %num% )")) { // In case of pow( x , 1 ): It can be simplified to x. - const std::string leftParameter(tok->tokAt(2)->str()); // get the left parameter - const std::string rightNumber(tok->tokAt(4)->str()); // get right number + const std::string leftParameter(tok->strAt(2)); // get the left parameter + const std::string rightNumber(tok->strAt(4)); // get right number if (!rightNumber.empty() && !leftParameter.empty()) { if (isOneNumber(rightNumber)) { // case: x^(1) = x tok->deleteNext(5); // delete tokens @@ -10427,14 +10427,14 @@ void Tokenizer::simplifyMathExpressions() Token * const tok2 = tok->linkAt(3); if (!Token::Match(tok2, ") , %num% ) + pow|powf|powl ( cos|cosf|cosl (")) continue; - const std::string leftExponent = tok2->tokAt(2)->str(); + const std::string leftExponent = tok2->strAt(2); if (!isTwoNumber(leftExponent)) continue; // left exponent is not 2 Token * const tok3 = tok2->tokAt(8); if (!Token::Match(tok3->link(), ") , %num% )")) continue; Token * const tok4 = tok3->link(); - const std::string rightExponent = tok4->tokAt(2)->str(); + const std::string rightExponent = tok4->strAt(2); if (!isTwoNumber(rightExponent)) continue; // right exponent is not 2 if (tok->tokAt(3)->stringifyList(tok2->next()) == tok3->stringifyList(tok3->link()->next())) { @@ -10445,14 +10445,14 @@ void Tokenizer::simplifyMathExpressions() Token * const tok2 = tok->linkAt(3); if (!Token::Match(tok2, ") , %num% ) + pow|powf|powl ( sin|sinf|sinl (")) continue; - const std::string leftExponent = tok2->tokAt(2)->str(); + const std::string leftExponent = tok2->strAt(2); if (!isTwoNumber(leftExponent)) continue; // left exponent is not 2 Token * const tok3 = tok2->tokAt(8); if (!Token::Match(tok3->link(), ") , %num% )")) continue; Token * const tok4 = tok3->link(); - const std::string rightExponent = tok4->tokAt(2)->str(); + const std::string rightExponent = tok4->strAt(2); if (!isTwoNumber(rightExponent)) continue; // right exponent is not 2 if (tok->tokAt(3)->stringifyList(tok2->next()) == tok3->stringifyList(tok3->link()->next())) { @@ -10463,14 +10463,14 @@ void Tokenizer::simplifyMathExpressions() Token * const tok2 = tok->linkAt(3); if (!Token::Match(tok2, ") , %num% ) - pow|powf|powl ( cosh|coshf|coshl (")) continue; - const std::string leftExponent = tok2->tokAt(2)->str(); + const std::string leftExponent = tok2->strAt(2); if (!isTwoNumber(leftExponent)) continue; // left exponent is not 2 Token * const tok3 = tok2->tokAt(8); if (!Token::Match(tok3->link(), ") , %num% )")) continue; Token * const tok4 = tok3->link(); - const std::string rightExponent = tok4->tokAt(2)->str(); + const std::string rightExponent = tok4->strAt(2); if (!isTwoNumber(rightExponent)) continue; // right exponent is not 2 if (tok->tokAt(3)->stringifyList(tok2->next()) == tok3->stringifyList(tok3->link()->next())) { @@ -10481,14 +10481,14 @@ void Tokenizer::simplifyMathExpressions() Token * const tok2 = tok->linkAt(3); if (!Token::Match(tok2, ") , %num% ) - pow|powf|powl ( sinh|sinhf|sinhl (")) continue; - const std::string leftExponent = tok2->tokAt(2)->str(); + const std::string leftExponent = tok2->strAt(2); if (!isTwoNumber(leftExponent)) continue; // left exponent is not 2 Token * const tok3 = tok2->tokAt(8); if (!Token::Match(tok3->link(), ") , %num% )")) continue; Token * const tok4 = tok3->link(); - const std::string rightExponent = tok4->tokAt(2)->str(); + const std::string rightExponent = tok4->strAt(2); if (!isTwoNumber(rightExponent)) continue; // right exponent is not 2 if (tok->tokAt(3)->stringifyList(tok2->next()) == tok3->stringifyList(tok3->link()->next())) { diff --git a/lib/valueflow.cpp b/lib/valueflow.cpp index 168870275..1f66c6cbf 100644 --- a/lib/valueflow.cpp +++ b/lib/valueflow.cpp @@ -441,7 +441,7 @@ static void valueFlowBeforeCondition(TokenList *tokenlist, ErrorLogger *errorLog const Token *prev = tok2->previous(); while (Token::Match(prev,"%var%|.") && prev->str() != "sizeof") prev = prev->previous(); - if (Token::Match(prev,"sizeof")) + if (prev && prev->str() == "sizeof") continue; } diff --git a/test/testinternal.cpp b/test/testinternal.cpp index bb33dc561..1a80e60fe 100644 --- a/test/testinternal.cpp +++ b/test/testinternal.cpp @@ -105,6 +105,12 @@ private: " Token::findsimplematch(tok, \"foobar\");\n" "}"); ASSERT_EQUALS("", errout.str()); + + check("void f() {\n" + " const Token *tok;\n" + " Token::findsimplematch(tok, \"%\");\n" + "}"); + ASSERT_EQUALS("", errout.str()); } void simplePatternSquareBrackets() { diff --git a/test/testsymboldatabase.cpp b/test/testsymboldatabase.cpp index 000898dd1..e8e80669b 100644 --- a/test/testsymboldatabase.cpp +++ b/test/testsymboldatabase.cpp @@ -640,9 +640,9 @@ private: std::istringstream istr(code); tokenizer.tokenize(istr, "test.cpp"); - const Token *tok = Token::findmatch(tokenizer.tokens(), ". x"); + const Token *tok = Token::findsimplematch(tokenizer.tokens(), ". x"); tok = tok ? tok->next() : nullptr; - ASSERT(tok && tok->variable() && Token::Match(tok->variable()->typeStartToken(), "int x ;")); + ASSERT(tok && tok->variable() && Token::simpleMatch(tok->variable()->typeStartToken(), "int x ;")); ASSERT(tok && tok->varId() == 0U); // It's possible to set a varId } @@ -660,9 +660,9 @@ private: std::istringstream istr(code); tokenizer.tokenize(istr, "test.cpp"); - const Token *tok = Token::findmatch(tokenizer.tokens(), ". x"); + const Token *tok = Token::findsimplematch(tokenizer.tokens(), ". x"); tok = tok ? tok->next() : nullptr; - ASSERT(tok && tok->variable() && Token::Match(tok->variable()->typeStartToken(), "int x ;")); + ASSERT(tok && tok->variable() && Token::simpleMatch(tok->variable()->typeStartToken(), "int x ;")); ASSERT(tok && tok->varId() == 0U); // It's possible to set a varId } @@ -680,9 +680,9 @@ private: std::istringstream istr(code); tokenizer.tokenize(istr, "test.cpp"); - const Token *tok = Token::findmatch(tokenizer.tokens(), ". x"); + const Token *tok = Token::findsimplematch(tokenizer.tokens(), ". x"); tok = tok ? tok->next() : nullptr; - ASSERT(tok && tok->variable() && Token::Match(tok->variable()->typeStartToken(), "int x ;")); + ASSERT(tok && tok->variable() && Token::simpleMatch(tok->variable()->typeStartToken(), "int x ;")); ASSERT(tok && tok->varId() == 0U); // It's possible to set a varId } @@ -726,7 +726,7 @@ private: ASSERT(db && db->scopeList.size() == 3); if (db) { - const Token * const functionToken = Token::findmatch(tokenizer.tokens(), "func"); + const Token * const functionToken = Token::findsimplematch(tokenizer.tokens(), "func"); const Scope *scope = findFunctionScopeByToken(db, functionToken); @@ -752,7 +752,7 @@ private: ASSERT(db && db->scopeList.size() == 2); if (db) { - const Token * const functionToken = Token::findmatch(tokenizer.tokens(), "func"); + const Token * const functionToken = Token::findsimplematch(tokenizer.tokens(), "func"); const Scope *scope = findFunctionScopeByToken(db, functionToken); @@ -773,7 +773,7 @@ private: ASSERT(db && db->scopeList.size() == 3); if (db) { - const Token * const functionToken = Token::findmatch(tokenizer.tokens()->linkAt(2), "func"); + const Token * const functionToken = Token::findsimplematch(tokenizer.tokens()->linkAt(2), "func"); const Scope *scope = findFunctionScopeByToken(db, functionToken); @@ -796,7 +796,7 @@ private: ASSERT(db && db->scopeList.size() == 2); if (db) { - const Token * const functionToken = Token::findmatch(tokenizer.tokens(), "func"); + const Token * const functionToken = Token::findsimplematch(tokenizer.tokens(), "func"); const Scope *scope = findFunctionScopeByToken(db, functionToken); @@ -817,7 +817,7 @@ private: ASSERT(db && db->scopeList.size() == 3); if (db) { - const Token * const functionToken = Token::findmatch(tokenizer.tokens(), "func"); + const Token * const functionToken = Token::findsimplematch(tokenizer.tokens(), "func"); const Scope *scope = findFunctionScopeByToken(db, functionToken); @@ -838,7 +838,7 @@ private: ASSERT(db && db->scopeList.size() == 2); if (db) { - const Token * const functionToken = Token::findmatch(tokenizer.tokens(), "func"); + const Token * const functionToken = Token::findsimplematch(tokenizer.tokens(), "func"); const Scope *scope = findFunctionScopeByToken(db, functionToken); @@ -859,7 +859,7 @@ private: ASSERT(db && db->scopeList.size() == 3); if (db) { - const Token * const functionToken = Token::findmatch(tokenizer.tokens()->linkAt(2), "func"); + const Token * const functionToken = Token::findsimplematch(tokenizer.tokens()->linkAt(2), "func"); const Scope *scope = findFunctionScopeByToken(db, functionToken); @@ -2043,7 +2043,7 @@ private: " float t;\n" " func(x, &t);\n" "}"); - const Token *callfunc = Token::findmatch(tokenizer.tokens(), "func ( x , & t ) ;"); + const Token *callfunc = Token::findsimplematch(tokenizer.tokens(), "func ( x , & t ) ;"); ASSERT_EQUALS("", errout.str()); ASSERT_EQUALS(true, db != nullptr); // not null ASSERT_EQUALS(true, callfunc != nullptr); // not null