]> granicus.if.org Git - clang/commitdiff
Enhance modularization: return a <state,loc> pair to let GRExprEngine modify the
authorZhongxing Xu <xuzhongxing@gmail.com>
Sun, 16 Nov 2008 07:06:26 +0000 (07:06 +0000)
committerZhongxing Xu <xuzhongxing@gmail.com>
Sun, 16 Nov 2008 07:06:26 +0000 (07:06 +0000)
environment.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@59407 91177308-0d34-0410-b5e6-96231b3b80d8

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

index 06c49cb85cc4f4ba99e982b63277b1367ed6c3e7..e31b6d4ddcd45697c8cf59818a6fd1ca2b3e732e 100644 (file)
@@ -81,8 +81,8 @@ public:
   ///  conversions between arrays and pointers.
   virtual SVal ArrayToPointer(SVal Array) = 0;
 
-  virtual const GRState* CastRegion(const GRState* St, SVal VoidPtr, 
-                                    QualType CastToTy, Stmt* CastE) = 0;
+  virtual std::pair<const GRState*, SVal> 
+  CastRegion(const GRState* St, SVal VoidPtr, QualType CastToTy, Stmt* CastE)=0;
   
   /// getSelfRegion - Returns the region for the 'self' (Objective-C) or
   ///  'this' object (C++).  When used when analyzing a normal function this
index 8b5ef6ee865a1cc1035eb147354ea732628e4d3f..ae6febff7ba9a960aecb94f87d6ebb47e6b68302 100644 (file)
@@ -66,9 +66,9 @@ public:
   ///  conversions between arrays and pointers.
   SVal ArrayToPointer(SVal Array) { return Array; }
 
-  const GRState* CastRegion(const GRState* St, SVal VoidPtr, QualType CastToTy,
-                            Stmt* CastE) {
-    return St;
+  std::pair<const GRState*, SVal> 
+  CastRegion(const GRState* St, SVal VoidPtr, QualType CastToTy, Stmt* CastE) {
+    return std::pair<const GRState*, SVal>(St, UnknownVal());
   }
 
   
index e002c1363722c4e9336b29459466f49445dbbe57..fe7d6f942664558044b44db55f4844f9b6a46e66 100644 (file)
@@ -1698,11 +1698,15 @@ void GRExprEngine::VisitCast(Expr* CastE, Expr* Ex, NodeTy* Pred, NodeSet& Dst){
       assert(Loc::IsLocType(ExTy));
 
       // Delegate to store manager.
-      const GRState* NewSt = getStoreManager().CastRegion(St, V, T, CastE);
+      std::pair<const GRState*, SVal> Res =  
+        getStoreManager().CastRegion(St, V, T, CastE);
+
+      const GRState* NewSt = Res.first;
+      SVal NewPtr = Res.second;
 
       // If no new region is created, fall through to the default case.
       if (NewSt != St) {
-        MakeNode(Dst, CastE, N, NewSt);
+        MakeNode(Dst, CastE, N, BindExpr(NewSt, CastE, NewPtr));
         continue;
       }
     }
index 732785c0f7201e678143728bd673352d7f8a1860..fab2e605383993dcc37a59e2ccae1677f4817460 100644 (file)
@@ -82,8 +82,8 @@ public:
 
   SVal ArrayToPointer(SVal Array);
 
-  const GRState* CastRegion(const GRState* St, SVal VoidPtr, 
-                            QualType CastToTy, Stmt* CastE);
+  std::pair<const GRState*, SVal>
+  CastRegion(const GRState* St, SVal VoidPtr, QualType CastToTy, Stmt* CastE);
 
   SVal Retrieve(Store S, Loc L, QualType T = QualType());
 
@@ -264,10 +264,9 @@ SVal RegionStoreManager::ArrayToPointer(SVal Array) {
   return loc::MemRegionVal(ER);                    
 }
 
-const GRState* RegionStoreManager::CastRegion(const GRState* St,
-                                              SVal VoidPtr, 
-                                              QualType CastToTy,
-                                              Stmt* CastE) {
+std::pair<const GRState*, SVal>
+RegionStoreManager::CastRegion(const GRState* St, SVal VoidPtr, 
+                               QualType CastToTy, Stmt* CastE) {
   if (const AllocaRegion* AR =
       dyn_cast<AllocaRegion>(cast<loc::MemRegionVal>(VoidPtr).getRegion())) {
 
@@ -278,14 +277,13 @@ const GRState* RegionStoreManager::CastRegion(const GRState* St,
     nonloc::ConcreteInt Idx(getBasicVals().getZeroWithPtrWidth(false));
     const ElementRegion* ER = MRMgr.getElementRegion(Idx, TR);
 
-    St = StateMgr.BindExpr(St, CastE, loc::MemRegionVal(ER));
-
     // Add a RegionView to base region.
-    return AddRegionView(St, TR, AR);
+    return std::pair<const GRState*, SVal>(AddRegionView(St, TR, AR), 
+                                           loc::MemRegionVal(ER));
   }
 
   // Default case.
-  return St;
+  return std::pair<const GRState*, SVal>(St, UnknownVal());
 }
 
 SVal RegionStoreManager::Retrieve(Store S, Loc L, QualType T) {