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

Idriss via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Sep 17 05:30:53 PDT 2018


This revision was automatically updated to reflect the committed changes.
Closed by commit rCTE342388: [Clang-Tidy: modernize] Fix for modernize-redundant-void-arg: complains about… (authored by IdrissRio, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D52135?vs=165741&id=165746#toc

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: 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,64 @@
   // 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>();
+}


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D52135.165746.patch
Type: text/x-patch
Size: 2378 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20180917/9274af6a/attachment.bin>


More information about the cfe-commits mailing list