Use Token::simpleMatch() / Token::findsimplematch() where possible

This commit is contained in:
Thomas Jarosch 2011-10-28 22:30:33 +02:00
parent b69ad0fefc
commit 91a5d95bc9
3 changed files with 7 additions and 7 deletions

View File

@ -191,7 +191,7 @@ void CheckOther::warningOldStylePointerCast()
void CheckOther::checkFflushOnInputStream()
{
const Token *tok = _tokenizer->tokens();
while (tok && ((tok = Token::findmatch(tok, "fflush ( stdin )")) != NULL)) {
while (tok && ((tok = Token::findsimplematch(tok, "fflush ( stdin )")) != NULL)) {
fflushOnInputStreamError(tok, tok->strAt(2));
tok = tok->tokAt(4);
}
@ -399,12 +399,12 @@ void CheckOther::checkSwitchCaseFallThrough()
if (loopnest.empty()) {
justbreak = true;
}
tok2 = Token::findmatch(tok2, ";");
tok2 = Token::findsimplematch(tok2, ";");
} else if (Token::Match(tok2, "case|default")) {
if (!justbreak && !firstcase) {
switchCaseFallThrough(tok2);
}
tok2 = Token::findmatch(tok2, ":");
tok2 = Token::findsimplematch(tok2, ":");
justbreak = true;
firstcase = false;
} else if (tok2->str() == "{") {

View File

@ -103,7 +103,7 @@ private:
tokenizer.tokenize(istr, "test.cpp");
// there is no allocation
const Token *tok = Token::findmatch(tokenizer.tokens(), "ret =");
const Token *tok = Token::findsimplematch(tokenizer.tokens(), "ret =");
CheckMemoryLeak check(&tokenizer, 0);
ASSERT_EQUALS(CheckMemoryLeak::No, check.getAllocationType(tok->tokAt(2), 1));
}

View File

@ -140,13 +140,13 @@ private:
void nextArgument() {
givenACodeSampleToTokenize example1("foo(1, 2, 3, 4);");
ASSERT_EQUALS(true, Token::Match(example1.tokens()->tokAt(2)->nextArgument(), "2 , 3"));
ASSERT_EQUALS(true, Token::simpleMatch(example1.tokens()->tokAt(2)->nextArgument(), "2 , 3"));
givenACodeSampleToTokenize example2("foo();");
ASSERT_EQUALS(true, example2.tokens()->tokAt(2)->nextArgument() == 0);
givenACodeSampleToTokenize example3("foo(bar(a, b), 2, 3);");
ASSERT_EQUALS(true, Token::Match(example3.tokens()->tokAt(2)->nextArgument(), "2 , 3"));
ASSERT_EQUALS(true, Token::simpleMatch(example3.tokens()->tokAt(2)->nextArgument(), "2 , 3"));
}
@ -252,7 +252,7 @@ private:
ASSERT_EQUALS(true, Token::Match(logicalOr.tokens(), "%oror%|&&"));
givenACodeSampleToTokenize logicalAnd("&&");
ASSERT_EQUALS(true, Token::Match(logicalAnd.tokens(), "&&"));
ASSERT_EQUALS(true, Token::simpleMatch(logicalAnd.tokens(), "&&"));
ASSERT_EQUALS(true, Token::Match(logicalAnd.tokens(), "&&|%oror%"));
ASSERT_EQUALS(true, Token::Match(logicalAnd.tokens(), "%oror%|&&"));
}