Fixed #5827 (Invalid token match patterns)
This commit is contained in:
parent
20c19b85c2
commit
d6db261213
|
@ -976,7 +976,7 @@ bool TemplateSimplifier::simplifyCalculations(Token *_tokens)
|
||||||
if (tok->isNumber()) {
|
if (tok->isNumber()) {
|
||||||
// Remove redundant conditions (0&&x) (1||x)
|
// Remove redundant conditions (0&&x) (1||x)
|
||||||
if (Token::Match(tok->previous(), "[(=,] 0 &&") ||
|
if (Token::Match(tok->previous(), "[(=,] 0 &&") ||
|
||||||
Token::Match(tok->previous(), "[(=,] 1 ||")) {
|
Token::Match(tok->previous(), "[(=,] 1 %oror%")) {
|
||||||
unsigned int par = 0;
|
unsigned int par = 0;
|
||||||
const Token *tok2 = tok;
|
const Token *tok2 = tok;
|
||||||
for (; tok2; tok2 = tok2->next()) {
|
for (; tok2; tok2 = tok2->next()) {
|
||||||
|
|
|
@ -302,10 +302,10 @@ private:
|
||||||
|
|
||||||
void matchAny() const {
|
void matchAny() const {
|
||||||
givenACodeSampleToTokenize varBitOrVar("abc|def", true);
|
givenACodeSampleToTokenize varBitOrVar("abc|def", true);
|
||||||
ASSERT_EQUALS(true, Token::Match(varBitOrVar.tokens(), "%var% | %var%"));
|
ASSERT_EQUALS(true, Token::Match(varBitOrVar.tokens(), "%var% %or% %var%"));
|
||||||
|
|
||||||
givenACodeSampleToTokenize varLogOrVar("abc||def", true);
|
givenACodeSampleToTokenize varLogOrVar("abc||def", true);
|
||||||
ASSERT_EQUALS(true, Token::Match(varLogOrVar.tokens(), "%var% || %var%"));
|
ASSERT_EQUALS(true, Token::Match(varLogOrVar.tokens(), "%var% %oror% %var%"));
|
||||||
}
|
}
|
||||||
|
|
||||||
void matchSingleChar() const {
|
void matchSingleChar() const {
|
||||||
|
|
Loading…
Reference in New Issue