[cfe-commits] r58028 - in /cfe/trunk: include/clang/Analysis/PathSensitive/GRState.h include/clang/Analysis/PathSensitive/Store.h lib/Analysis/BasicStore.cpp lib/Analysis/GRExprEngine.cpp

Zhongxing Xu xuzhongxing at gmail.com
Wed Oct 22 20:10:42 PDT 2008


Author: zhongxingxu
Date: Wed Oct 22 22:10:39 2008
New Revision: 58028

URL: http://llvm.org/viewvc/llvm-project?rev=58028&view=rev
Log:
Let StoreManager do different cast on arrays. BasicStore will just keep it intact.

Modified:
    cfe/trunk/include/clang/Analysis/PathSensitive/GRState.h
    cfe/trunk/include/clang/Analysis/PathSensitive/Store.h
    cfe/trunk/lib/Analysis/BasicStore.cpp
    cfe/trunk/lib/Analysis/GRExprEngine.cpp

Modified: cfe/trunk/include/clang/Analysis/PathSensitive/GRState.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Analysis/PathSensitive/GRState.h?rev=58028&r1=58027&r2=58028&view=diff

==============================================================================
--- cfe/trunk/include/clang/Analysis/PathSensitive/GRState.h (original)
+++ cfe/trunk/include/clang/Analysis/PathSensitive/GRState.h Wed Oct 22 22:10:39 2008
@@ -405,6 +405,10 @@
     
     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);

Modified: cfe/trunk/include/clang/Analysis/PathSensitive/Store.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Analysis/PathSensitive/Store.h?rev=58028&r1=58027&r2=58028&view=diff

==============================================================================
--- cfe/trunk/include/clang/Analysis/PathSensitive/Store.h (original)
+++ cfe/trunk/include/clang/Analysis/PathSensitive/Store.h Wed Oct 22 22:10:39 2008
@@ -61,6 +61,7 @@
   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,

Modified: cfe/trunk/lib/Analysis/BasicStore.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Analysis/BasicStore.cpp?rev=58028&r1=58027&r2=58028&view=diff

==============================================================================
--- cfe/trunk/lib/Analysis/BasicStore.cpp (original)
+++ cfe/trunk/lib/Analysis/BasicStore.cpp Wed Oct 22 22:10:39 2008
@@ -51,6 +51,8 @@
   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,

Modified: cfe/trunk/lib/Analysis/GRExprEngine.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Analysis/GRExprEngine.cpp?rev=58028&r1=58027&r2=58028&view=diff

==============================================================================
--- cfe/trunk/lib/Analysis/GRExprEngine.cpp (original)
+++ cfe/trunk/lib/Analysis/GRExprEngine.cpp Wed Oct 22 22:10:39 2008
@@ -1503,9 +1503,15 @@
         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())));
   }
 }





More information about the cfe-commits mailing list