Removed obsolete internal check. The underlying but in Token::Match should be fixed since b4f0869a71
This commit is contained in:
parent
688d5d5c54
commit
f771a79738
|
@ -50,33 +50,6 @@ void CheckInternal::checkTokenMatchPatterns()
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
const char *p = pattern.c_str();
|
|
||||||
while (*p) {
|
|
||||||
while (*p && std::isspace(*p))
|
|
||||||
p++;
|
|
||||||
const char *start = p;
|
|
||||||
while (*p && !std::isspace(*p))
|
|
||||||
p++;
|
|
||||||
const char *end = p - 1;
|
|
||||||
if (start < end && !(*start == '[' && *end == ']')) {
|
|
||||||
bool cmd = (*start=='%' && std::isalpha(*(start+1)));
|
|
||||||
// check multicompare pattern..
|
|
||||||
for (const char *s = start; s != end; s++) {
|
|
||||||
if (*s == '|') {
|
|
||||||
if (!(*(s+1) == '%' && std::isalpha(*(s+2)))) {
|
|
||||||
cmd = false;
|
|
||||||
} else if (!cmd &&
|
|
||||||
std::strncmp(s+1,"%op%",4)!=0 &&
|
|
||||||
std::strncmp(s+1,"%or%",4)!=0 &&
|
|
||||||
std::strncmp(s+1,"%cop%",5)!=0 &&
|
|
||||||
std::strncmp(s+1,"%name%",5)!=0 &&
|
|
||||||
std::strncmp(s+1,"%oror%",6)!=0) {
|
|
||||||
multiComparePatternError(tok, pattern, funcname);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (pattern.find("||") != std::string::npos || pattern.find(" | ") != std::string::npos || pattern[0] == '|' || (pattern[pattern.length() - 1] == '|' && pattern[pattern.length() - 2] == ' '))
|
if (pattern.find("||") != std::string::npos || pattern.find(" | ") != std::string::npos || pattern[0] == '|' || (pattern[pattern.length() - 1] == '|' && pattern[pattern.length() - 2] == ' '))
|
||||||
orInComplexPattern(tok, pattern, funcname);
|
orInComplexPattern(tok, pattern, funcname);
|
||||||
|
|
||||||
|
|
|
@ -39,8 +39,7 @@ private:
|
||||||
TEST_CASE(missingPercentCharacter)
|
TEST_CASE(missingPercentCharacter)
|
||||||
TEST_CASE(unknownPattern)
|
TEST_CASE(unknownPattern)
|
||||||
TEST_CASE(redundantNextPrevious)
|
TEST_CASE(redundantNextPrevious)
|
||||||
TEST_CASE(internalError)
|
TEST_CASE(internalError);
|
||||||
TEST_CASE(invalidMultiCompare);
|
|
||||||
TEST_CASE(orInComplexPattern);
|
TEST_CASE(orInComplexPattern);
|
||||||
TEST_CASE(extraWhitespace);
|
TEST_CASE(extraWhitespace);
|
||||||
}
|
}
|
||||||
|
@ -237,8 +236,7 @@ private:
|
||||||
" const Token *tok;\n"
|
" const Token *tok;\n"
|
||||||
" Token::Match(tok, \"foo|%type|bar\");\n"
|
" Token::Match(tok, \"foo|%type|bar\");\n"
|
||||||
"}");
|
"}");
|
||||||
ASSERT_EQUALS("[test.cpp:3]: (error) Bad multicompare pattern (a %cmd% must be first unless it is %or%,%op%,%cop%,%name%,%oror%) inside Token::Match() call: \"foo|%type|bar\"\n"
|
ASSERT_EQUALS("[test.cpp:3]: (error) Missing percent end character in Token::Match() pattern: \"foo|%type|bar\"\n"
|
||||||
"[test.cpp:3]: (error) Missing percent end character in Token::Match() pattern: \"foo|%type|bar\"\n"
|
|
||||||
, errout.str());
|
, errout.str());
|
||||||
|
|
||||||
// Make sure we don't take %or% for a broken %oror%
|
// Make sure we don't take %or% for a broken %oror%
|
||||||
|
@ -330,27 +328,6 @@ private:
|
||||||
ASSERT_EQUALS("", errout.str());
|
ASSERT_EQUALS("", errout.str());
|
||||||
}
|
}
|
||||||
|
|
||||||
void invalidMultiCompare() {
|
|
||||||
// #5310
|
|
||||||
check("void f() {\n"
|
|
||||||
" const Token *tok;\n"
|
|
||||||
" Token::Match(tok, \";|%type%\");\n"
|
|
||||||
"}");
|
|
||||||
ASSERT_EQUALS("[test.cpp:3]: (error) Bad multicompare pattern (a %cmd% must be first unless it is %or%,%op%,%cop%,%name%,%oror%) inside Token::Match() call: \";|%type%\"\n", errout.str());
|
|
||||||
|
|
||||||
check("void f() {\n"
|
|
||||||
" const Token *tok;\n"
|
|
||||||
" Token::Match(tok, \";|%oror%\");\n"
|
|
||||||
"}");
|
|
||||||
ASSERT_EQUALS("", errout.str());
|
|
||||||
|
|
||||||
check("void f() {\n" // The %name%|%num% works..
|
|
||||||
" const Token *tok;\n"
|
|
||||||
" Token::Match(tok, \"%name%|%num%\");\n"
|
|
||||||
"}");
|
|
||||||
ASSERT_EQUALS("", errout.str());
|
|
||||||
}
|
|
||||||
|
|
||||||
void orInComplexPattern() {
|
void orInComplexPattern() {
|
||||||
check("void f() {\n"
|
check("void f() {\n"
|
||||||
" Token::Match(tok, \"||\");\n"
|
" Token::Match(tok, \"||\");\n"
|
||||||
|
|
Loading…
Reference in New Issue