[cfe-commits] r120178 - /cfe/trunk/lib/Checker/ArrayBoundChecker.cpp
Ted Kremenek
kremenek at apple.com
Sat Nov 27 23:51:21 PST 2010
Hi Zhongxing,
Similar to my comment for the other related change, what is the motivation for removing the use of StripCasts? I'm not saying the patch is wrong; I'd just like to see more of an explanation of why this is the right thing to do. I'd personally like to see a comment in the code explaining the logic so that the use of StripCasts() doesn't just get arbitrarily added back later. A test case (if one is relevant) would also be useful in understanding the motivation behind the change.
Thanks,
Ted
On Nov 26, 2010, at 1:14 AM, Zhongxing Xu <xuzhongxing at gmail.com> wrote:
> 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.
>
>
> _______________________________________________
> cfe-commits mailing list
> cfe-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
More information about the cfe-commits
mailing list