Skip to content

Commit dccebb9

Browse files
committed
Removed missingReturn inconclusive warnings, that was too noisy
1 parent 4296859 commit dccebb9

3 files changed

Lines changed: 4 additions & 20 deletions

File tree

lib/checkfunctions.cpp

Lines changed: 3 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,6 @@ static const Token *checkMissingReturnScope(const Token *tok, const Library &lib
252252

253253
void CheckFunctions::checkMissingReturn()
254254
{
255-
const bool inconclusive = mSettings->certainty.isEnabled(Certainty::inconclusive);
256255
const SymbolDatabase *symbolDatabase = mTokenizer->getSymbolDatabase();
257256
for (const Scope *scope : symbolDatabase->functionScopes) {
258257
const Function *function = scope->function;
@@ -267,20 +266,8 @@ void CheckFunctions::checkMissingReturn()
267266
if (Function::returnsVoid(function, true))
268267
continue;
269268
const Token *errorToken = checkMissingReturnScope(scope->bodyEnd, mSettings->library);
270-
if (errorToken) {
269+
if (errorToken)
271270
missingReturnError(errorToken);
272-
continue;
273-
}
274-
if (inconclusive && Token::simpleMatch(scope->bodyEnd->tokAt(-2), ") ; }")) {
275-
const Token *ftok = scope->bodyEnd->linkAt(-2)->previous();
276-
if (mSettings->library.isNotLibraryFunction(ftok)) {
277-
const Token *tok = ftok;
278-
while (Token::Match(tok->tokAt(-2), "%name% :: %name%"))
279-
tok = tok->tokAt(-2);
280-
if (Token::Match(tok->previous(), "[;{}] %name% (|::") && !tok->isKeyword())
281-
missingReturnError(tok, Certainty::inconclusive);
282-
}
283-
}
284271
}
285272
}
286273

@@ -366,10 +353,10 @@ static const Token *checkMissingReturnScope(const Token *tok, const Library &lib
366353
return nullptr;
367354
}
368355

369-
void CheckFunctions::missingReturnError(const Token* tok, Certainty::CertaintyLevel certainty)
356+
void CheckFunctions::missingReturnError(const Token* tok)
370357
{
371358
reportError(tok, Severity::error, "missingReturn",
372-
"Found a exit path from function with non-void return type that has missing return statement", CWE758, certainty);
359+
"Found a exit path from function with non-void return type that has missing return statement", CWE758, Certainty::normal);
373360
}
374361
//---------------------------------------------------------------------------
375362
// Detect passing wrong values to <cmath> functions like atan(0, x);

lib/checkfunctions.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ class CPPCHECKLIB CheckFunctions : public Check {
120120
void memsetZeroBytesError(const Token *tok);
121121
void memsetFloatError(const Token *tok, const std::string &var_value);
122122
void memsetValueOutOfRangeError(const Token *tok, const std::string &value);
123-
void missingReturnError(const Token *tok, Certainty::CertaintyLevel certainty=Certainty::normal);
123+
void missingReturnError(const Token *tok);
124124
void copyElisionError(const Token *tok);
125125

126126
void getErrorMessages(ErrorLogger *errorLogger, const Settings *settings) const OVERRIDE {

test/testfunctions.cpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1493,9 +1493,6 @@ class TestFunctions : public TestFixture {
14931493

14941494
check("int f(int x) { assert(0); }");
14951495
ASSERT_EQUALS("", errout.str());
1496-
1497-
check("int f(int x) { RETURN(0); }");
1498-
ASSERT_EQUALS("[test.cpp:1]: (error, inconclusive) Found a exit path from function with non-void return type that has missing return statement\n", errout.str());
14991496
}
15001497

15011498
// NRVO check

0 commit comments

Comments
 (0)