Tokenizer: reduce usage of Token::Match in some cases.
This commit is contained in:
parent
963f6ce3ef
commit
4b08b13845
|
@ -4169,7 +4169,7 @@ bool Tokenizer::simplifyIfAddBraces()
|
||||||
|
|
||||||
else if (tok->str() == "else") {
|
else if (tok->str() == "else") {
|
||||||
// An else followed by an if or brace don't need to be processed further
|
// An else followed by an if or brace don't need to be processed further
|
||||||
if (Token::Match(tok, "else if|{"))
|
if (Token::Match(tok->next(), "if|{"))
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -7019,22 +7019,25 @@ void Tokenizer::simplifyEnum()
|
||||||
tok = tok->previous();
|
tok = tok->previous();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Token::Match(tok, "class|struct|namespace %any%") &&
|
if (Token::Match(tok, "class|struct|namespace") && tok->next() &&
|
||||||
(!tok->previous() || (tok->previous() && tok->previous()->str() != "enum"))) {
|
(!tok->previous() || (tok->previous() && tok->previous()->str() != "enum"))) {
|
||||||
className = tok->next()->str();
|
className = tok->next()->str();
|
||||||
classLevel = 0;
|
classLevel = 0;
|
||||||
continue;
|
|
||||||
} else if (tok->str() == "}") {
|
} else if (tok->str() == "}") {
|
||||||
--classLevel;
|
--classLevel;
|
||||||
if (classLevel < 0)
|
if (classLevel < 0)
|
||||||
className = "";
|
className = "";
|
||||||
|
|
||||||
continue;
|
|
||||||
} else if (tok->str() == "{") {
|
} else if (tok->str() == "{") {
|
||||||
++classLevel;
|
++classLevel;
|
||||||
continue;
|
} else if (tok->str() == "enum") {
|
||||||
} else if (Token::Match(tok, "enum class|struct| {|:") ||
|
Token *temp = tok->next();
|
||||||
Token::Match(tok, "enum class|struct| %type% {|:|;")) {
|
if (!temp)
|
||||||
|
break;
|
||||||
|
if (Token::Match(temp, "class|struct"))
|
||||||
|
temp = temp->next();
|
||||||
|
if (!Token::Match(temp, "[{:]") &&
|
||||||
|
(!temp->isName() || !Token::Match(temp->next(), "[{:;]")))
|
||||||
|
continue;
|
||||||
Token *start = tok;
|
Token *start = tok;
|
||||||
Token *enumType = 0;
|
Token *enumType = 0;
|
||||||
Token *typeTokenStart = 0;
|
Token *typeTokenStart = 0;
|
||||||
|
@ -7045,7 +7048,7 @@ void Tokenizer::simplifyEnum()
|
||||||
tok->deleteNext();
|
tok->deleteNext();
|
||||||
|
|
||||||
// check for name
|
// check for name
|
||||||
if (Token::Match(tok->next(), "%type%")) {
|
if (tok->next()->isName()) {
|
||||||
enumType = tok->next();
|
enumType = tok->next();
|
||||||
tok = tok->next();
|
tok = tok->next();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue