Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions gui/statsdialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ void StatsDialog::setProject(const ProjectFile* projectFile)
if (!statsFile.isEmpty()) {
QChartView *chartView = createChart(statsFile, "cppcheck");
mUI->mTabHistory->layout()->addWidget(chartView);
// cppcheck-suppress knownConditionTrueFalse - TODO in getClangAnalyzer()
if (projectFile->getClangAnalyzer()) {
chartView = createChart(statsFile, CLANG_ANALYZER);
mUI->mTabHistory->layout()->addWidget(chartView);
Expand Down
5 changes: 0 additions & 5 deletions lib/checkcondition.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1524,11 +1524,6 @@ void CheckCondition::alwaysTrueFalse()
}
if (!tok->hasKnownIntValue())
continue;
if (Token::Match(tok->previous(), "%name% (") && tok->previous()->function()) {
const Function* f = tok->previous()->function();
if (f->functionScope && Token::Match(f->functionScope->bodyStart, "{ return true|false ;"))
continue;
}
const Token* condition = nullptr;
{
// is this a condition..
Expand Down
9 changes: 9 additions & 0 deletions test/testcondition.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4846,6 +4846,15 @@ class TestCondition : public TestFixture {
"}\n");
ASSERT_EQUALS("[test.cpp:6:9] -> [test.cpp:9:9]: (warning) Identical condition 'a', second condition is always false [identicalConditionAfterEarlyExit]\n",
errout_str());

check("bool b() { return false; }\n" // #10452
"void f() {\n"
" if (b()) {}\n"
" if (!b()) {}\n"
"}\n");
ASSERT_EQUALS("[test.cpp:3:10]: (style) Condition 'b()' is always false [knownConditionTrueFalse]\n"
"[test.cpp:4:9]: (style) Condition '!b()' is always true [knownConditionTrueFalse]\n",
errout_str());
}

void alwaysTrueSymbolic()
Expand Down
Loading