Add transfer function support for ObjCIvarRefExpr.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@57654 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Analysis/BasicStore.cpp b/lib/Analysis/BasicStore.cpp
index f97f8b2..15a20c8 100644
--- a/lib/Analysis/BasicStore.cpp
+++ b/lib/Analysis/BasicStore.cpp
@@ -48,6 +48,7 @@
}
virtual RVal getLValue(const GRState* St, const Expr* Ex);
+ virtual RVal getLValue(const GRState* St, const ObjCIvarDecl* D, RVal Base);
virtual Store
RemoveDeadBindings(Store store, Stmt* Loc, const LiveVariables& Live,
@@ -154,6 +155,11 @@
return UnknownVal();
}
+RVal BasicStoreManager::getLValue(const GRState* St, const ObjCIvarDecl* D,
+ RVal Base) {
+ return UnknownVal();
+}
+
Store BasicStoreManager::SetRVal(Store store, LVal LV, RVal V) {
switch (LV.getSubKind()) {
case lval::MemRegionKind: {
diff --git a/lib/Analysis/GRExprEngine.cpp b/lib/Analysis/GRExprEngine.cpp
index 2d24134..f974dfc 100644
--- a/lib/Analysis/GRExprEngine.cpp
+++ b/lib/Analysis/GRExprEngine.cpp
@@ -350,10 +350,13 @@
break;
}
- case Stmt::MemberExprClass: {
+ case Stmt::MemberExprClass:
VisitMemberExpr(cast<MemberExpr>(S), Pred, Dst, false);
break;
- }
+
+ case Stmt::ObjCIvarRefExprClass:
+ VisitObjCIvarRefExpr(cast<ObjCIvarRefExpr>(S), Pred, Dst, false);
+ break;
case Stmt::ObjCMessageExprClass: {
VisitObjCMessageExpr(cast<ObjCMessageExpr>(S), Pred, Dst);
@@ -417,6 +420,10 @@
VisitDeclRefExpr(cast<DeclRefExpr>(Ex), Pred, Dst, true);
return;
+ case Stmt::ObjCIvarRefExprClass:
+ VisitObjCIvarRefExpr(cast<ObjCIvarRefExpr>(Ex), Pred, Dst, true);
+ return;
+
case Stmt::UnaryOperatorClass:
VisitUnaryOperator(cast<UnaryOperator>(Ex), Pred, Dst, true);
return;
@@ -1223,6 +1230,30 @@
}
//===----------------------------------------------------------------------===//
+// Transfer function: Objective-C ivar references.
+//===----------------------------------------------------------------------===//
+
+void GRExprEngine::VisitObjCIvarRefExpr(ObjCIvarRefExpr* Ex,
+ NodeTy* Pred, NodeSet& Dst,
+ bool asLValue) {
+
+ Expr* Base = cast<Expr>(Ex->getBase());
+ NodeSet Tmp;
+ Visit(Base, Pred, Tmp);
+
+ for (NodeSet::iterator I=Tmp.begin(), E=Tmp.end(); I!=E; ++I) {
+ const GRState* St = GetState(*I);
+ RVal BaseVal = GetRVal(St, Base);
+ RVal location = StateMgr.GetLValue(St, Ex->getDecl(), BaseVal);
+
+ if (asLValue)
+ MakeNode(Dst, Ex, *I, SetRVal(St, Ex, location));
+ else
+ EvalLoad(Dst, Ex, *I, St, location);
+ }
+}
+
+//===----------------------------------------------------------------------===//
// Transfer function: Objective-C message expressions.
//===----------------------------------------------------------------------===//