Token::Match: removed harmless special code for initial '!!foo' patterns.

This commit is contained in:
Edoardo Prezioso 2013-01-09 20:11:02 +01:00
parent de36324d62
commit 6236e1dc38
3 changed files with 1 additions and 18 deletions

View File

@ -510,7 +510,6 @@ int Token::firstWordLen(const char *str)
bool Token::Match(const Token *tok, const char pattern[], unsigned int varid) bool Token::Match(const Token *tok, const char pattern[], unsigned int varid)
{ {
const char *p = pattern; const char *p = pattern;
bool firstpattern = true;
bool ismulticomp = false; bool ismulticomp = false;
while (*p) { while (*p) {
// Skip spaces in pattern.. // Skip spaces in pattern..
@ -531,15 +530,6 @@ bool Token::Match(const Token *tok, const char pattern[], unsigned int varid)
return false; 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 // Compare the first character of the string for optimization reasons
// before doing more detailed checks. // before doing more detailed checks.
if (p[0] == '%') { if (p[0] == '%') {

View File

@ -316,7 +316,6 @@ private:
ASSERT_EQUALS(false, Token::Match(emptyString.tokens(), "!!else something")); ASSERT_EQUALS(false, Token::Match(emptyString.tokens(), "!!else something"));
givenACodeSampleToTokenize ifSemicolon("if ;", true); givenACodeSampleToTokenize ifSemicolon("if ;", true);
ASSERT_EQUALS(true, Token::Match(ifSemicolon.tokens(), "!!return if"));
ASSERT_EQUALS(true, Token::Match(ifSemicolon.tokens(), "if ; !!else")); ASSERT_EQUALS(true, Token::Match(ifSemicolon.tokens(), "if ; !!else"));
givenACodeSampleToTokenize ifSemicolonSomething("if ; something", true); givenACodeSampleToTokenize ifSemicolonSomething("if ; something", true);
@ -342,7 +341,7 @@ private:
ASSERT_EQUALS(false, Token::Match(noType.tokens(), "%type%")); ASSERT_EQUALS(false, Token::Match(noType.tokens(), "%type%"));
givenACodeSampleToTokenize noType2("void delete", true); 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() { void matchChar() {

View File

@ -340,12 +340,6 @@ class MatchCompiler:
break # Non-const pattern - bailout break # Non-const pattern - bailout
pattern = res.group(1) 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) line = self._replaceSpecificTokenMatch(is_simplematch, line, pos1, end_pos, pattern, tok, varId)
return line return line