[cfe-commits] r120178 - /cfe/trunk/lib/Checker/ArrayBoundChecker.cpp

Zhongxing Xu xuzhongxing at gmail.com
Fri Nov 26 01:14:07 PST 2010


Author: zhongxingxu
Date: Fri Nov 26 03:14:07 2010
New Revision: 120178

URL: http://llvm.org/viewvc/llvm-project?rev=120178&view=rev
Log:
Do not use StripCasts() in this context.

Modified:
    cfe/trunk/lib/Checker/ArrayBoundChecker.cpp

Modified: cfe/trunk/lib/Checker/ArrayBoundChecker.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Checker/ArrayBoundChecker.cpp?rev=120178&r1=120177&r2=120178&view=diff
==============================================================================
--- cfe/trunk/lib/Checker/ArrayBoundChecker.cpp (original)
+++ cfe/trunk/lib/Checker/ArrayBoundChecker.cpp Fri Nov 26 03:14:07 2010
@@ -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.





More information about the cfe-commits mailing list