diff options
author | Reid Kleckner <rnk@google.com> | 2016-04-29 00:37:43 +0000 |
---|---|---|
committer | Reid Kleckner <rnk@google.com> | 2016-04-29 00:37:43 +0000 |
commit | e5d643a3e7fb52ce6a87c84dac0de41bda6a63e7 (patch) | |
tree | 8eec2555b70bd0c038c182d1c0bd95deafc7a81c /include/clang/Basic/Diagnostic.h | |
parent | 4eaa6552bba77670e89d3bf6fab1e30f669141b6 (diff) | |
download | clang-e5d643a3e7fb52ce6a87c84dac0de41bda6a63e7.tar.gz |
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
Diffstat (limited to 'include/clang/Basic/Diagnostic.h')
-rw-r--r-- | include/clang/Basic/Diagnostic.h | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/include/clang/Basic/Diagnostic.h b/include/clang/Basic/Diagnostic.h index dd4443e5dd..085faeae48 100644 --- a/include/clang/Basic/Diagnostic.h +++ b/include/clang/Basic/Diagnostic.h @@ -1072,10 +1072,10 @@ inline const DiagnosticBuilder &operator<<(const DiagnosticBuilder &DB, // so that we only match those arguments that are (statically) DeclContexts; // other arguments that derive from DeclContext (e.g., RecordDecls) will not // match. -template<typename T> -inline -typename std::enable_if<std::is_same<T, DeclContext>::value, - const DiagnosticBuilder &>::type +template <typename T> +inline typename std::enable_if< + std::is_same<typename std::remove_const<T>::type, DeclContext>::value, + const DiagnosticBuilder &>::type operator<<(const DiagnosticBuilder &DB, T *DC) { DB.AddTaggedVal(reinterpret_cast<intptr_t>(DC), DiagnosticsEngine::ak_declcontext); |