[PATCH] D26278: Avoid -Wshadow warnings for shadowed variables that aren't captured by lambdas with an explicit capture list

Alex Lorenz via cfe-commits cfe-commits at lists.llvm.org
Thu Nov 3 04:44:13 PDT 2016


arphaman created this revision.
arphaman added reviewers: rsmith, rnk.
arphaman added a subscriber: cfe-commits.
arphaman set the repository for this revision to rL LLVM.

This patch avoids the -Wshadow warning for variables which shadow variables that aren't captured by lambdas with an explicit capture list. It provides an additional note that points to location of the explicit capture.

I noticed that we have -Wshadow-all as well, but I wasn't sure how to preserve the old behaviour for it (since I don't think I can check if a diagnostic group is enabled), or if the old behaviour should be preserved at all. What do you think?

This patch fixes PR 21426, but I think that this is a partial fix, since that bug doesn't specify that the capture list should be explicit. I plan on working on a similar patch for lambdas with a default capture specifier and implicit variable captures, but I'm not sure it's 100% needed for them. Do you think this kind of change would make sense for implicit captures as well?


Repository:
  rL LLVM

https://reviews.llvm.org/D26278

Files:
  include/clang/Basic/DiagnosticSemaKinds.td
  lib/Sema/SemaDecl.cpp
  test/SemaCXX/warn-shadow-in-lambdas.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D26278.76840.patch
Type: text/x-patch
Size: 5849 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20161103/23196c01/attachment-0001.bin>


More information about the cfe-commits mailing list