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 | e1e8565cd97ea80adebb9cfcc1f01979ae43c643 (patch) | |
tree | 4f2b166d8712631af05df8582cf8a16f7e259d86 /clang/lib/Checker | |
parent | 5afc4d80c72b2dd9b261b8edd603e89ad3787a9d (diff) | |
download | bcm5719-llvm-e1e8565cd97ea80adebb9cfcc1f01979ae43c643.tar.gz bcm5719-llvm-e1e8565cd97ea80adebb9cfcc1f01979ae43c643.zip |
Do not use StripCasts() in this context.
llvm-svn: 120178
Diffstat (limited to 'clang/lib/Checker')
-rw-r--r-- | clang/lib/Checker/ArrayBoundChecker.cpp | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/clang/lib/Checker/ArrayBoundChecker.cpp b/clang/lib/Checker/ArrayBoundChecker.cpp index cf2a2fcf62f..dccb9a29527 100644 --- a/clang/lib/Checker/ArrayBoundChecker.cpp +++ b/clang/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. |