[PATCH] D18271: Avoid -Wshadow warnings about constructor parameters named after fields
Richard Smith via cfe-commits
cfe-commits at lists.llvm.org
Thu Apr 7 13:17:11 PDT 2016
rsmith added inline comments.
================
Comment at: lib/Sema/SemaDecl.cpp:1615
@@ -1614,2 +1614,3 @@
IdResolver.RemoveDecl(D);
+ ShadowingDecls.erase(D);
}
----------------
This'd be a good place to produce a -Wshadow-constructor or similar warning if D is still in the map.
================
Comment at: lib/Sema/SemaDecl.cpp:6483
@@ +6482,3 @@
+ const NamedDecl *D = DRE->getDecl();
+ auto I = ShadowingDecls.find(D);
+ if (I == ShadowingDecls.end())
----------------
Maybe map to the canonical decl before using the `Decl*` as a key? (This doesn't matter for now, but we'll likely want to extend this to other kinds of shadowing in the future.)
================
Comment at: lib/Sema/SemaDecl.cpp:6489-6490
@@ +6488,4 @@
+ ShadowedDeclKind Kind = computeShadowedDeclKind(ShadowedDecl, OldDC);
+ Diag(Loc, diag::warn_modifying_shadowing_decl) << D << Kind << OldDC;
+ Diag(ShadowedDecl->getLocation(), diag::note_previous_declaration);
+
----------------
Could be useful to also note the location of the shadowing decl.
http://reviews.llvm.org/D18271
More information about the cfe-commits
mailing list