Do not use StripCasts() in this context.
llvm-svn: 120178
diff --git a/clang/lib/Checker/ArrayBoundChecker.cpp b/clang/lib/Checker/ArrayBoundChecker.cpp
index cf2a2fc..dccb9a2 100644
--- a/clang/lib/Checker/ArrayBoundChecker.cpp
+++ b/clang/lib/Checker/ArrayBoundChecker.cpp
@@ -44,8 +44,6 @@
if (!R)
return;
- R = R->StripCasts();
-
const ElementRegion *ER = dyn_cast<ElementRegion>(R);
if (!ER)
return;
@@ -53,6 +51,11 @@
// 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.