[cfe-commits] [Patch] Warn about self-initialization of reference variables
Hans Wennborg
hans at chromium.org
Fri Aug 17 03:15:00 PDT 2012
On Thu, Aug 16, 2012 at 9:24 PM, Richard Smith <richard at metafoo.co.uk> wrote:
> LGTM, modulo a couple of small things:
Thanks for the review!
>> - if (!VDecl->hasLocalStorage() &&
>> - (isa<InitListExpr>(Init) || !VDecl->getType()->isRecordType()))
>> - CheckSelfReference(RealDecl, Init);
>> + if (!VDecl->hasLocalStorage() || VDecl->getType()->isReferenceType())
>> + if (isa<InitListExpr>(Init) || !VDecl->getType()->isRecordType())
>> + CheckSelfReference(RealDecl, Init);
>
> '&&' instead of nested 'if's? It might be clearer to reuse !isTrackedVar()
> (from Analysis/UninitializedValues.cpp) here, but I'm happy for the patch to
> go in either way.
Switched to && instead of nested ifs for now.
!isTrackedVar() doesn't seem to be a one-to-one match here. For
example, in my if statement I'm checking that it's not a record type,
whereas !isTrackedVar() would check that it's not a scalar or vector
type. Happy to work with this post-commit if you think it would be
better, though.
>> +++ b/test/SemaCXX/convert-to-bool.cpp
> Your warning found a bug in the test! I'm pretty sure this intended to say:
> B &b = c;
Fixed.
Committed r162093.
Thanks,
Hans
More information about the cfe-commits
mailing list