[cfe-commits] [Patch] Mark pass-by-reference as uninitialized variable use on initialization

Richard Smith richard at metafoo.co.uk
Mon Aug 6 16:09:29 PDT 2012


On Mon, Aug 6, 2012 at 3:29 PM, Richard Trieu <rtrieu at google.com> wrote:

> Modify the self-reference visitor to mark pass-by-reference to function
> calls as uninitialized use.  This will warn on code such as:
>
> const string Foo = "prefix" + Foo + "suffix";
>

Can we put this under a more specific -W flag? -Wuninitialized is intended
to be essentially free of false positives.

I'm a little concerned that this uninitialized-variables warning is
deviating from the behavior of the CFG-based warning, which explicitly
excludes variables passed by reference to functions from its list of uses,
so if this is effective at finding bugs, perhaps we should add this check
there too.

--- lib/Sema/SemaDecl.cpp (revision 161345)
+++ lib/Sema/SemaDecl.cpp (working copy)
@@ -6223,7 +6223,7 @@

     void VisitImplicitCastExpr(ImplicitCastExpr *E) {
       if ((!isRecordType && E->getCastKind() == CK_LValueToRValue) ||
-          (isRecordType && E->getCastKind() == CK_NoOp))
+          (E->getCastKind() == CK_NoOp))

Drop these parens... But I'm not really clear on what this is checking for.
Presumably qualification conversions, but why are those a good place to
look for self-initialization?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20120806/d6aa7f34/attachment.html>


More information about the cfe-commits mailing list