simplify if(tok && Token::{simple,}Match) to if(Token::{simple,}Match).
This commit is contained in:
parent
f3f3567f16
commit
6f1e7e897d
|
@ -1059,7 +1059,7 @@ void CheckClass::checkMemset()
|
||||||
if (var && arg1->strAt(1) == ",") {
|
if (var && arg1->strAt(1) == ",") {
|
||||||
if (var->isArrayOrPointer()) {
|
if (var->isArrayOrPointer()) {
|
||||||
const Token *endTok = var->typeEndToken();
|
const Token *endTok = var->typeEndToken();
|
||||||
while (endTok && Token::simpleMatch(endTok, "*")) {
|
while (Token::simpleMatch(endTok, "*")) {
|
||||||
++numIndirToVariableType;
|
++numIndirToVariableType;
|
||||||
endTok = endTok->previous();
|
endTok = endTok->previous();
|
||||||
}
|
}
|
||||||
|
|
|
@ -239,7 +239,7 @@ static bool inBooleanFunction(const Token *tok)
|
||||||
const Function *func = scope->function;
|
const Function *func = scope->function;
|
||||||
if (func) {
|
if (func) {
|
||||||
const Token *ret = func->retDef;
|
const Token *ret = func->retDef;
|
||||||
while (ret && Token::Match(ret, "static|const"))
|
while (Token::Match(ret, "static|const"))
|
||||||
ret = ret->next();
|
ret = ret->next();
|
||||||
return ret && (ret->str() == "bool");
|
return ret && (ret->str() == "bool");
|
||||||
}
|
}
|
||||||
|
|
|
@ -980,7 +980,7 @@ bool CheckUninitVar::isVariableUsage(const Token *vartok, bool pointer, Alloc al
|
||||||
const Token *parent = vartok->next()->astParent();
|
const Token *parent = vartok->next()->astParent();
|
||||||
while (Token::Match(parent, "[|."))
|
while (Token::Match(parent, "[|."))
|
||||||
parent = parent->astParent();
|
parent = parent->astParent();
|
||||||
if (parent && Token::simpleMatch(parent, "&") && !parent->astOperand2())
|
if (Token::simpleMatch(parent, "&") && !parent->astOperand2())
|
||||||
return false;
|
return false;
|
||||||
if (parent && Token::Match(parent->previous(), "if|while|switch ("))
|
if (parent && Token::Match(parent->previous(), "if|while|switch ("))
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -3079,7 +3079,7 @@ Scope::Scope(const SymbolDatabase *check_, const Token *classDef_, const Scope *
|
||||||
// skip over qualification if present
|
// skip over qualification if present
|
||||||
if (nameTok && nameTok->str() == "::")
|
if (nameTok && nameTok->str() == "::")
|
||||||
nameTok = nameTok->next();
|
nameTok = nameTok->next();
|
||||||
while (nameTok && Token::Match(nameTok, "%type% ::"))
|
while (Token::Match(nameTok, "%type% ::"))
|
||||||
nameTok = nameTok->tokAt(2);
|
nameTok = nameTok->tokAt(2);
|
||||||
if (nameTok && ((type == Scope::eEnum && Token::Match(nameTok, ":|{")) || nameTok->str() != "{")) // anonymous and unnamed structs/unions don't have a name
|
if (nameTok && ((type == Scope::eEnum && Token::Match(nameTok, ":|{")) || nameTok->str() != "{")) // anonymous and unnamed structs/unions don't have a name
|
||||||
|
|
||||||
|
|
|
@ -1816,7 +1816,7 @@ void Tokenizer::combineOperators()
|
||||||
else if (c1 == '-' && c2 == '>') {
|
else if (c1 == '-' && c2 == '>') {
|
||||||
// If the preceding sequence is "( & %name% )", replace it by "%name%"
|
// If the preceding sequence is "( & %name% )", replace it by "%name%"
|
||||||
Token *t = tok->tokAt(-4);
|
Token *t = tok->tokAt(-4);
|
||||||
if (t && Token::Match(t, "( & %name% )")) {
|
if (Token::Match(t, "( & %name% )")) {
|
||||||
t->deleteThis();
|
t->deleteThis();
|
||||||
t->deleteThis();
|
t->deleteThis();
|
||||||
t->deleteNext();
|
t->deleteNext();
|
||||||
|
@ -7000,7 +7000,7 @@ bool Tokenizer::simplifyRedundantParentheses()
|
||||||
if (Token::Match(tok->previous(), "*|& ( %name% )")) {
|
if (Token::Match(tok->previous(), "*|& ( %name% )")) {
|
||||||
// We may have a variable declaration looking like "type_name *(var_name)"
|
// We may have a variable declaration looking like "type_name *(var_name)"
|
||||||
Token *tok2 = tok->tokAt(-2);
|
Token *tok2 = tok->tokAt(-2);
|
||||||
while (tok2 && Token::Match(tok2, "%type%|static|const|extern") && tok2->str() != "operator") {
|
while (Token::Match(tok2, "%type%|static|const|extern") && tok2->str() != "operator") {
|
||||||
tok2 = tok2->previous();
|
tok2 = tok2->previous();
|
||||||
}
|
}
|
||||||
if (tok2 && !Token::Match(tok2, "[;,{]")) {
|
if (tok2 && !Token::Match(tok2, "[;,{]")) {
|
||||||
|
@ -8614,10 +8614,10 @@ void Tokenizer::simplifyKeyword()
|
||||||
// 2) void f() final; <- function is final
|
// 2) void f() final; <- function is final
|
||||||
if (Token::Match(tok, ") const|override|final")) {
|
if (Token::Match(tok, ") const|override|final")) {
|
||||||
Token* specifier = tok->tokAt(2);
|
Token* specifier = tok->tokAt(2);
|
||||||
while (specifier && Token::Match(specifier, "const|override|final")) {
|
while (Token::Match(specifier, "const|override|final")) {
|
||||||
specifier=specifier->next();
|
specifier=specifier->next();
|
||||||
}
|
}
|
||||||
if (specifier && Token::Match(specifier, "[{;]")) {
|
if (Token::Match(specifier, "[{;]")) {
|
||||||
specifier = tok->next();
|
specifier = tok->next();
|
||||||
while (!Token::Match(specifier, "[{;]")) {
|
while (!Token::Match(specifier, "[{;]")) {
|
||||||
if (specifier->str()=="final")
|
if (specifier->str()=="final")
|
||||||
|
|
Loading…
Reference in New Issue