diff options
author | Zhongxing Xu <xuzhongxing@gmail.com> | 2010-11-26 09:14:07 +0000 |
---|---|---|
committer | Zhongxing Xu <xuzhongxing@gmail.com> | 2010-11-26 09:14:07 +0000 |
commit | 110eaf156121760073fe6af6b3b0ed09be0cc0ce (patch) | |
tree | c522674e150be398e107b8dcc5b0345f6ce1d89c /lib/Checker/ArrayBoundChecker.cpp | |
parent | b1dbe0ee0d2e766067ab5a30daf89b2743ebbe43 (diff) |
Do not use StripCasts() in this context.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@120178 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Checker/ArrayBoundChecker.cpp')
-rw-r--r-- | lib/Checker/ArrayBoundChecker.cpp | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/lib/Checker/ArrayBoundChecker.cpp b/lib/Checker/ArrayBoundChecker.cpp index cf2a2fcf62..dccb9a2952 100644 --- a/lib/Checker/ArrayBoundChecker.cpp +++ b/lib/Checker/ArrayBoundChecker.cpp @@ -44,8 +44,6 @@ void ArrayBoundChecker::VisitLocation(CheckerContext &C, const Stmt *S, SVal l){ if (!R) return; - R = R->StripCasts(); - const ElementRegion *ER = dyn_cast<ElementRegion>(R); if (!ER) return; @@ -53,6 +51,11 @@ void ArrayBoundChecker::VisitLocation(CheckerContext &C, const Stmt *S, SVal l){ // Get the index of the accessed element. DefinedOrUnknownSVal Idx = cast<DefinedOrUnknownSVal>(ER->getIndex()); + // Zero index is always in bound, this also passes ElementRegions created for + // pointer casts. + if (Idx.isZeroConstant()) + return; + const GRState *state = C.getState(); // Get the size of the array. |