diff options
| -rw-r--r-- | clang-tools-extra/clang-tidy/modernize/RedundantVoidArgCheck.cpp | 2 | ||||
| -rw-r--r-- | clang-tools-extra/test/clang-tidy/modernize-redundant-void-arg.cpp | 61 |
2 files changed, 62 insertions, 1 deletions
diff --git a/clang-tools-extra/clang-tidy/modernize/RedundantVoidArgCheck.cpp b/clang-tools-extra/clang-tidy/modernize/RedundantVoidArgCheck.cpp index 51dc5a2cc40..ea49ab7bba3 100644 --- a/clang-tools-extra/clang-tidy/modernize/RedundantVoidArgCheck.cpp +++ b/clang-tools-extra/clang-tidy/modernize/RedundantVoidArgCheck.cpp @@ -49,7 +49,7 @@ void RedundantVoidArgCheck::registerMatchers(MatchFinder *Finder) { return; Finder->addMatcher(functionDecl(parameterCountIs(0), unless(isImplicit()), - unless(isExternC())) + unless(isInstantiated()), unless(isExternC())) .bind(FunctionId), this); Finder->addMatcher(typedefNameDecl().bind(TypedefId), this); diff --git a/clang-tools-extra/test/clang-tidy/modernize-redundant-void-arg.cpp b/clang-tools-extra/test/clang-tidy/modernize-redundant-void-arg.cpp index 750e5c1b293..453a4816af0 100644 --- a/clang-tools-extra/test/clang-tidy/modernize-redundant-void-arg.cpp +++ b/clang-tools-extra/test/clang-tidy/modernize-redundant-void-arg.cpp @@ -488,3 +488,64 @@ void lambda_expression_with_macro_test(){ // CHECK-MESSAGES: :[[@LINE-1]]:6: warning: redundant void argument list in lambda expression [modernize-redundant-void-arg] // CHECK-FIXES: []() BODY; } + +struct S_1 { + void g_1(void) const { + // CHECK-MESSAGES: :[[@LINE-1]]:11: warning: redundant void argument list in function definition [modernize-redundant-void-arg] + // CHECK-FIXES: void g_1() const { + int a; + (void)a; + } + + void g_2() const { + int a; + (void)a; + } +}; + +template <typename T0> +struct S_2 { + void g_1(void) const { + // CHECK-MESSAGES: :[[@LINE-1]]:11: warning: redundant void argument list in function definition [modernize-redundant-void-arg] + // CHECK-FIXES: void g_1() const { + int a; + (void)a; + } + + void g_2() const { + int a; + (void)a; + } +}; + +template <typename T0> +struct S_3 { + template <typename T1> + void g_1(void) const { + // CHECK-MESSAGES: :[[@LINE-1]]:11: warning: redundant void argument list in function definition [modernize-redundant-void-arg] + // CHECK-FIXES: void g_1() const { + int a; + (void)a; + } + template <typename T2> + void g_2() const { + int a; + (void)a; + } +}; + +template <typename T1> +void g_3(void) { + // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: redundant void argument list in function definition [modernize-redundant-void-arg] + // CHECK-FIXES: void g_3(){ + int a; + (void)a; +} + +//Template instantiation +void f_testTemplate() { + S_1(); + S_2<int>(); + S_3<int>(); + g_3<int>(); +} |

