[PATCH] Add an argument comment checker to clang-tidy.

Peter Collingbourne peter at pcc.me.uk
Mon Mar 17 01:12:44 PDT 2014



================
Comment at: clang-tidy/misc/MiscTidyModule.cpp:88
@@ +87,3 @@
+
+    // Other parameters must be an edit distance at least 2 more away from this
+    // parameter. This gives us greater confidence that this is a typo of this
----------------
Alexander Kornienko wrote:
> nit: I'd make a constant for "2" in case it turns out, that 1 or 3 works better here.
Done.

================
Comment at: clang-tidy/misc/MiscTidyModule.cpp:122
@@ +121,3 @@
+
+    auto Comments =
+        getCommentsInRange(Ctx, SourceRange(BeginSLoc, EndSLoc));
----------------
Alexander Kornienko wrote:
> Maybe "for (auto Comment : getCommentsInRange(...))"?
Done.

================
Comment at: clang-tidy/misc/MiscTidyModule.cpp:161
@@ +160,3 @@
+                  Construct->getParenOrBraceRange().getBegin(),
+                  llvm::ArrayRef<const Expr *>(Construct->getArgs(),
+                                               Construct->getNumArgs()));
----------------
Alexander Kornienko wrote:
> nit: Use llvm:makeArrayRef (here and 5 lines above).
Done. (This uncovered a const correctness bug in Clang which I will fix later.)

================
Comment at: clang-tidy/misc/MiscTidyModule.h:1
@@ +1,2 @@
+//===--- MiscTidyModule.h - clang-tidy --------------------------*- C++ -*-===//
+//
----------------
Alexander Kornienko wrote:
> I'd make a .h + .cpp file per check instead of using a single header for all checks.
Done.

================
Comment at: test/clang-tidy/arg-comments.cpp:26
@@ +25,3 @@
+}
+
+// CHECK-NOT: warning
----------------
Alexander Kornienko wrote:
> Please add tests for the typo detection logic.
> 
> It may be easier to write replacement tests as unit-tests, than as lit-based ones. See tools/extra/unittests/clang-tidy/GoogleModuleTest.cpp for an example.
Done.


http://llvm-reviews.chandlerc.com/D2914



More information about the cfe-commits mailing list