]> granicus.if.org Git - clang/commitdiff
Let StoreManager do different cast on arrays. BasicStore will just keep it intact.
authorZhongxing Xu <xuzhongxing@gmail.com>
Thu, 23 Oct 2008 03:10:39 +0000 (03:10 +0000)
committerZhongxing Xu <xuzhongxing@gmail.com>
Thu, 23 Oct 2008 03:10:39 +0000 (03:10 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@58028 91177308-0d34-0410-b5e6-96231b3b80d8

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

index 87c180db551f9cc9c5b2a3c8ba077cfc9a2e3f2f..95a439e636d38524ea567f9a6b5000c183ee3df2 100644 (file)
@@ -405,6 +405,10 @@ public:
     
     return SetSVal(St, Ex, V, isBlkExpr, Invalidate);
   }
+
+  SVal ArrayToPointer(SVal Array) {
+    return StoreMgr->ArrayToPointer(Array);
+  }
   
   // Methods that manipulate the GDM.
   const GRState* addGDM(const GRState* St, void* Key, void* Data);
index 5a93e0e5ea034038f3513f3406edfcd11fee5161..f4f0415863494253b74fe27c286f8d5023297131 100644 (file)
@@ -61,6 +61,7 @@ public:
   virtual SVal getLValueElement(const GRState* St, 
                                    SVal Base, SVal Offset) = 0;
   
+  virtual SVal ArrayToPointer(SVal Array) = 0;
 
   virtual Store
   RemoveDeadBindings(Store store, Stmt* Loc, const LiveVariables& Live,
index cdecb1931943bb03eb08f6b64749db709df8fc5e..70631ac5bf1296d0e276e77539191ed4c68f3d21 100644 (file)
@@ -51,6 +51,8 @@ public:
   SVal getLValueIvar(const GRState* St, const ObjCIvarDecl* D, SVal Base);
   SVal getLValueField(const GRState* St, SVal Base, const FieldDecl* D);  
   SVal getLValueElement(const GRState* St, SVal Base, SVal Offset);
+
+  SVal ArrayToPointer(SVal Array) { return Array; }
   
   virtual Store
   RemoveDeadBindings(Store store, Stmt* Loc, const LiveVariables& Live,
index ae474bef61e074ae752d2aa990c12ddfe40ece3f..4d771fb366f93e0c90628156f9760399b83ce29f 100644 (file)
@@ -1503,9 +1503,15 @@ void GRExprEngine::VisitCast(Expr* CastE, Expr* Ex, NodeTy* Pred, NodeSet& Dst){
         MakeNode(Dst, CastE, N, SetSVal(St, CastE, V));
         continue;
       }
-    
+
+    // StoreManager casts array to different values.
+    if (ExTy->isArrayType()) {
+      V = StateMgr.ArrayToPointer(V);
+      MakeNode(Dst, CastE, N, SetSVal(St, CastE, V));
+      continue;
+    }
+
     // All other cases.
-    
     MakeNode(Dst, CastE, N, SetSVal(St, CastE, EvalCast(V, CastE->getType())));
   }
 }