Fix 10645: FP knownEmptyContainer after conditional return (#3620)
This commit is contained in:
parent
f79bb40e3d
commit
cb2738a60c
|
@ -640,13 +640,13 @@ static ValueFlow::Value execute(const Token* expr, ProgramMemory& pm)
|
|||
if (rhs.isIntValue()) {
|
||||
std::vector<ValueFlow::Value> result =
|
||||
infer(makeIntegralInferModel(), expr->str(), expr->astOperand1()->values(), {rhs});
|
||||
if (result.empty())
|
||||
if (result.empty() || !result.front().isKnown())
|
||||
return unknown;
|
||||
return result.front();
|
||||
} else if (lhs.isIntValue()) {
|
||||
std::vector<ValueFlow::Value> result =
|
||||
infer(makeIntegralInferModel(), expr->str(), {lhs}, expr->astOperand2()->values());
|
||||
if (result.empty())
|
||||
if (result.empty() || !result.front().isKnown())
|
||||
return unknown;
|
||||
return result.front();
|
||||
}
|
||||
|
|
|
@ -5387,6 +5387,18 @@ private:
|
|||
"}\n",
|
||||
true);
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
|
||||
check("void f(const std::vector<int>& v, int e) {\n"
|
||||
" if (!v.empty()) {\n"
|
||||
" if (e < 0 || true) {\n"
|
||||
" if (e < 0)\n"
|
||||
" return;\n"
|
||||
" }\n"
|
||||
" }\n"
|
||||
" for (auto i : v) {}\n"
|
||||
"}\n",
|
||||
true);
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
|
||||
void checkMutexes() {
|
||||
|
|
Loading…
Reference in New Issue