IdrissRio created this revision.
IdrissRio added reviewers: aaron.ballman, hokein, alexfh.
Herald added a subscriber: cfe-commits.

[Clang-Tidy: modernize] Fix for modernize-redundant-void-arg: complains about 
variable cast to void


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D52135

Files:
  clang-tidy/modernize/RedundantVoidArgCheck.cpp
  test/clang-tidy/modernize-redundant-void-arg.cpp


Index: test/clang-tidy/modernize-redundant-void-arg.cpp
===================================================================
--- test/clang-tidy/modernize-redundant-void-arg.cpp
+++ test/clang-tidy/modernize-redundant-void-arg.cpp
@@ -488,3 +488,17 @@
   // CHECK-MESSAGES: :[[@LINE-1]]:6: warning: redundant void argument list in 
lambda expression [modernize-redundant-void-arg]
   // CHECK-FIXES: []() BODY;
 }
+
+template <typename T0>
+struct S_template {
+       template <typename T>
+       void g_template() const {
+               int a_template;
+               (void)a_template;
+       }
+};
+
+void test_template() {
+       S_template<int>().g_template<int>();
+}
+
Index: clang-tidy/modernize/RedundantVoidArgCheck.cpp
===================================================================
--- clang-tidy/modernize/RedundantVoidArgCheck.cpp
+++ clang-tidy/modernize/RedundantVoidArgCheck.cpp
@@ -49,7 +49,7 @@
     return;
 
   Finder->addMatcher(functionDecl(parameterCountIs(0), unless(isImplicit()),
-                                  unless(isExternC()))
+                                  unless(isInstantiated()), 
unless(isExternC()))
                          .bind(FunctionId),
                      this);
   Finder->addMatcher(typedefNameDecl().bind(TypedefId), this);


Index: test/clang-tidy/modernize-redundant-void-arg.cpp
===================================================================
--- test/clang-tidy/modernize-redundant-void-arg.cpp
+++ test/clang-tidy/modernize-redundant-void-arg.cpp
@@ -488,3 +488,17 @@
   // CHECK-MESSAGES: :[[@LINE-1]]:6: warning: redundant void argument list in lambda expression [modernize-redundant-void-arg]
   // CHECK-FIXES: []() BODY;
 }
+
+template <typename T0>
+struct S_template {
+	template <typename T>
+	void g_template() const {
+		int a_template;
+		(void)a_template;
+	}
+};
+
+void test_template() {
+	S_template<int>().g_template<int>();
+}
+
Index: clang-tidy/modernize/RedundantVoidArgCheck.cpp
===================================================================
--- clang-tidy/modernize/RedundantVoidArgCheck.cpp
+++ clang-tidy/modernize/RedundantVoidArgCheck.cpp
@@ -49,7 +49,7 @@
     return;
 
   Finder->addMatcher(functionDecl(parameterCountIs(0), unless(isImplicit()),
-                                  unless(isExternC()))
+                                  unless(isInstantiated()), unless(isExternC()))
                          .bind(FunctionId),
                      this);
   Finder->addMatcher(typedefNameDecl().bind(TypedefId), this);
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to