Fix issue 9859: false positive: knownConditionTrueFalse (#2759)
This commit is contained in:
parent
262d37fb47
commit
82bdbcd73b
|
@ -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;
|
||||
|
|
|
@ -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() {
|
||||
|
|
Loading…
Reference in New Issue