Avoid -Wshadow warnings about constructor parameters named after fields
Usually these parameters are used solely to initialize the field in the initializer list, and there is no real shadowing confusion. There is a new warning under -Wshadow called -Wshadow-field-in-constructor-modified. It attempts to find modifications of such constructor parameters that probably intended to modify the field. It has some false negatives, though, so there is another warning group, -Wshadow-field-in-constructor, which always warns on this special case. For users who just want the old behavior and don't care about these fine grained groups, we have a new warning group called -Wshadow-all that activates everything. Fixes PR16088. Reviewers: rsmith Subscribers: cfe-commits Differential Revision: http://reviews.llvm.org/D18271 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@267957 91177308-0d34-0410-b5e6-96231b3b80d8
Showing
- include/clang/Basic/Diagnostic.h 4 additions, 4 deletionsinclude/clang/Basic/Diagnostic.h
- include/clang/Basic/DiagnosticGroups.td 10 additions, 1 deletioninclude/clang/Basic/DiagnosticGroups.td
- include/clang/Basic/DiagnosticSemaKinds.td 9 additions, 1 deletioninclude/clang/Basic/DiagnosticSemaKinds.td
- include/clang/Sema/Sema.h 11 additions, 0 deletionsinclude/clang/Sema/Sema.h
- lib/Sema/AnalysisBasedWarnings.cpp 1 addition, 1 deletionlib/Sema/AnalysisBasedWarnings.cpp
- lib/Sema/SemaDecl.cpp 61 additions, 19 deletionslib/Sema/SemaDecl.cpp
- lib/Sema/SemaExpr.cpp 3 additions, 0 deletionslib/Sema/SemaExpr.cpp
- test/SemaCXX/warn-shadow.cpp 18 additions, 2 deletionstest/SemaCXX/warn-shadow.cpp
Loading
Please register or sign in to comment