This is an archive of the discontinued LLVM Phabricator instance.

[PATCH] Disabling warnings on unused parameters if function is deleted/ defaulted (cxx11) [PR19303]
ClosedPublic

Authored by dinesh.d on Apr 15 2014, 6:08 AM.

Details

Summary

if a function is defined out-of-line and marked as deleted/ defaulted [cxx11],
it is handled by Parser::ParseFunctionDefinition( Body = 0). This function calls
Actions.ActOnFinishFunctionBody() which in-turn calls DiagnoseUnusedParameters()
and DiagnoseSizeOfParametersAndReturnValue(). After this, the function attributes
are set to deleted/ defaulted.

For deleted/ defaulted function, as they do not have body to diagnosed against,
DiagnoseXXX calls does not make much sense. I have added a patch with this check
before calling DiagnoseXXX functions.

I have tried other options like, first mark functions as deleted/ defaulted and
then call ActOnFinishFunctionBody() and check if function is marked before calling
DiagnoseXXX functions but it has its own side effects.

Please let me know if this patch is ok.

Diff Detail

Event Timeline

rnk added a subscriber: rnk.Apr 25 2014, 2:02 PM
rnk added inline comments.
lib/Sema/SemaDecl.cpp
9926–9927

This comment should be higher level, explaining why it's doing this, not how it's doing it. The code itself is fairly obvious. For example:

// Don't diagnose unused parameters of defaulted or deleted functions.
9930–9931

This might apply to a copy constructor for a large class. Consider:

struct A {
  int a[LARGE];
  A(A a);
};
A::A(A a) = default; // expected-warning {{...}}
dinesh.d updated this revision to Diff 8864.Apr 26 2014, 11:19 AM
dinesh.d edited edge metadata.

Updated as per comment.

Thanks for review

rnk added a comment.Apr 29 2014, 5:38 PM

Looks good! Do you need someone to commit it?

Yes, I do not have commit access and need help in committing this.

dinesh.d accepted this revision.Apr 30 2014, 2:51 PM
dinesh.d added a reviewer: dinesh.d.

Thanks for committing this patch (r207672)

This revision is now accepted and ready to land.Apr 30 2014, 2:51 PM
dinesh.d closed this revision.Apr 30 2014, 2:51 PM