]> granicus.if.org Git - clang/commitdiff
Add transfer function support for ObjCIvarRefExpr.
authorTed Kremenek <kremenek@apple.com>
Fri, 17 Oct 2008 00:03:18 +0000 (00:03 +0000)
committerTed Kremenek <kremenek@apple.com>
Fri, 17 Oct 2008 00:03:18 +0000 (00:03 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@57654 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/Analysis/PathSensitive/GRExprEngine.h
include/clang/Analysis/PathSensitive/GRState.h
include/clang/Analysis/PathSensitive/Store.h
lib/Analysis/BasicStore.cpp
lib/Analysis/GRExprEngine.cpp

index 8a4f9cd6c9eb853546b07dcb96b041c3f2567fe6..d1e25a5a664366c6e05b97553386197e1b60567e 100644 (file)
@@ -441,6 +441,8 @@ protected:
   }
 
   // Get the lvalue of an expression.
+  // FIXME: Remove this method, and used specialized versions of GetLValue
+  // in GRStateManager.
   RVal GetLValue(const GRState* St, const Expr* Ex) {
     return StateMgr.GetLValue(St, Ex);
   }
@@ -521,6 +523,10 @@ protected:
   /// VisitMemberExpr - Transfer function for member expressions.
   void VisitMemberExpr(MemberExpr* M, NodeTy* Pred, NodeSet& Dst,bool asLValue);
   
+  /// VisitObjCIvarRefExpr - Transfer function logic for ObjCIvarRefExprs.
+  void VisitObjCIvarRefExpr(ObjCIvarRefExpr* DR, NodeTy* Pred, NodeSet& Dst,
+                            bool asLValue); 
+  
   /// VisitObjCMessageExpr - Transfer function for ObjC message expressions.
   void VisitObjCMessageExpr(ObjCMessageExpr* ME, NodeTy* Pred, NodeSet& Dst);
   
index 130160c4ed4566a58396aef4f5d4626cb008da81..2ae671cec33912699a1b0053bf05daca3b4afe3f 100644 (file)
@@ -346,11 +346,17 @@ public:
   }
 
   // Get the lvalue of expression.
+  // FIXME: Remove this method, and implement specialized versions for
+  //  specific Decls.
   RVal GetLValue(const GRState* St, const Expr* Ex) {
     // Forward to store manager. The lvalue of an expression is determined by
     // the store manager.
     return StoreMgr->getLValue(St, Ex);
   }
+  
+  RVal GetLValue(const GRState* St, ObjCIvarDecl* D, RVal Base) {
+    return StoreMgr->getLValue(St, D, Base);
+  }
 
   // Methods that query & manipulate the Environment.
   
index b6c9c5d30295c799542a2e7966cca6b82833c6f7..c61b4820980af4127f3c909ae6edc3b71d54898f 100644 (file)
@@ -30,6 +30,7 @@ class GRStateManager;
 class LiveVariables;
 class Stmt;
 class Expr;
+class ObjCIvarDecl;
 class MemRegion;
 class MemRegionManager;
 
@@ -47,7 +48,12 @@ public:
   virtual LVal getLVal(const VarDecl* VD) = 0;  
 
   // Get the lvalue of an expression.
+  // FIXME: Remove this method, and implement specialized versions for
+  //  specific Decls.
   virtual RVal getLValue(const GRState* St, const Expr* Ex) = 0;
+  
+  virtual RVal getLValue(const GRState* St, const ObjCIvarDecl* D, RVal Base)=0;
+  
 
   virtual Store
   RemoveDeadBindings(Store store, Stmt* Loc, const LiveVariables& Live,
index f97f8b2c291a819c93dddf9e1b6eb08cc6d69d0e..15a20c843a0d4e63dd6ceae29469a384e0aca5dc 100644 (file)
@@ -48,6 +48,7 @@ public:
   }
 
   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 @@ RVal BasicStoreManager::GetRVal(Store St, LVal LV, QualType T) {
   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: {
index 2d241344af70cbe966404a50ffa53f7022b4dca0..f974dfc2c4805d7307fa7c655fd1623741f97630 100644 (file)
@@ -350,10 +350,13 @@ void GRExprEngine::Visit(Stmt* S, NodeTy* Pred, NodeSet& Dst) {
       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 @@ void GRExprEngine::VisitLValue(Expr* Ex, NodeTy* Pred, NodeSet& Dst) {
       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;
@@ -1222,6 +1229,30 @@ void GRExprEngine::VisitCall(CallExpr* CE, NodeTy* Pred,
   }
 }
 
+//===----------------------------------------------------------------------===//
+// 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.
 //===----------------------------------------------------------------------===//