[PATCH] D53595: [C++17] Reject shadowing of capture by parameter in lambda

Erik Pilkington via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Oct 23 12:28:58 PDT 2018


erik.pilkington added a comment.

Thanks for working on this! Can you update www/cxx_dr_status.html too?



================
Comment at: lib/Sema/SemaLambda.cpp:507
+      bool Error = false;
+      if (getLangOpts().CPlusPlus17) {
+        // Resolution of CWG 2211 in C++17 renders shadowing ill-formed.
----------------
We usually back-port defect report resolutions to older standards, in this case maybe we should just warn pre-17 though. (Even though we warn here anyways with -Wshadow in -Wextra)


================
Comment at: lib/Sema/SemaLambda.cpp:509
+        // Resolution of CWG 2211 in C++17 renders shadowing ill-formed.
+        for (const auto &Capture: Captures) {
+          if (Capture.Id && Capture.Id->getName() == Param->getName()) {
----------------
Nit: the colon should have a space on it's left here.


================
Comment at: lib/Sema/SemaLambda.cpp:510
+        for (const auto &Capture: Captures) {
+          if (Capture.Id && Capture.Id->getName() == Param->getName()) {
+            Error = true;
----------------
You should compare `IdentifierInfo`s here, rather than `StringRef`s.


Repository:
  rC Clang

https://reviews.llvm.org/D53595





More information about the cfe-commits mailing list