CheckOther::checkComparisonOfBoolWithBool,checkComparisonOfFuncReturningBool: use symbolDatabase to check only tokens in executable code.

This commit is contained in:
Edoardo Prezioso 2012-10-01 15:38:31 +02:00
parent 9a462d8a0a
commit 60de3e75af
1 changed files with 55 additions and 47 deletions

View File

@ -2231,7 +2231,10 @@ void CheckOther::checkComparisonOfFuncReturningBool()
const SymbolDatabase * const symbolDatabase = _tokenizer->getSymbolDatabase();
for (const Token *tok = _tokenizer->tokens(); tok; tok = tok->next()) {
for (std::list<Scope>::const_iterator scope = symbolDatabase->scopeList.begin(); scope != symbolDatabase->scopeList.end(); ++scope) {
if (!scope->isExecutable())
continue;
for (const Token* tok = scope->classStart->next(); tok != scope->classEnd; tok = tok->next()) {
if (tok->previous() && tok->type() == Token::eComparisonOp && tok->str() != "==" && tok->str() != "!=") {
const Token *first_token;
bool first_token_func_of_type_bool = false;
@ -2269,6 +2272,7 @@ void CheckOther::checkComparisonOfFuncReturningBool()
}
}
}
}
void CheckOther::comparisonOfFuncReturningBoolError(const Token *tok, const std::string &expression)
{
@ -2307,7 +2311,10 @@ void CheckOther::checkComparisonOfBoolWithBool()
const SymbolDatabase* const symbolDatabase = _tokenizer->getSymbolDatabase();
for (const Token *tok = _tokenizer->tokens(); tok; tok = tok->next()) {
for (std::list<Scope>::const_iterator scope = symbolDatabase->scopeList.begin(); scope != symbolDatabase->scopeList.end(); ++scope) {
if (!scope->isExecutable())
continue;
for (const Token* tok = scope->classStart->next(); tok != scope->classEnd; tok = tok->next()) {
if (tok->previous() && tok->type() == Token::eComparisonOp && tok->str() != "==" && tok->str() != "!=") {
bool first_token_bool = false;
bool second_token_bool = false;
@ -2330,6 +2337,7 @@ void CheckOther::checkComparisonOfBoolWithBool()
}
}
}
}
void CheckOther::comparisonOfBoolWithBoolError(const Token *tok, const std::string &expression)
{