From c1bef5671e682de5a573c7c6b66871b36de0ec61 Mon Sep 17 00:00:00 2001 From: Anna Zaks Date: Wed, 3 Apr 2013 19:28:12 +0000 Subject: [analyzer] Properly handle the ternary operator in trackNullOrUndefValue MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 1) Look for the node where the condition expression is live when checking if it is constrained to true or false. 2) Fix a bug in ProgramState::isNull, which was masking the problem. When the expression is not a symbol (,which is the case when it is Unknown) return unconstrained value, instead of value constrained to “false”! (Thankfully other callers of isNull have not been effected by the bug.) git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@178684 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/StaticAnalyzer/Core/ProgramState.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'lib/StaticAnalyzer/Core/ProgramState.cpp') diff --git a/lib/StaticAnalyzer/Core/ProgramState.cpp b/lib/StaticAnalyzer/Core/ProgramState.cpp index f3e80f19c9..bff2242925 100644 --- a/lib/StaticAnalyzer/Core/ProgramState.cpp +++ b/lib/StaticAnalyzer/Core/ProgramState.cpp @@ -380,9 +380,13 @@ ConditionTruthVal ProgramState::isNull(SVal V) const { if (V.isZeroConstant()) return true; + if (V.isConstant()) + return false; + SymbolRef Sym = V.getAsSymbol(); if (!Sym) - return false; + return ConditionTruthVal(); + return getStateManager().ConstraintMgr->isNull(this, Sym); } -- cgit v1.2.3