[cfe-commits] r97437 - in /cfe/trunk: 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

Zhongxing Xu xuzhongxing at gmail.com
Sun Feb 28 22:56:52 PST 2010


Author: zhongxingxu
Date: Mon Mar  1 00:56:52 2010
New Revision: 97437

URL: http://llvm.org/viewvc/llvm-project?rev=97437&view=rev
Log:
Since now we store the cast type with an ElementRegion, there is
no need to store a type with SymbolRegionValue.

Modified:
    cfe/trunk/include/clang/Checker/PathSensitive/SymbolManager.h
    cfe/trunk/include/clang/Checker/PathSensitive/ValueManager.h
    cfe/trunk/lib/Checker/BasicStore.cpp
    cfe/trunk/lib/Checker/FlatStore.cpp
    cfe/trunk/lib/Checker/RegionStore.cpp
    cfe/trunk/lib/Checker/SymbolManager.cpp
    cfe/trunk/lib/Checker/ValueManager.cpp

Modified: cfe/trunk/include/clang/Checker/PathSensitive/SymbolManager.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Checker/PathSensitive/SymbolManager.h?rev=97437&r1=97436&r2=97437&view=diff
==============================================================================
--- cfe/trunk/include/clang/Checker/PathSensitive/SymbolManager.h (original)
+++ cfe/trunk/include/clang/Checker/PathSensitive/SymbolManager.h Mon Mar  1 00:56:52 2010
@@ -91,26 +91,21 @@
 
 // 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 @@
   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);

Modified: cfe/trunk/include/clang/Checker/PathSensitive/ValueManager.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Checker/PathSensitive/ValueManager.h?rev=97437&r1=97436&r2=97437&view=diff
==============================================================================
--- cfe/trunk/include/clang/Checker/PathSensitive/ValueManager.h (original)
+++ cfe/trunk/include/clang/Checker/PathSensitive/ValueManager.h Mon Mar  1 00:56:52 2010
@@ -94,8 +94,7 @@
   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);

Modified: cfe/trunk/lib/Checker/BasicStore.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Checker/BasicStore.cpp?rev=97437&r1=97436&r2=97437&view=diff
==============================================================================
--- cfe/trunk/lib/Checker/BasicStore.cpp (original)
+++ cfe/trunk/lib/Checker/BasicStore.cpp Mon Mar  1 00:56:52 2010
@@ -319,7 +319,7 @@
       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 @@
         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 @@
 
       // 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);

Modified: cfe/trunk/lib/Checker/FlatStore.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Checker/FlatStore.cpp?rev=97437&r1=97436&r2=97437&view=diff
==============================================================================
--- cfe/trunk/lib/Checker/FlatStore.cpp (original)
+++ cfe/trunk/lib/Checker/FlatStore.cpp Mon Mar  1 00:56:52 2010
@@ -97,7 +97,7 @@
   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) {

Modified: cfe/trunk/lib/Checker/RegionStore.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Checker/RegionStore.cpp?rev=97437&r1=97436&r2=97437&view=diff
==============================================================================
--- cfe/trunk/lib/Checker/RegionStore.cpp (original)
+++ cfe/trunk/lib/Checker/RegionStore.cpp Mon Mar  1 00:56:52 2010
@@ -1070,7 +1070,7 @@
   }
 
   // All other values are symbolic.
-  return ValMgr.getRegionValueSymbolVal(R, RTy);
+  return ValMgr.getRegionValueSymbolVal(R);
 }
 
 std::pair<Store, const MemRegion *>
@@ -1231,7 +1231,7 @@
   }
 
   // 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 @@
   
   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 @@
   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) {

Modified: cfe/trunk/lib/Checker/SymbolManager.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Checker/SymbolManager.cpp?rev=97437&r1=97436&r2=97437&view=diff
==============================================================================
--- cfe/trunk/lib/Checker/SymbolManager.cpp (original)
+++ cfe/trunk/lib/Checker/SymbolManager.cpp Mon Mar  1 00:56:52 2010
@@ -79,14 +79,14 @@
 }
 
 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 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() {}

Modified: cfe/trunk/lib/Checker/ValueManager.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Checker/ValueManager.cpp?rev=97437&r1=97436&r2=97437&view=diff
==============================================================================
--- cfe/trunk/lib/Checker/ValueManager.cpp (original)
+++ cfe/trunk/lib/Checker/ValueManager.cpp Mon Mar  1 00:56:52 2010
@@ -70,18 +70,14 @@
   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));





More information about the cfe-commits mailing list