]> granicus.if.org Git - clang/commitdiff
Since now we store the cast type with an ElementRegion, there is
authorZhongxing Xu <xuzhongxing@gmail.com>
Mon, 1 Mar 2010 06:56:52 +0000 (06:56 +0000)
committerZhongxing Xu <xuzhongxing@gmail.com>
Mon, 1 Mar 2010 06:56:52 +0000 (06:56 +0000)
no need to store a type with SymbolRegionValue.

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

include/clang/Checker/PathSensitive/SymbolManager.h
include/clang/Checker/PathSensitive/ValueManager.h
lib/Checker/BasicStore.cpp
lib/Checker/FlatStore.cpp
lib/Checker/RegionStore.cpp
lib/Checker/SymbolManager.cpp
lib/Checker/ValueManager.cpp

index 248937137da2e9a3376fead6c106cf4b235315d2..d49f5e81c802d3ff0af2d52b66d9d1e32d5a50df 100644 (file)
@@ -91,26 +91,21 @@ typedef const SymbolData* SymbolRef;
 
 // A symbol representing the value of a MemRegion.
 class SymbolRegionValue : public SymbolData {
-  const MemRegion *R;
-  // We may cast the region to another type, so the expected type of the symbol
-  // may be different from the region's original type.
-  QualType T;
+  const TypedRegion *R;
 
 public:
-  SymbolRegionValue(SymbolID sym, const MemRegion *r, QualType t = QualType())
-    : SymbolData(RegionValueKind, sym), R(r), T(t) {}
+  SymbolRegionValue(SymbolID sym, const TypedRegion *r)
+    : SymbolData(RegionValueKind, sym), R(r) {}
 
-  const MemRegion* getRegion() const { return R; }
+  const TypedRegion* getRegion() const { return R; }
 
-  static void Profile(llvm::FoldingSetNodeID& profile, const MemRegion* R,
-                     QualType T) {
+  static void Profile(llvm::FoldingSetNodeID& profile, const TypedRegion* R) {
     profile.AddInteger((unsigned) RegionValueKind);
     profile.AddPointer(R);
-    T.Profile(profile);
   }
 
   virtual void Profile(llvm::FoldingSetNodeID& profile) {
-    Profile(profile, R, T);
+    Profile(profile, R);
   }
 
   void dumpToStream(llvm::raw_ostream &os) const;
@@ -298,8 +293,8 @@ public:
   static bool canSymbolicate(QualType T);
 
   /// Make a unique symbol for MemRegion R according to its kind.
-  const SymbolRegionValue* getRegionValueSymbol(const MemRegion* R,
-                                               QualType T = QualType());
+  const SymbolRegionValue* getRegionValueSymbol(const TypedRegion* R);
+
   const SymbolConjured* getConjuredSymbol(const Stmt* E, QualType T,
                                           unsigned VisitCount,
                                           const void* SymbolTag = 0);
index ea3af57ed3e4bd543362c5f89d4bddc0e27a18c9..f80ad421742fa49492dfd7d0067e8ab3c766b04e 100644 (file)
@@ -94,8 +94,7 @@ public:
   DefinedOrUnknownSVal makeZeroVal(QualType T);
 
   /// getRegionValueSymbolVal - make a unique symbol for value of R.
-  DefinedOrUnknownSVal getRegionValueSymbolVal(const MemRegion *R,
-                                               QualType T = QualType());
+  DefinedOrUnknownSVal getRegionValueSymbolVal(const TypedRegion *R);
 
   DefinedOrUnknownSVal getConjuredSymbolVal(const void *SymbolTag,
                                             const Expr *E, unsigned Count);
index 6ef29429f681d9f48acc401543204be62cdeba4a..3661ae18fab321385bca51e96cbd4336861ca60d 100644 (file)
@@ -319,7 +319,7 @@ Store BasicStoreManager::scanForIvars(Stmt *B, const Decl* SelfDecl,
       const Expr *Base = IV->getBase()->IgnoreParenCasts();
       if (const DeclRefExpr *DR = dyn_cast<DeclRefExpr>(Base)) {
         if (DR->getDecl() == SelfDecl) {
-          const MemRegion *IVR = MRMgr.getObjCIvarRegion(IV->getDecl(),
+          const ObjCIvarRegion *IVR = MRMgr.getObjCIvarRegion(IV->getDecl(),
                                                          SelfRegion);
           SVal X = ValMgr.getRegionValueSymbolVal(IVR);
           St = Bind(St, ValMgr.makeLoc(IVR), X);
@@ -351,7 +351,7 @@ Store BasicStoreManager::getInitialStore(const LocationContext *InitLoc) {
         if (MD->getSelfDecl() == PD) {
           // FIXME: Add type constraints (when they become available) to
           // SelfRegion?  (i.e., it implements MD->getClassInterface()).
-          const MemRegion *VR = MRMgr.getVarRegion(PD, InitLoc);
+          const VarRegion *VR = MRMgr.getVarRegion(PD, InitLoc);
           const MemRegion *SelfRegion =
             ValMgr.getRegionValueSymbolVal(VR).getAsRegion();          
           assert(SelfRegion);          
@@ -369,7 +369,7 @@ Store BasicStoreManager::getInitialStore(const LocationContext *InitLoc) {
 
       // Initialize globals and parameters to symbolic values.
       // Initialize local variables to undefined.
-      const MemRegion *R = ValMgr.getRegionManager().getVarRegion(VD, InitLoc);
+      const VarRegion *R = ValMgr.getRegionManager().getVarRegion(VD, InitLoc);
       SVal X = UndefinedVal();
       if (R->hasGlobalsOrParametersStorage())
         X = ValMgr.getRegionValueSymbolVal(R);
index dac66def5dc96259b7063cf1935088786d78b1af..07a54fb487369cbb560dd3878cb4eb4fcf8627f3 100644 (file)
@@ -97,7 +97,7 @@ SVal FlatStoreManager::RetrieveRegionWithNoBinding(const MemRegion *R,
   if (R->hasStackNonParametersStorage())
     return UndefinedVal();
   else
-    return ValMgr.getRegionValueSymbolVal(R, T);
+    return ValMgr.getRegionValueSymbolVal(cast<TypedRegion>(R));
 }
 
 Store FlatStoreManager::Bind(Store store, Loc L, SVal val) {
index 94decd3d99c0683bba40811aeaba54bfba908736..fd48f72dd4ae17eb6415b1e0c16599b3e064fd55 100644 (file)
@@ -1070,7 +1070,7 @@ SVal RegionStoreManager::Retrieve(Store store, Loc L, QualType T) {
   }
 
   // All other values are symbolic.
-  return ValMgr.getRegionValueSymbolVal(R, RTy);
+  return ValMgr.getRegionValueSymbolVal(R);
 }
 
 std::pair<Store, const MemRegion *>
@@ -1231,7 +1231,7 @@ SVal RegionStoreManager::RetrieveFieldOrElementCommon(Store store,
   }
 
   // All other values are symbolic.
-  return ValMgr.getRegionValueSymbolVal(R, Ty);
+  return ValMgr.getRegionValueSymbolVal(R);
 }
 
 SVal RegionStoreManager::RetrieveObjCIvar(Store store, const ObjCIvarRegion* R){
@@ -1271,11 +1271,11 @@ SVal RegionStoreManager::RetrieveVar(Store store, const VarRegion *R) {
   
   if (isa<UnknownSpaceRegion>(MS) || 
       isa<StackArgumentsSpaceRegion>(MS))
-    return ValMgr.getRegionValueSymbolVal(R, T);
+    return ValMgr.getRegionValueSymbolVal(R);
 
   if (isa<GlobalsSpaceRegion>(MS)) {
     if (VD->isFileVarDecl())
-      return ValMgr.getRegionValueSymbolVal(R, T);
+      return ValMgr.getRegionValueSymbolVal(R);
 
     if (T->isIntegerType())
       return ValMgr.makeIntVal(0, T);
@@ -1293,7 +1293,7 @@ SVal RegionStoreManager::RetrieveLazySymbol(const TypedRegion *R) {
   QualType valTy = R->getValueType(getContext());
 
   // All other values are symbolic.
-  return ValMgr.getRegionValueSymbolVal(R, valTy);
+  return ValMgr.getRegionValueSymbolVal(R);
 }
 
 SVal RegionStoreManager::RetrieveStruct(Store store, const TypedRegion* R) {
index 7278b4189c2a2e7fbfac09a31d5140d807f18c06..f2d630cdf64b192923c1b38c5d1a938d79ca825b 100644 (file)
@@ -79,14 +79,14 @@ void SymbolRegionValue::dumpToStream(llvm::raw_ostream& os) const {
 }
 
 const SymbolRegionValue*
-SymbolManager::getRegionValueSymbol(const MemRegion* R, QualType T) {
+SymbolManager::getRegionValueSymbol(const TypedRegion* R) {
   llvm::FoldingSetNodeID profile;
-  SymbolRegionValue::Profile(profile, R, T);
+  SymbolRegionValue::Profile(profile, R);
   void* InsertPos;
   SymExpr *SD = DataSet.FindNodeOrInsertPos(profile, InsertPos);
   if (!SD) {
     SD = (SymExpr*) BPAlloc.Allocate<SymbolRegionValue>();
-    new (SD) SymbolRegionValue(SymbolCounter, R, T);
+    new (SD) SymbolRegionValue(SymbolCounter, R);
     DataSet.InsertNode(SD, InsertPos);
     ++SymbolCounter;
   }
@@ -176,13 +176,7 @@ QualType SymbolDerived::getType(ASTContext& Ctx) const {
 }
 
 QualType SymbolRegionValue::getType(ASTContext& C) const {
-  if (!T.isNull())
-    return T;
-
-  if (const TypedRegion* TR = dyn_cast<TypedRegion>(R))
-    return TR->getValueType(C);
-
-  return QualType();
+  return R->getValueType(C);
 }
 
 SymbolManager::~SymbolManager() {}
index 5359489a2299bef805a1e6ee5b45188ced2bd385..aa0c3c877dde1c3f91d6e0355c3fb18181b781f3 100644 (file)
@@ -70,18 +70,14 @@ SVal ValueManager::convertToArrayIndex(SVal V) {
   return SVator->EvalCastNL(cast<NonLoc>(V), ArrayIndexTy);
 }
 
-DefinedOrUnknownSVal ValueManager::getRegionValueSymbolVal(const MemRegion* R,
-                                                           QualType T) {
-
-  if (T.isNull()) {
-    const TypedRegion* TR = cast<TypedRegion>(R);
-    T = TR->getValueType(SymMgr.getContext());
-  }
+DefinedOrUnknownSVal 
+ValueManager::getRegionValueSymbolVal(const TypedRegion* R) {
+  QualType T = R->getValueType(SymMgr.getContext());
 
   if (!SymbolManager::canSymbolicate(T))
     return UnknownVal();
 
-  SymbolRef sym = SymMgr.getRegionValueSymbol(R, T);
+  SymbolRef sym = SymMgr.getRegionValueSymbol(R);
 
   if (Loc::IsLocType(T))
     return loc::MemRegionVal(MemMgr.getSymbolicRegion(sym));