Disable checkComparisonOfFuncReturningBool check because of false warnings. Ticket #2617
This commit is contained in:
parent
bb62325ddb
commit
ff4f8b58f3
|
@ -2245,6 +2245,11 @@ void CheckOther::misusedScopeObjectError(const Token *tok, const std::string& va
|
|||
|
||||
void CheckOther::checkComparisonOfFuncReturningBool()
|
||||
{
|
||||
// FIXME: This checking is "experimental" because of the false positives
|
||||
// when self checking lib/preprocessor.cpp (#2617)
|
||||
if (!_settings->experimental)
|
||||
return;
|
||||
|
||||
if (!_settings->isEnabled("style"))
|
||||
return;
|
||||
|
||||
|
@ -2264,7 +2269,7 @@ void CheckOther::checkComparisonOfFuncReturningBool()
|
|||
|
||||
std::string const first_token_name = first_token->str();
|
||||
if (first_token->isName()&& isFunction(first_token->str(), _tokenizer->tokens())) {
|
||||
const Token *fToken = _tokenizer->getFunctionTokenByName(first_token_name.c_str());
|
||||
const Token *fToken = NULL; // TODO: locate function token
|
||||
if (fToken &&fToken->previous() && fToken->previous()->str() == "bool") {
|
||||
first_token_func_of_type_bool = true;
|
||||
}
|
||||
|
@ -2276,7 +2281,7 @@ void CheckOther::checkComparisonOfFuncReturningBool()
|
|||
}
|
||||
std::string const second_token_name = second_token->str();
|
||||
if (second_token->isName()&& isFunction(second_token->str(), _tokenizer->tokens())) {
|
||||
const Token *fToken = _tokenizer->getFunctionTokenByName(second_token_name.c_str());
|
||||
const Token *fToken = NULL; // TODO: locate function token
|
||||
if (fToken &&fToken->previous() && fToken->previous()->str() == "bool") {
|
||||
second_token_func_of_type_bool = true;
|
||||
}
|
||||
|
|
|
@ -7555,19 +7555,6 @@ bool Tokenizer::IsScopeNoReturn(const Token *endScopeToken, bool *unknown)
|
|||
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
const Token *Tokenizer::getFunctionTokenByName(const char funcname[]) const
|
||||
{
|
||||
std::list<Scope>::const_iterator scope;
|
||||
|
||||
for (scope = _symbolDatabase->scopeList.begin(); scope != _symbolDatabase->scopeList.end(); ++scope) {
|
||||
if (scope->type == Scope::eFunction) {
|
||||
if (scope->classDef->str() == funcname)
|
||||
return scope->classDef;
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
bool Tokenizer::isFunctionParameterPassedByValue(const Token *fpar) const
|
||||
{
|
||||
// TODO: If symbol database is available, use it.
|
||||
|
|
|
@ -142,14 +142,6 @@ public:
|
|||
*/
|
||||
unsigned int sizeOfType(const Token *type) const;
|
||||
|
||||
/**
|
||||
* Get function token by function name
|
||||
* @todo better handling of overloaded functions
|
||||
* @todo only scan parent scopes
|
||||
* @param funcname function name
|
||||
*/
|
||||
const Token *getFunctionTokenByName(const char funcname[]) const;
|
||||
|
||||
/**
|
||||
* Try to determine if function parameter is passed by value by looking
|
||||
* at the function declaration.
|
||||
|
|
|
@ -3992,7 +3992,7 @@ private:
|
|||
" else\n"
|
||||
" return true;\n"
|
||||
"}\n");
|
||||
ASSERT_EQUALS("[test.cpp:3]: (style) Comparison of two functions returning boolean value using relational (<, >, <= or >=) operator.\n", errout.str());
|
||||
TODO_ASSERT_EQUALS("[test.cpp:3]: (style) Comparison of two functions returning boolean value using relational (<, >, <= or >=) operator.\n", "", errout.str());
|
||||
}
|
||||
|
||||
void checkComparisonOfFuncReturningBool2() {
|
||||
|
@ -4010,7 +4010,7 @@ private:
|
|||
" else\n"
|
||||
" return false;\n"
|
||||
"}\n");
|
||||
ASSERT_EQUALS("[test.cpp:4]: (style) Comparison of a function returning boolean value using relational (<, >, <= or >=) operator.\n", errout.str());
|
||||
TODO_ASSERT_EQUALS("[test.cpp:4]: (style) Comparison of a function returning boolean value using relational (<, >, <= or >=) operator.\n", "", errout.str());
|
||||
}
|
||||
|
||||
void checkComparisonOfFuncReturningBool3() {
|
||||
|
@ -4027,7 +4027,7 @@ private:
|
|||
" else\n"
|
||||
" return false;\n"
|
||||
"}\n");
|
||||
ASSERT_EQUALS("[test.cpp:3]: (style) Comparison of a function returning boolean value using relational (<, >, <= or >=) operator.\n", errout.str());
|
||||
TODO_ASSERT_EQUALS("[test.cpp:3]: (style) Comparison of a function returning boolean value using relational (<, >, <= or >=) operator.\n", "", errout.str());
|
||||
}
|
||||
|
||||
void checkComparisonOfFuncReturningBool4() {
|
||||
|
@ -4052,7 +4052,7 @@ private:
|
|||
" else\n"
|
||||
" return false;\n"
|
||||
"}\n");
|
||||
ASSERT_EQUALS("[test.cpp:4]: (style) Comparison of a function returning boolean value using relational (<, >, <= or >=) operator.\n", errout.str());
|
||||
TODO_ASSERT_EQUALS("[test.cpp:4]: (style) Comparison of a function returning boolean value using relational (<, >, <= or >=) operator.\n", "", errout.str());
|
||||
}
|
||||
|
||||
void checkComparisonOfFuncReturningBool5() {
|
||||
|
@ -4076,7 +4076,7 @@ private:
|
|||
" else\n"
|
||||
" return true;\n"
|
||||
"}\n");
|
||||
ASSERT_EQUALS("[test.cpp:3]: (style) Comparison of two functions returning boolean value using relational (<, >, <= or >=) operator.\n", errout.str());
|
||||
TODO_ASSERT_EQUALS("[test.cpp:3]: (style) Comparison of two functions returning boolean value using relational (<, >, <= or >=) operator.\n", "", errout.str());
|
||||
}
|
||||
|
||||
void checkComparisonOfBoolWithBool() {
|
||||
|
|
Loading…
Reference in New Issue