[PATCH] D18271: Avoid -Wshadow warnings about constructor parameters named after fields

Alexander Kornienko via cfe-commits cfe-commits at lists.llvm.org
Wed Mar 23 11:03:10 PDT 2016

alexfh added a subscriber: alexfh.
alexfh added a comment.

As a data point: I ran -Wshadow on our code base with a similar, but simpler patch (http://reviews.llvm.org/D18395, just disables the warning on ctor parameters named after fields). It removes more than half of the hits (from ~100k initially) and a random sample of ~100 removed removed hits didn't contain any issues that we'd like to still be warning about.

Ultimately, I think, this diagnostic should be made much less noisy to be actually useful. So maybe even starting with a removal of a larger subset of warnings (and then gradually adding back the cases that seem to be important to flag) would be better.

Comment at: lib/Sema/SemaExpr.cpp:9887
@@ -9854,1 +9886,3 @@
     if (ConvTy == Compatible) {
+      const Expr *InnerLHS = LHSExpr->IgnoreParenCasts();
+      const DeclRefExpr *DRE = dyn_cast<DeclRefExpr>(InnerLHS);
Why this change?


More information about the cfe-commits mailing list