Fix issue 9859: false positive: knownConditionTrueFalse (#2759)

This commit is contained in:
Paul Fultz II 2020-08-28 12:26:09 -05:00 committed by GitHub
parent 262d37fb47
commit 82bdbcd73b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 1 deletions

View File

@ -2574,7 +2574,7 @@ struct SingleValueFlowForwardAnalyzer : ValueFlowForwardAnalyzer {
virtual bool isGlobal() const OVERRIDE {
for (const auto&p:getVars()) {
const Variable* var = p.second;
if (var->isGlobal() && !var->isConst())
if (!var->isLocal() && !var->isArgument() && !var->isConst())
return true;
}
return false;

View File

@ -3588,6 +3588,17 @@ private:
" return;\n"
"}\n");
ASSERT_EQUALS("", errout.str());
check("struct A {\n"
" std::vector<int> v;\n"
" void g();\n"
" void f(bool b) {\n"
" v.clear();\n"
" g();\n"
" return !v.empty();\n"
" }\n"
"};\n");
ASSERT_EQUALS("", errout.str());
}
void multiConditionAlwaysTrue() {