From 383c273966c20b029ee2f104ec7d6318c9968006 Mon Sep 17 00:00:00 2001 From: Zhongxing Xu Date: Thu, 12 Nov 2009 02:48:32 +0000 Subject: [PATCH] Make StoreManager::getSizeInElements() always return DefinedOrUnknownSVal. llvm-svn: 86932 --- clang/include/clang/Analysis/PathSensitive/Store.h | 3 ++- clang/lib/Analysis/ArrayBoundChecker.cpp | 5 ++--- clang/lib/Analysis/RegionStore.cpp | 7 ++++--- clang/lib/Analysis/ReturnPointerRangeChecker.cpp | 5 ++--- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/clang/include/clang/Analysis/PathSensitive/Store.h b/clang/include/clang/Analysis/PathSensitive/Store.h index 6ca2e9e9aa68..6c6804bc3f68 100644 --- a/clang/include/clang/Analysis/PathSensitive/Store.h +++ b/clang/include/clang/Analysis/PathSensitive/Store.h @@ -102,7 +102,8 @@ public: virtual SVal getLValueElement(QualType elementType, SVal offset, SVal Base)=0; // FIXME: Make out-of-line. - virtual SVal getSizeInElements(const GRState *state, const MemRegion *region){ + virtual DefinedOrUnknownSVal getSizeInElements(const GRState *state, + const MemRegion *region) { return UnknownVal(); } diff --git a/clang/lib/Analysis/ArrayBoundChecker.cpp b/clang/lib/Analysis/ArrayBoundChecker.cpp index ae8e1149c508..34a5631edd3e 100644 --- a/clang/lib/Analysis/ArrayBoundChecker.cpp +++ b/clang/lib/Analysis/ArrayBoundChecker.cpp @@ -56,9 +56,8 @@ void ArrayBoundChecker::VisitLocation(CheckerContext &C, const Stmt *S, SVal l){ const GRState *state = C.getState(); // Get the size of the array. - SVal NumVal = C.getStoreManager().getSizeInElements(state, - ER->getSuperRegion()); - DefinedOrUnknownSVal &NumElements = cast(NumVal); + DefinedOrUnknownSVal NumElements + = C.getStoreManager().getSizeInElements(state, ER->getSuperRegion()); const GRState *StInBound = state->AssumeInBound(Idx, NumElements, true); const GRState *StOutBound = state->AssumeInBound(Idx, NumElements, false); diff --git a/clang/lib/Analysis/RegionStore.cpp b/clang/lib/Analysis/RegionStore.cpp index 91769cd447cd..46cddd0da1b3 100644 --- a/clang/lib/Analysis/RegionStore.cpp +++ b/clang/lib/Analysis/RegionStore.cpp @@ -360,7 +360,8 @@ public: //===------------------------------------------------------------------===// const GRState *setExtent(const GRState *state, const MemRegion* R, SVal Extent); - SVal getSizeInElements(const GRState *state, const MemRegion* R); + DefinedOrUnknownSVal getSizeInElements(const GRState *state, + const MemRegion* R); //===------------------------------------------------------------------===// // Utility methods. @@ -696,8 +697,8 @@ SVal RegionStoreManager::getLValueElement(QualType elementType, SVal Offset, // Extents for regions. //===----------------------------------------------------------------------===// -SVal RegionStoreManager::getSizeInElements(const GRState *state, - const MemRegion *R) { +DefinedOrUnknownSVal RegionStoreManager::getSizeInElements(const GRState *state, + const MemRegion *R) { switch (R->getKind()) { case MemRegion::MemSpaceRegionKind: diff --git a/clang/lib/Analysis/ReturnPointerRangeChecker.cpp b/clang/lib/Analysis/ReturnPointerRangeChecker.cpp index 261081ebb41d..f007d0e0d1ac 100644 --- a/clang/lib/Analysis/ReturnPointerRangeChecker.cpp +++ b/clang/lib/Analysis/ReturnPointerRangeChecker.cpp @@ -64,9 +64,8 @@ void ReturnPointerRangeChecker::PreVisitReturnStmt(CheckerContext &C, // FIXME: All of this out-of-bounds checking should eventually be refactored // into a common place. - SVal NumVal = C.getStoreManager().getSizeInElements(state, - ER->getSuperRegion()); - DefinedOrUnknownSVal &NumElements = cast(NumVal); + DefinedOrUnknownSVal NumElements + = C.getStoreManager().getSizeInElements(state, ER->getSuperRegion()); const GRState *StInBound = state->AssumeInBound(Idx, NumElements, true); const GRState *StOutBound = state->AssumeInBound(Idx, NumElements, false);