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

Alexander Kornienko alexfh at google.com
Thu Mar 6 01:41:09 PST 2014



================
Comment at: clang-tidy/llvm/LLVMTidyModule.cpp:131
@@ +130,3 @@
+          diag(PVD->getLocation(), "%0 declared here", DiagnosticIDs::Note)
+              << II;
+        }
----------------
Alexander Kornienko wrote:
> Peter Collingbourne wrote:
> > Alexander Kornienko wrote:
> > > I think, adding a FixIt to correct the comment would be useful at least in some of the cases (say, a typo in the comment). As a safety measure you could try to find the argument with the closest name to the one used in the comment, and only suggest the fix if this is the same argument. What do you think?
> > That sounds about right but I think we should put an upper bound on the allowable edit distance (similarly to how we handle typos during semantic analysis) and use a larger threshold for the other parameters. I've implemented this scheme and I'll let it run over LLVM tonight.
> That's even better. BTW, if you run this over LLVM in fix mode, you'll probably be disappointed, as 1. there's a problem with replacement fix-its (I'll commit a patch soon), 2. fixing inside headers makes awful things without deduplication (I'll try to work this out today). As for the diagnostic run, I found it to be quite fast (faster, than a full build), when running in parallel with xargs -P, e.g.:
> 
>   find lib/ -name "*.cpp" | xargs -n1 -P32 clang-tidy -checks=misc-
> 
> (if you use this already, sorry for the noise).
Actually, the fix for the 1. has been committed in r202987, so the replacement fix-its should work.

================
Comment at: clang-tidy/misc/MiscTidyModule.cpp:161
@@ +160,3 @@
+                  Construct->getParenOrBraceRange().getBegin(),
+                  llvm::ArrayRef<const Expr *>(Construct->getArgs(),
+                                               Construct->getNumArgs()));
----------------
nit: Use llvm:makeArrayRef (here and 5 lines above).


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



More information about the cfe-commits mailing list