Added lval::FieldOffset, which represents symbolic lvalues for field offsets from other Lvalues.
This removes the failure in null-deref-ps.c (test suite).
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@50449 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Analysis/GRExprEngine.cpp b/lib/Analysis/GRExprEngine.cpp
index 2353058..a4f1a05 100644
--- a/lib/Analysis/GRExprEngine.cpp
+++ b/lib/Analysis/GRExprEngine.cpp
@@ -856,16 +856,12 @@
// This is a redunant copy; we do this as a placeholder for future logic.
for (NodeSet::iterator I=Tmp.begin(), E=Tmp.end(); I!=E; ++I) {
ValueState* St = GetState(*I);
- RVal V = GetRVal(St, Base);
+ RVal BaseV = GetRVal(St, Base);
- // TODO: Compute the LVal for the field. This will enable field
- // sensitivity for the analysis.
+ RVal V = lval::FieldOffset::Make(BasicVals, GetRVal(St, Base),
+ M->getMemberDecl());
- if (!(V.isUndef() || V.isUnknown() || isa<lval::ConcreteInt>(V)))
- V = UnknownVal();
-
- MakeNode(Dst, M, *I, SetRVal(St, M, V));
-
+ MakeNode(Dst, M, *I, SetRVal(St, M, V));
}
return;
@@ -879,13 +875,8 @@
for (NodeSet::iterator I=Tmp.begin(), E=Tmp.end(); I!=E; ++I) {
ValueState* St = GetState(*I);
- RVal V = GetRVal(St, Base);
-
- // TODO: Compute the LVal for the field. This will enable field
- // sensitivity for the analysis.
-
- if (!(V.isUndef() || V.isUnknown() || isa<lval::ConcreteInt>(V)))
- V = UnknownVal();
+ RVal V = lval::FieldOffset::Make(BasicVals, GetRVal(St, Base),
+ M->getMemberDecl());
EvalLoad(Dst, M, *I, St, V, true);
}
@@ -2034,7 +2025,11 @@
case lval::StringLiteralValKind:
isFeasible = Assumption;
return St;
-
+
+ case lval::FieldOffsetKind:
+ return AssumeAux(St, cast<lval::FieldOffset>(Cond).getBase(),
+ Assumption, isFeasible);
+
case lval::ConcreteIntKind: {
bool b = cast<lval::ConcreteInt>(Cond).getValue() != 0;
isFeasible = b ? Assumption : !Assumption;