]> granicus.if.org Git - clang/commitdiff
Do not use StripCasts() in this context.
authorZhongxing Xu <xuzhongxing@gmail.com>
Fri, 26 Nov 2010 09:14:07 +0000 (09:14 +0000)
committerZhongxing Xu <xuzhongxing@gmail.com>
Fri, 26 Nov 2010 09:14:07 +0000 (09:14 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@120178 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Checker/ArrayBoundChecker.cpp

index cf2a2fcf62f3ef0337736276eee9003ed72b93ed..dccb9a295277cb13e53efa813ec5eda00a8270dd 100644 (file)
@@ -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.