george.burgess.iv updated this revision to Diff 444397.
george.burgess.iv added a comment.

Rebased on top of 891319f654c102572cf7028ed04bbaf6c59e7bff 
<https://reviews.llvm.org/rG891319f654c102572cf7028ed04bbaf6c59e7bff> as 
requested; `ninja check-clang-extra docs-clang-tools-html` passes


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D126735/new/

https://reviews.llvm.org/D126735

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


Index: 
clang-tools-extra/test/clang-tidy/checkers/modernize/redundant-void-arg.cpp
===================================================================
--- clang-tools-extra/test/clang-tidy/checkers/modernize/redundant-void-arg.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/modernize/redundant-void-arg.cpp
@@ -592,3 +592,9 @@
   (void)a;
 }
 #undef return_t
+
+// Explicitly specifying `(void)` is a way to sidestep -Wvexing-parse, so we
+// should not warn about it here.
+void most_vexing_parse() {
+  int foo(void);
+}
Index: clang-tools-extra/clang-tidy/modernize/RedundantVoidArgCheck.cpp
===================================================================
--- clang-tools-extra/clang-tidy/modernize/RedundantVoidArgCheck.cpp
+++ clang-tools-extra/clang-tidy/modernize/RedundantVoidArgCheck.cpp
@@ -109,9 +109,13 @@
     }
     removeVoidArgumentTokens(Result, SourceRange(Start, End),
                              "function definition");
-  } else
+  } else if (!Function->getLexicalDeclContext()->isFunctionOrMethod()) {
+    // Only do this if our decl context is outside of a function or method;
+    // otherwise, the user may have explicitly written `(void)` to avoid Most
+    // Vexing Parse warnings.
     removeVoidArgumentTokens(Result, SourceRange(Start, End),
                              "function declaration");
+  }
 }
 
 bool isMacroIdentifier(const IdentifierTable &Idents, const Token &ProtoToken) 
{


Index: clang-tools-extra/test/clang-tidy/checkers/modernize/redundant-void-arg.cpp
===================================================================
--- clang-tools-extra/test/clang-tidy/checkers/modernize/redundant-void-arg.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/modernize/redundant-void-arg.cpp
@@ -592,3 +592,9 @@
   (void)a;
 }
 #undef return_t
+
+// Explicitly specifying `(void)` is a way to sidestep -Wvexing-parse, so we
+// should not warn about it here.
+void most_vexing_parse() {
+  int foo(void);
+}
Index: clang-tools-extra/clang-tidy/modernize/RedundantVoidArgCheck.cpp
===================================================================
--- clang-tools-extra/clang-tidy/modernize/RedundantVoidArgCheck.cpp
+++ clang-tools-extra/clang-tidy/modernize/RedundantVoidArgCheck.cpp
@@ -109,9 +109,13 @@
     }
     removeVoidArgumentTokens(Result, SourceRange(Start, End),
                              "function definition");
-  } else
+  } else if (!Function->getLexicalDeclContext()->isFunctionOrMethod()) {
+    // Only do this if our decl context is outside of a function or method;
+    // otherwise, the user may have explicitly written `(void)` to avoid Most
+    // Vexing Parse warnings.
     removeVoidArgumentTokens(Result, SourceRange(Start, End),
                              "function declaration");
+  }
 }
 
 bool isMacroIdentifier(const IdentifierTable &Idents, const Token &ProtoToken) {
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to