[PATCH] D26672: Avoid -Wshadow warnings for parameters that shadow fields in setter-like methods
Alex Lorenz via cfe-commits
cfe-commits at lists.llvm.org
Tue Nov 15 07:47:11 PST 2016
arphaman created this revision.
arphaman added reviewers: rnk, rsmith.
arphaman added subscribers: cfe-commits, lhames.
arphaman set the repository for this revision to rL LLVM.
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.
Repository:
rL LLVM
https://reviews.llvm.org/D26672
Files:
include/clang/Basic/DiagnosticGroups.td
include/clang/Basic/DiagnosticSemaKinds.td
include/clang/Sema/Sema.h
lib/Sema/SemaDecl.cpp
lib/Sema/SemaExpr.cpp
test/SemaCXX/warn-shadow-in-setter-methods.cpp
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D26672.78000.patch
Type: text/x-patch
Size: 10934 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20161115/281732d4/attachment.bin>
More information about the cfe-commits
mailing list