Skip to content

Commit 6236e1d

Browse files
committed
Token::Match: removed harmless special code for initial '!!foo' patterns.
1 parent de36324 commit 6236e1d

File tree

3 files changed

+1
-18
lines changed

3 files changed

+1
-18
lines changed

lib/token.cpp

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -510,7 +510,6 @@ int Token::firstWordLen(const char *str)
510510
bool Token::Match(const Token *tok, const char pattern[], unsigned int varid)
511511
{
512512
const char *p = pattern;
513-
bool firstpattern = true;
514513
bool ismulticomp = false;
515514
while (*p) {
516515
// Skip spaces in pattern..
@@ -531,15 +530,6 @@ bool Token::Match(const Token *tok, const char pattern[], unsigned int varid)
531530
return false;
532531
}
533532

534-
// If we are in the first token, we skip all initial !! patterns
535-
if (firstpattern && !tok->previous() && tok->next() && p[0] == '!' && p[1] == '!' && p[2] != '\0') {
536-
while (*p && *p != ' ')
537-
++p;
538-
continue;
539-
}
540-
541-
firstpattern = false;
542-
543533
// Compare the first character of the string for optimization reasons
544534
// before doing more detailed checks.
545535
if (p[0] == '%') {

test/testtoken.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -316,7 +316,6 @@ class TestToken : public TestFixture {
316316
ASSERT_EQUALS(false, Token::Match(emptyString.tokens(), "!!else something"));
317317

318318
givenACodeSampleToTokenize ifSemicolon("if ;", true);
319-
ASSERT_EQUALS(true, Token::Match(ifSemicolon.tokens(), "!!return if"));
320319
ASSERT_EQUALS(true, Token::Match(ifSemicolon.tokens(), "if ; !!else"));
321320

322321
givenACodeSampleToTokenize ifSemicolonSomething("if ; something", true);
@@ -342,7 +341,7 @@ class TestToken : public TestFixture {
342341
ASSERT_EQUALS(false, Token::Match(noType.tokens(), "%type%"));
343342

344343
givenACodeSampleToTokenize noType2("void delete", true);
345-
TODO_ASSERT_EQUALS(false, true, Token::Match(noType2.tokens(), "!!foo %type%"));
344+
ASSERT_EQUALS(false, Token::Match(noType2.tokens(), "!!foo %type%"));
346345
}
347346

348347
void matchChar() {

tools/matchcompiler.py

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -340,12 +340,6 @@ def _replaceTokenMatch(self, line):
340340
break # Non-const pattern - bailout
341341

342342
pattern = res.group(1)
343-
344-
# TODO: We currently generate incorrect code for "!!" patterns
345-
# skip them for now until this is fixed
346-
if pattern.find("!!") != -1:
347-
break
348-
349343
line = self._replaceSpecificTokenMatch(is_simplematch, line, pos1, end_pos, pattern, tok, varId)
350344

351345
return line

0 commit comments

Comments
 (0)