From: Zhongxing Xu Date: Fri, 26 Nov 2010 09:07:38 +0000 (+0000) Subject: Should not use StripCasts() in this context. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=b1dbe0ee0d2e766067ab5a30daf89b2743ebbe43;p=clang Should not use StripCasts() in this context. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@120177 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Checker/ReturnPointerRangeChecker.cpp b/lib/Checker/ReturnPointerRangeChecker.cpp index 0e7a5cf9d1..f743eeb6eb 100644 --- a/lib/Checker/ReturnPointerRangeChecker.cpp +++ b/lib/Checker/ReturnPointerRangeChecker.cpp @@ -48,19 +48,16 @@ void ReturnPointerRangeChecker::PreVisitReturnStmt(CheckerContext &C, SVal V = state->getSVal(RetE); const MemRegion *R = V.getAsRegion(); - if (!R) - return; - - R = R->StripCasts(); - if (!R) - return; const ElementRegion *ER = dyn_cast_or_null(R); if (!ER) return; DefinedOrUnknownSVal Idx = cast(ER->getIndex()); - + // Zero index is always in bound, this also passes ElementRegions created for + // pointer casts. + if (Idx.isZeroConstant()) + return; // FIXME: All of this out-of-bounds checking should eventually be refactored // into a common place.