diff options
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)) { |

