diff options
author | Malcolm Parsons <malcolm.parsons@gmail.com> | 2016-10-11 12:02:16 +0000 |
---|---|---|
committer | Malcolm Parsons <malcolm.parsons@gmail.com> | 2016-10-11 12:02:16 +0000 |
commit | 8cb9b02c7e4e7a517bea033e88da3bf689030c7a (patch) | |
tree | 1117e22c1dd8be90c1e9290be54b80a7e49d4f5e /clang-tools-extra/test/clang-tidy/readability-avoid-const-params-in-decls.cpp | |
parent | 8acba11675be0b2c4d509e132d7dad593b6179e0 (diff) | |
download | bcm5719-llvm-8cb9b02c7e4e7a517bea033e88da3bf689030c7a.tar.gz bcm5719-llvm-8cb9b02c7e4e7a517bea033e88da3bf689030c7a.zip |
[clang-tidy] readability-avoid-const-params-in-decls template instantiation bugfix
Summary: Bugfix for 30398. Don't warn for template instantiations
Reviewers: aaron.ballman, hokein, alexfh
Subscribers: omtcyfz, cfe-commits
Differential Revision: https://reviews.llvm.org/D24652
llvm-svn: 283873
Diffstat (limited to 'clang-tools-extra/test/clang-tidy/readability-avoid-const-params-in-decls.cpp')
-rw-r--r-- | clang-tools-extra/test/clang-tidy/readability-avoid-const-params-in-decls.cpp | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/clang-tools-extra/test/clang-tidy/readability-avoid-const-params-in-decls.cpp b/clang-tools-extra/test/clang-tidy/readability-avoid-const-params-in-decls.cpp index f009f9f5941..c2c12a429fb 100644 --- a/clang-tools-extra/test/clang-tidy/readability-avoid-const-params-in-decls.cpp +++ b/clang-tools-extra/test/clang-tidy/readability-avoid-const-params-in-decls.cpp @@ -53,6 +53,12 @@ void F12(const bool b = true); // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: parameter 'b' // CHECK-FIXES: void F12(bool b = true); +template<class T> +int F13(const bool b = true); +// CHECK-MESSAGES: :[[@LINE-1]]:9: warning: parameter 'b' +// CHECK-FIXES: int F13(bool b = true); +int f13 = F13<int>(); + struct Foo { Foo(const int i); // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: parameter 'i' @@ -63,6 +69,18 @@ struct Foo { // CHECK-FIXES: void operator()(int i); }; +template <class T> +struct FooT { + FooT(const int i); + // CHECK-MESSAGES: :[[@LINE-1]]:8: warning: parameter 'i' + // CHECK-FIXES: FooT(int i); + + void operator()(const int i); + // CHECK-MESSAGES: :[[@LINE-1]]:19: warning: parameter 'i' + // CHECK-FIXES: void operator()(int i); +}; +FooT<int> f(1); + // Do not match on definitions void NF1(const int i) {} void NF2(const int *const i) {} @@ -72,6 +90,25 @@ void NF5(const int) {} void NF6(const int *const) {} void NF7(int, const int) {} void NF8(const int, const int) {} +template <class T> +int NF9(const int, const int) { return 0; } +int nf9 = NF9<int>(1, 2); + +// Do not match on inline member functions +struct Bar { + Bar(const int i) {} + + void operator()(const int i) {} +}; + +// Do not match on inline member functions of a templated class +template <class T> +struct BarT { + BarT(const int i) {} + + void operator()(const int i) {} +}; +BarT<int> b(1); // Do not match on other stuff void NF(const alias_type& i); |