From 6236e1dc385ec8165085c47c9b56533eb7d99dc7 Mon Sep 17 00:00:00 2001 From: Edoardo Prezioso Date: Wed, 9 Jan 2013 20:11:02 +0100 Subject: [PATCH] Token::Match: removed harmless special code for initial '!!foo' patterns. --- lib/token.cpp | 10 ---------- test/testtoken.cpp | 3 +-- tools/matchcompiler.py | 6 ------ 3 files changed, 1 insertion(+), 18 deletions(-) diff --git a/lib/token.cpp b/lib/token.cpp index 08975386f..625ba7b75 100644 --- a/lib/token.cpp +++ b/lib/token.cpp @@ -510,7 +510,6 @@ int Token::firstWordLen(const char *str) bool Token::Match(const Token *tok, const char pattern[], unsigned int varid) { const char *p = pattern; - bool firstpattern = true; bool ismulticomp = false; while (*p) { // Skip spaces in pattern.. @@ -531,15 +530,6 @@ bool Token::Match(const Token *tok, const char pattern[], unsigned int varid) return false; } - // If we are in the first token, we skip all initial !! patterns - if (firstpattern && !tok->previous() && tok->next() && p[0] == '!' && p[1] == '!' && p[2] != '\0') { - while (*p && *p != ' ') - ++p; - continue; - } - - firstpattern = false; - // Compare the first character of the string for optimization reasons // before doing more detailed checks. if (p[0] == '%') { diff --git a/test/testtoken.cpp b/test/testtoken.cpp index 1ae08f2a8..c9617bdd5 100644 --- a/test/testtoken.cpp +++ b/test/testtoken.cpp @@ -316,7 +316,6 @@ private: ASSERT_EQUALS(false, Token::Match(emptyString.tokens(), "!!else something")); givenACodeSampleToTokenize ifSemicolon("if ;", true); - ASSERT_EQUALS(true, Token::Match(ifSemicolon.tokens(), "!!return if")); ASSERT_EQUALS(true, Token::Match(ifSemicolon.tokens(), "if ; !!else")); givenACodeSampleToTokenize ifSemicolonSomething("if ; something", true); @@ -342,7 +341,7 @@ private: ASSERT_EQUALS(false, Token::Match(noType.tokens(), "%type%")); givenACodeSampleToTokenize noType2("void delete", true); - TODO_ASSERT_EQUALS(false, true, Token::Match(noType2.tokens(), "!!foo %type%")); + ASSERT_EQUALS(false, Token::Match(noType2.tokens(), "!!foo %type%")); } void matchChar() { diff --git a/tools/matchcompiler.py b/tools/matchcompiler.py index 07cfa9c39..fef2e4ece 100755 --- a/tools/matchcompiler.py +++ b/tools/matchcompiler.py @@ -340,12 +340,6 @@ class MatchCompiler: break # Non-const pattern - bailout pattern = res.group(1) - - # TODO: We currently generate incorrect code for "!!" patterns - # skip them for now until this is fixed - if pattern.find("!!") != -1: - break - line = self._replaceSpecificTokenMatch(is_simplematch, line, pos1, end_pos, pattern, tok, varId) return line