[cfe-commits] [PATCH] Fix uninitialized variable tracking for compound assignments
Richard Smith
richard at metafoo.co.uk
Mon Jul 16 13:06:07 PDT 2012
On Mon, Jul 16, 2012 at 12:55 PM, Ted Kremenek <kremenek at apple.com> wrote:
>
> On Jul 15, 2012, at 10:14 PM, Richard Smith <richard at metafoo.co.uk> wrote:
>
> The patch replaces the 'track the last DeclRefExpr we saw' technique with
> a separate pass to classify the DeclRefExprs as use or initialization.
> Fixing this exposed some "false" positives on some benchmarking code which
> looks like:
>
> void f() {
> volatile int n;
> for (int i = 0; i < N; ++i)
> n += f();
> }
>
> ... so the patch classifies compound-assignments as neither initialization
> nor use (it leaves the variable uninitialized if it was before, and leaves
> it initialized if it was before).
>
>
> Hi Richard,
>
> One comment on this last point. We tend to like avoiding the
> uninitialized value taint propagating after the first use to avoid a
> cascade of warnings. Your last comment here implies that were we to flag a
> warning at "n += f()" we might also flag another warning later if 'n' is
> used again. Is that true?
>
-Wuninitialized only produces one warning per variable. That's handled in
the Sema layer; the Analysis layer reports all uninitialized uses. My patch
doesn't change that side of things.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20120716/c3bd9eb9/attachment.html>
More information about the cfe-commits
mailing list