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:
parent
82af702c6f
commit
653a1ea83e
|
@ -2926,9 +2926,11 @@ struct ExpressionAnalyzer : SingleValueFlowAnalyzer {
|
||||||
assert(e && e->exprId() != 0 && "Not a valid expression");
|
assert(e && e->exprId() != 0 && "Not a valid expression");
|
||||||
dependOnThis = exprDependsOnThis(expr);
|
dependOnThis = exprDependsOnThis(expr);
|
||||||
setupExprVarIds(expr);
|
setupExprVarIds(expr);
|
||||||
if (val.isSymbolicValue())
|
if (val.isSymbolicValue()) {
|
||||||
|
dependOnThis |= exprDependsOnThis(val.tokvalue);
|
||||||
setupExprVarIds(val.tokvalue);
|
setupExprVarIds(val.tokvalue);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static bool nonLocal(const Variable* var, bool deref) {
|
static bool nonLocal(const Variable* var, bool deref) {
|
||||||
return !var || (!var->isLocal() && !var->isArgument()) || (deref && var->isArgument() && var->isPointer()) ||
|
return !var || (!var->isLocal() && !var->isArgument()) || (deref && var->isArgument() && var->isPointer()) ||
|
||||||
|
|
|
@ -4483,6 +4483,20 @@ private:
|
||||||
"}");
|
"}");
|
||||||
ASSERT_EQUALS("", errout.str());
|
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
|
// #9541
|
||||||
check("int f(int pos, int a) {\n"
|
check("int f(int pos, int a) {\n"
|
||||||
" if (pos <= 0)\n"
|
" if (pos <= 0)\n"
|
||||||
|
|
Loading…
Reference in New Issue