This is an archive of the discontinued LLVM Phabricator instance.

Avoid -Wshadow warnings for parameters that shadow fields in setter-like methods
Needs ReviewPublic

Authored by arphaman on Nov 15 2016, 7:47 AM.

Details

Reviewers
rnk
rsmith
Summary

This patch avoids the -Wshadow warning for parameters that shadow fields of their enclosing record and that are defined in a setter-like method. The following heuristic is used to avoid the warning:

  • If a parameter is used only for assignments like this->x = x;, then the warning can be avoided.
  • Otherwise (even if the parameter is unused completely) the warning is shown as normally.

The old behaviour is preserved with -Wshadow-all.

Diff Detail

Repository
rL LLVM

Event Timeline

arphaman updated this revision to Diff 78000.Nov 15 2016, 7:47 AM
arphaman retitled this revision from to Avoid -Wshadow warnings for parameters that shadow fields in setter-like methods.
arphaman updated this object.
arphaman added reviewers: rnk, rsmith.
arphaman set the repository for this revision to rL LLVM.
arphaman added subscribers: cfe-commits, lhames.
arphaman updated this revision to Diff 78004.Nov 15 2016, 8:00 AM

The updated patch fixes a copy-pasted comment.

arphaman updated this revision to Diff 78005.Nov 15 2016, 8:19 AM

Fixed an existing comment that now became partially invalid.