diff options
| author | Zhongxing Xu <xuzhongxing@gmail.com> | 2009-05-06 08:08:27 +0000 |
|---|---|---|
| committer | Zhongxing Xu <xuzhongxing@gmail.com> | 2009-05-06 08:08:27 +0000 |
| commit | 1813e23a52e71b6533f50a30c4a3ed5563786f8d (patch) | |
| tree | 25e1bbbec563186d68002fd9d2448ed5195a1abc /clang/lib/Analysis/RegionStore.cpp | |
| parent | 960ae0660bb08efb1564d81032150d2933ab36ce (diff) | |
| download | bcm5719-llvm-1813e23a52e71b6533f50a30c4a3ed5563786f8d.tar.gz bcm5719-llvm-1813e23a52e71b6533f50a30c4a3ed5563786f8d.zip | |
Implement a heuristic type size comparison method for now.
llvm-svn: 71074
Diffstat (limited to 'clang/lib/Analysis/RegionStore.cpp')
| -rw-r--r-- | clang/lib/Analysis/RegionStore.cpp | 22 |
1 files changed, 19 insertions, 3 deletions
diff --git a/clang/lib/Analysis/RegionStore.cpp b/clang/lib/Analysis/RegionStore.cpp index 145559e8b81..5f8e6c3f92a 100644 --- a/clang/lib/Analysis/RegionStore.cpp +++ b/clang/lib/Analysis/RegionStore.cpp @@ -554,6 +554,10 @@ SVal RegionStoreManager::getSizeInElements(const GRState* St, return UnknownVal(); } + if (isa<ElementRegion>(R)) { + return UnknownVal(); + } + assert(0 && "Other regions are not supported yet."); return UnknownVal(); } @@ -585,6 +589,13 @@ SVal RegionStoreManager::ArrayToPointer(Loc Array) { return loc::MemRegionVal(ER); } +static bool isSmallerThan(QualType T1, QualType T2) { + if (T1->isCharType()) + return true; + else + return false; +} + RegionStoreManager::CastResult RegionStoreManager::CastRegion(const GRState* state, const MemRegion* R, QualType CastToTy) { @@ -637,9 +648,14 @@ RegionStoreManager::CastRegion(const GRState* state, const MemRegion* R, // VarRegion. if (isa<VarRegion>(R) || isa<ElementRegion>(R) || isa<FieldRegion>(R) || isa<ObjCIvarRegion>(R) || isa<CompoundLiteralRegion>(R)) { - // FIXME: create an ElementRegion when the size of the pointee type is - // smaller than the region. - return CastResult(state, R); + if (isSmallerThan(PointeeTy, + cast<TypedRegion>(R)->getRValueType(getContext()))) { + SVal Idx = ValMgr.makeZeroArrayIndex(); + ElementRegion* ER = MRMgr.getElementRegion(PointeeTy, Idx, + cast<TypedRegion>(R)); + return CastResult(state, ER); + } else + return CastResult(state, R); } if (isa<TypedViewRegion>(R)) { |

