Implement FIXME in GRExprEngine::VisitUnaryOperator() to handle implicit conversions caused by the '!' operator. This required adding some logic to GRSimpleVals to reason about nonloc::LocAsInteger SVals. This code appears to work fine, but it should eventually be cleaned up.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@59335 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Analysis/GRExprEngine.cpp b/lib/Analysis/GRExprEngine.cpp
index 6b53f1e..137a31e 100644
--- a/lib/Analysis/GRExprEngine.cpp
+++ b/lib/Analysis/GRExprEngine.cpp
@@ -2044,10 +2044,16 @@
// Get the value of the subexpression.
SVal V = GetSVal(St, Ex);
- // Perform promotions.
- // FIXME: This is the right thing to do, but it currently breaks
- // a bunch of tests.
- // V = EvalCast(V, U->getType());
+ if (V.isUnknownOrUndef()) {
+ MakeNode(Dst, U, *I, BindExpr(St, U, V));
+ continue;
+ }
+
+ QualType DstT = getContext().getCanonicalType(U->getType());
+ QualType SrcT = getContext().getCanonicalType(Ex->getType());
+
+ if (DstT != SrcT) // Perform promotions.
+ V = EvalCast(V, DstT);
if (V.isUnknownOrUndef()) {
MakeNode(Dst, U, *I, BindExpr(St, U, V));
@@ -2551,7 +2557,7 @@
NonLoc L, NonLoc R) {
GRStateSet::AutoPopulate AP(OStates, St);
- if (R.isValid()) getTF().EvalBinOpNN(OStates, StateMgr, St, Ex, Op, L, R);
+ if (R.isValid()) getTF().EvalBinOpNN(OStates, *this, St, Ex, Op, L, R);
}
//===----------------------------------------------------------------------===//