[cfe-commits] r120177 - /cfe/trunk/lib/Checker/ReturnPointerRangeChecker.cpp

Xu Zhongxing xuzhongxing at gmail.com
Sat Nov 27 23:49:33 PST 2010


No. I want to reduce the uses of StripCasts. It shouldn't be used
everywhere. Here we should check the zero index explicitly.

On Sun, Nov 28, 2010 at 3:45 PM, Ted Kremenek <kremenek at apple.com> wrote:

> Hi Zhongxing,
>
> What is the motivation for this change?  Did the previous logic cause a
> test case to fail?
>
> On Nov 26, 2010, at 1:07 AM, Zhongxing Xu <xuzhongxing at gmail.com> wrote:
>
> > Author: zhongxingxu
> > Date: Fri Nov 26 03:07:38 2010
> > New Revision: 120177
> >
> > URL: http://llvm.org/viewvc/llvm-project?rev=120177&view=rev
> > Log:
> > Should not use StripCasts() in this context.
> >
> > Modified:
> >    cfe/trunk/lib/Checker/ReturnPointerRangeChecker.cpp
> >
> > Modified: cfe/trunk/lib/Checker/ReturnPointerRangeChecker.cpp
> > URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Checker/ReturnPointerRangeChecker.cpp?rev=120177&r1=120176&r2=120177&view=diff
> >
> ==============================================================================
> > --- cfe/trunk/lib/Checker/ReturnPointerRangeChecker.cpp (original)
> > +++ cfe/trunk/lib/Checker/ReturnPointerRangeChecker.cpp Fri Nov 26
> 03:07:38 2010
> > @@ -48,19 +48,16 @@
> >
> >   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<ElementRegion>(R);
> >   if (!ER)
> >     return;
> >
> >   DefinedOrUnknownSVal Idx = cast<DefinedOrUnknownSVal>(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.
> >
> >
> >
> > _______________________________________________
> > cfe-commits mailing list
> > cfe-commits at cs.uiuc.edu
> > http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20101128/1bce9066/attachment.html>


More information about the cfe-commits mailing list