Related to previous commit: reduce scope level, remove the now redundant check.
This commit is contained in:
parent
60de3e75af
commit
72666e10d1
|
@ -2235,40 +2235,40 @@ void CheckOther::checkComparisonOfFuncReturningBool()
|
||||||
if (!scope->isExecutable())
|
if (!scope->isExecutable())
|
||||||
continue;
|
continue;
|
||||||
for (const Token* tok = scope->classStart->next(); tok != scope->classEnd; tok = tok->next()) {
|
for (const Token* tok = scope->classStart->next(); tok != scope->classEnd; tok = tok->next()) {
|
||||||
if (tok->previous() && tok->type() == Token::eComparisonOp && tok->str() != "==" && tok->str() != "!=") {
|
if (tok->type() != Token::eComparisonOp || tok->str() == "==" || tok->str() == "!=")
|
||||||
const Token *first_token;
|
continue;
|
||||||
bool first_token_func_of_type_bool = false;
|
const Token *first_token;
|
||||||
if (Token::simpleMatch(tok->previous(), ")")) {
|
bool first_token_func_of_type_bool = false;
|
||||||
first_token = tok->previous()->link()->previous();
|
if (Token::simpleMatch(tok->previous(), ")")) {
|
||||||
} else {
|
first_token = tok->previous()->link()->previous();
|
||||||
first_token = tok->previous();
|
} else {
|
||||||
}
|
first_token = tok->previous();
|
||||||
if (Token::Match(first_token, "%var% (") && !Token::Match(first_token->previous(), "::|.")) {
|
}
|
||||||
const Function* func = symbolDatabase->findFunctionByName(first_token->str(), first_token->scope());
|
if (Token::Match(first_token, "%var% (") && !Token::Match(first_token->previous(), "::|.")) {
|
||||||
if (func && func->tokenDef && func->tokenDef->strAt(-1) == "bool") {
|
const Function* func = symbolDatabase->findFunctionByName(first_token->str(), first_token->scope());
|
||||||
first_token_func_of_type_bool = true;
|
if (func && func->tokenDef && func->tokenDef->strAt(-1) == "bool") {
|
||||||
}
|
first_token_func_of_type_bool = true;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Token *second_token = tok->next();
|
Token *second_token = tok->next();
|
||||||
bool second_token_func_of_type_bool = false;
|
bool second_token_func_of_type_bool = false;
|
||||||
while (second_token->str()=="!") {
|
while (second_token->str()=="!") {
|
||||||
second_token = second_token->next();
|
second_token = second_token->next();
|
||||||
}
|
}
|
||||||
if (Token::Match(second_token, "%var% (") && !Token::Match(second_token->previous(), "::|.")) {
|
if (Token::Match(second_token, "%var% (") && !Token::Match(second_token->previous(), "::|.")) {
|
||||||
const Function* func = symbolDatabase->findFunctionByName(second_token->str(), second_token->scope());
|
const Function* func = symbolDatabase->findFunctionByName(second_token->str(), second_token->scope());
|
||||||
if (func && func->tokenDef && func->tokenDef->strAt(-1) == "bool") {
|
if (func && func->tokenDef && func->tokenDef->strAt(-1) == "bool") {
|
||||||
second_token_func_of_type_bool = true;
|
second_token_func_of_type_bool = true;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if ((first_token_func_of_type_bool == true) && (second_token_func_of_type_bool == true)) {
|
if ((first_token_func_of_type_bool == true) && (second_token_func_of_type_bool == true)) {
|
||||||
comparisonOfTwoFuncsReturningBoolError(first_token->next(), first_token->str(), second_token->str());
|
comparisonOfTwoFuncsReturningBoolError(first_token->next(), first_token->str(), second_token->str());
|
||||||
} else if (first_token_func_of_type_bool == true) {
|
} else if (first_token_func_of_type_bool == true) {
|
||||||
comparisonOfFuncReturningBoolError(first_token->next(), first_token->str());
|
comparisonOfFuncReturningBoolError(first_token->next(), first_token->str());
|
||||||
} else if (second_token_func_of_type_bool == true) {
|
} else if (second_token_func_of_type_bool == true) {
|
||||||
comparisonOfFuncReturningBoolError(second_token->previous(), second_token->str());
|
comparisonOfFuncReturningBoolError(second_token->previous(), second_token->str());
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2315,26 +2315,26 @@ void CheckOther::checkComparisonOfBoolWithBool()
|
||||||
if (!scope->isExecutable())
|
if (!scope->isExecutable())
|
||||||
continue;
|
continue;
|
||||||
for (const Token* tok = scope->classStart->next(); tok != scope->classEnd; tok = tok->next()) {
|
for (const Token* tok = scope->classStart->next(); tok != scope->classEnd; tok = tok->next()) {
|
||||||
if (tok->previous() && tok->type() == Token::eComparisonOp && tok->str() != "==" && tok->str() != "!=") {
|
if (tok->type() != Token::eComparisonOp || tok->str() == "==" || tok->str() == "!=")
|
||||||
bool first_token_bool = false;
|
continue;
|
||||||
bool second_token_bool = false;
|
bool first_token_bool = false;
|
||||||
|
bool second_token_bool = false;
|
||||||
|
|
||||||
const Token *first_token = tok->previous();
|
const Token *first_token = tok->previous();
|
||||||
if (first_token->varId()) {
|
if (first_token->varId()) {
|
||||||
if (isBool(symbolDatabase->getVariableFromVarId(first_token->varId()))) {
|
if (isBool(symbolDatabase->getVariableFromVarId(first_token->varId()))) {
|
||||||
first_token_bool = true;
|
first_token_bool = true;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
const Token *second_token = tok->next();
|
}
|
||||||
if (second_token->varId()) {
|
const Token *second_token = tok->next();
|
||||||
if (isBool(symbolDatabase->getVariableFromVarId(second_token->varId()))) {
|
if (second_token->varId()) {
|
||||||
second_token_bool = true;
|
if (isBool(symbolDatabase->getVariableFromVarId(second_token->varId()))) {
|
||||||
}
|
second_token_bool = true;
|
||||||
}
|
|
||||||
if ((first_token_bool == true) && (second_token_bool == true)) {
|
|
||||||
comparisonOfBoolWithBoolError(first_token->next(), first_token->str());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if ((first_token_bool == true) && (second_token_bool == true)) {
|
||||||
|
comparisonOfBoolWithBoolError(first_token->next(), first_token->str());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue