[PATCH] Add readability-redundant-void-arg check to clang-tidy

Richard legalize at xmission.com
Mon Jun 22 23:55:18 PDT 2015


================
Comment at: clang-tidy/readability/RedundantVoidArgCheck.cpp:244
@@ +243,3 @@
+    removeVoidArgumentTokens(
+        Result, shrinkRangeByOne(SourceRange(CStyleCast->getLParenLoc(),
+                                             CStyleCast->getRParenLoc())),
----------------
LegalizeAdulthood wrote:
> alexfh wrote:
> > Character-based offsets can be brittle in case escaped newlines and alternative tokens are used. I'd prefer getting the type range directly when it's possible. Here and for other casts something like this should work: `CStyleCast->getTypeInfoAsWritten()->getTypeLoc().getSourceRange()`.
> > 
> > Also, do we need separate functions for `ExplicitCastExpr` and two of its children classes?
> I don't think the character based offsets can be avoided here.  The nodes don't provide getter functions for all the locations I'm interested in and I have to construct the appropriate source location myself.  I will try what you suggest and see how it goes.
> 
> I tried doing things with just `ExplicitCastExpr` initially and when I added test cases for the functional and C-style casts, I needed to do different replacement ranges.
I was able to avoid some of the custom `SourceRange` computations, which allowed me to eliminate `shrinkRangeByOne` as well.

================
Comment at: test/clang-tidy/readability-redundant-void-arg.c:77
@@ +76,3 @@
+
+// intentionally not LLVM style to check preservation of whitespace
+typedef void (function_ptr2)
----------------
alexfh wrote:
> Special tests for whitespace handling seem to be superfluous when you just need to check that no changes are made. Also, the invariant "no warnings => no fixes" seems to be safe to rely on, so you can remove all CHECK-FIXES and add one "CHECK-MESSAGES-NOT: warning:" so that the script runs the FileCheck on the output.
I tried this, but it doesn't work with the shell script used to run clang-tidy.  You need to pass --allow-empty to FileCheck, but the script doesn't allow for this.  So I left the file unchanged.

http://reviews.llvm.org/D7639

EMAIL PREFERENCES
  http://reviews.llvm.org/settings/panel/emailpreferences/






More information about the cfe-commits mailing list