[clang-tools-extra] r293771 - [clang-tidy] misc-argument-comment: ignore comments after arguments

Alexander Kornienko via cfe-commits cfe-commits at lists.llvm.org
Wed Feb 1 07:28:26 PST 2017


Author: alexfh
Date: Wed Feb  1 09:28:25 2017
New Revision: 293771

URL: http://llvm.org/viewvc/llvm-project?rev=293771&view=rev
Log:
[clang-tidy] misc-argument-comment: ignore comments after arguments

Modified:
    clang-tools-extra/trunk/clang-tidy/misc/ArgumentCommentCheck.cpp
    clang-tools-extra/trunk/test/clang-tidy/misc-argument-comment.cpp

Modified: clang-tools-extra/trunk/clang-tidy/misc/ArgumentCommentCheck.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/misc/ArgumentCommentCheck.cpp?rev=293771&r1=293770&r2=293771&view=diff
==============================================================================
--- clang-tools-extra/trunk/clang-tidy/misc/ArgumentCommentCheck.cpp (original)
+++ clang-tools-extra/trunk/clang-tidy/misc/ArgumentCommentCheck.cpp Wed Feb  1 09:28:25 2017
@@ -67,16 +67,19 @@ getCommentsInRange(ASTContext *Ctx, Char
     Token Tok;
     if (TheLexer.LexFromRawLexer(Tok))
       break;
-    if (Tok.getLocation() == Range.getEnd() || Tok.getKind() == tok::eof)
+    if (Tok.getLocation() == Range.getEnd() || Tok.is(tok::eof))
       break;
 
-    if (Tok.getKind() == tok::comment) {
+    if (Tok.is(tok::comment)) {
       std::pair<FileID, unsigned> CommentLoc =
           SM.getDecomposedLoc(Tok.getLocation());
       assert(CommentLoc.first == BeginLoc.first);
       Comments.emplace_back(
           Tok.getLocation(),
           StringRef(Buffer.begin() + CommentLoc.second, Tok.getLength()));
+    } else {
+      // Clear comments found before the different token, e.g. comma.
+      Comments.clear();
     }
   }
 

Modified: clang-tools-extra/trunk/test/clang-tidy/misc-argument-comment.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/misc-argument-comment.cpp?rev=293771&r1=293770&r2=293771&view=diff
==============================================================================
--- clang-tools-extra/trunk/test/clang-tidy/misc-argument-comment.cpp (original)
+++ clang-tools-extra/trunk/test/clang-tidy/misc-argument-comment.cpp Wed Feb  1 09:28:25 2017
@@ -13,6 +13,8 @@ void g() {
   // CHECK-MESSAGES: :[[@LINE-5]]:19: note: 'y' declared here
   f(/*y=*/0, /*z=*/0);
   // CHECK-FIXES: {{^}}  f(/*y=*/0, /*z=*/0);
+
+  ffff(0 /*aaaa=*/, /*bbbb*/ 0); // Unsupported formats.
 }
 
 struct Closure {};




More information about the cfe-commits mailing list