[llvm-branch-commits] [cfe-branch] r71327 - /cfe/branches/Apple/Dib/lib/Analysis/RegionStore.cpp
Mike Stump
mrs at apple.com
Fri May 8 23:10:21 PDT 2009
Author: mrs
Date: Sat May 9 01:10:21 2009
New Revision: 71327
URL: http://llvm.org/viewvc/llvm-project?rev=71327&view=rev
Log:
Merge in 71076:
Add a GDM for recording the cast type of regions.
Modified:
cfe/branches/Apple/Dib/lib/Analysis/RegionStore.cpp
Modified: cfe/branches/Apple/Dib/lib/Analysis/RegionStore.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/Apple/Dib/lib/Analysis/RegionStore.cpp?rev=71327&r1=71326&r2=71327&view=diff
==============================================================================
--- cfe/branches/Apple/Dib/lib/Analysis/RegionStore.cpp (original)
+++ cfe/branches/Apple/Dib/lib/Analysis/RegionStore.cpp Sat May 9 01:10:21 2009
@@ -48,6 +48,17 @@
};
}
+// RegionCasts records the current cast type of a region.
+namespace { class VISIBILITY_HIDDEN RegionCasts {}; }
+static int RegionCastsIndex = 0;
+namespace clang {
+ template<> struct GRStateTrait<RegionCasts>
+ : public GRStatePartialTrait<llvm::ImmutableMap<const MemRegion*,
+ QualType> > {
+ static void* GDMIndex() { return &RegionCastsIndex; }
+ };
+}
+
//===----------------------------------------------------------------------===//
// Region "Extents"
//===----------------------------------------------------------------------===//
@@ -253,6 +264,7 @@
}
const GRState* setExtent(const GRState* St, const MemRegion* R, SVal Extent);
+ const GRState* setCastType(const GRState* St, const MemRegion* R, QualType T);
static inline RegionBindingsTy GetRegionBindings(Store store) {
return RegionBindingsTy(static_cast<const RegionBindingsTy::TreeTy*>(store));
@@ -488,6 +500,9 @@
// return the size as signed integer.
return NonLoc::MakeVal(getBasicVals(), CAT->getSize(), false);
}
+
+ // If the VarRegion is cast to other type, compute the size with respect to
+ // that type.
// Clients can use ordinary variables as if they were arrays. These
// essentially are arrays of size 1.
@@ -650,9 +665,11 @@
|| isa<ObjCIvarRegion>(R) || isa<CompoundLiteralRegion>(R)) {
if (isSmallerThan(PointeeTy,
cast<TypedRegion>(R)->getRValueType(getContext()))) {
+ // Record the cast type of the region.
+ state = setCastType(state, R, ToTy);
+
SVal Idx = ValMgr.makeZeroArrayIndex();
- ElementRegion* ER = MRMgr.getElementRegion(PointeeTy, Idx,
- cast<TypedRegion>(R));
+ ElementRegion* ER = MRMgr.getElementRegion(PointeeTy, Idx, R);
return CastResult(state, ER);
} else
return CastResult(state, R);
@@ -1295,3 +1312,9 @@
return state.set<RegionViewMap>(Base, V);
}
+
+const GRState* RegionStoreManager::setCastType(const GRState* St,
+ const MemRegion* R, QualType T) {
+ GRStateRef state(St, StateMgr);
+ return state.set<RegionCasts>(R, T);
+}
More information about the llvm-branch-commits
mailing list