Fix 11100: FP knownConditionTrueFalse with getter/setter member functions (#4198)

* Fix 11100: FP knownConditionTrueFalse with getter/setter member functions

* Format
This commit is contained in:
Paul Fultz II 2022-06-11 04:00:40 -05:00 committed by GitHub
parent 82af702c6f
commit 653a1ea83e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 17 additions and 1 deletions

View File

@ -2926,8 +2926,10 @@ struct ExpressionAnalyzer : SingleValueFlowAnalyzer {
assert(e && e->exprId() != 0 && "Not a valid expression");
dependOnThis = exprDependsOnThis(expr);
setupExprVarIds(expr);
if (val.isSymbolicValue())
if (val.isSymbolicValue()) {
dependOnThis |= exprDependsOnThis(val.tokvalue);
setupExprVarIds(val.tokvalue);
}
}
static bool nonLocal(const Variable* var, bool deref) {

View File

@ -4483,6 +4483,20 @@ private:
"}");
ASSERT_EQUALS("", errout.str());
// #11100
check("struct T {\n"
" bool m{};\n"
" void f(bool b);\n"
" bool get() const { return m; }\n"
" void set(bool v) { m = v; }\n"
"};\n"
"void T::f(bool b) {\n"
" bool tmp = get();\n"
" set(b);\n"
" if (tmp != get()) {}\n"
"}\n");
ASSERT_EQUALS("", errout.str());
// #9541
check("int f(int pos, int a) {\n"
" if (pos <= 0)\n"