[PATCH] D67080: [clang-tidy] Fix bugprone-argument-comment bug if there are marcos.

2019-09-04 Thread Alexander Kornienko via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL370919: [clang-tidy] Fix bugprone-argument-comment bug if 
there are marcos. (authored by alexfh, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D67080?vs=218372=218730#toc

Repository:
  rL LLVM

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

https://reviews.llvm.org/D67080

Files:
  clang-tools-extra/trunk/clang-tidy/bugprone/ArgumentCommentCheck.cpp
  clang-tools-extra/trunk/test/clang-tidy/bugprone-argument-comment-literals.cpp


Index: 
clang-tools-extra/trunk/test/clang-tidy/bugprone-argument-comment-literals.cpp
===
--- 
clang-tools-extra/trunk/test/clang-tidy/bugprone-argument-comment-literals.cpp
+++ 
clang-tools-extra/trunk/test/clang-tidy/bugprone-argument-comment-literals.cpp
@@ -15,10 +15,12 @@
 };
 
 #define FOO 1
+#define X(x) (x)
 
 void g(int a);
 void h(double b);
 void i(const char *c);
+void j(int a, int b, int c);
 
 double operator"" _km(long double);
 
@@ -106,6 +108,39 @@
   // CHECK-FIXES: h(/*b=*/1.0f);
   i(__FILE__);
 
+  j(1, X(1), X(1));
+  // CHECK-MESSAGES: [[@LINE-1]]:5: warning: argument comment missing for 
literal argument 'a' [bugprone-argument-comment]
+  // CHECK-FIXES: j(/*a=*/1, X(1), X(1));
+  j(/*a=*/1, X(1), X(1));
+
+  j(X(1), 1, X(1));
+  // CHECK-MESSAGES: [[@LINE-1]]:11: warning: argument comment missing for 
literal argument 'b' [bugprone-argument-comment]
+  // CHECK-FIXES: j(X(1), /*b=*/1, X(1));
+  j(X(1), /*b=*/1, X(1));
+
+  j(X(1), X(1), 1);
+  // CHECK-MESSAGES: [[@LINE-1]]:17: warning: argument comment missing for 
literal argument 'c' [bugprone-argument-comment]
+  // CHECK-FIXES: j(X(1), X(1), /*c=*/1);
+  j(X(1), X(1), /*c=*/1);
+
+  j(X(1), 1, 1);
+  // CHECK-MESSAGES: [[@LINE-1]]:11: warning: argument comment missing for 
literal argument 'b' [bugprone-argument-comment]
+  // CHECK-MESSAGES: [[@LINE-2]]:14: warning: argument comment missing for 
literal argument 'c' [bugprone-argument-comment]
+  // CHECK-FIXES: j(X(1), /*b=*/1, /*c=*/1);
+  j(X(1), /*b=*/1, /*c=*/1);
+
+  j(1, X(1), 1);
+  // CHECK-MESSAGES: [[@LINE-1]]:5: warning: argument comment missing for 
literal argument 'a' [bugprone-argument-comment]
+  // CHECK-MESSAGES: [[@LINE-2]]:14: warning: argument comment missing for 
literal argument 'c' [bugprone-argument-comment]
+  // CHECK-FIXES: j(/*a=*/1, X(1), /*c=*/1);
+  j(/*a=*/1, X(1), /*c=*/1);
+
+  j(1, 1, X(1));
+  // CHECK-MESSAGES: [[@LINE-1]]:5: warning: argument comment missing for 
literal argument 'a' [bugprone-argument-comment]
+  // CHECK-MESSAGES: [[@LINE-2]]:8: warning: argument comment missing for 
literal argument 'b' [bugprone-argument-comment]
+  // CHECK-FIXES: j(/*a=*/1, /*b=*/1, X(1));
+  j(/*a=*/1, /*b=*/1, X(1));
+
   // FIXME Would like the below to add argument comments.
   g((1));
   // FIXME But we should not add argument comments here.
Index: clang-tools-extra/trunk/clang-tidy/bugprone/ArgumentCommentCheck.cpp
===
--- clang-tools-extra/trunk/clang-tidy/bugprone/ArgumentCommentCheck.cpp
+++ clang-tools-extra/trunk/clang-tidy/bugprone/ArgumentCommentCheck.cpp
@@ -286,8 +286,8 @@
   Comments = getCommentsInRange(Ctx, BeforeArgument);
 } else {
   // Fall back to parsing back from the start of the argument.
-  CharSourceRange ArgsRange = MakeFileCharRange(
-  Args[I]->getBeginLoc(), Args[NumArgs - 1]->getEndLoc());
+  CharSourceRange ArgsRange =
+  MakeFileCharRange(Args[I]->getBeginLoc(), Args[I]->getEndLoc());
   Comments = getCommentsBeforeLoc(Ctx, ArgsRange.getBegin());
 }
 


Index: clang-tools-extra/trunk/test/clang-tidy/bugprone-argument-comment-literals.cpp
===
--- clang-tools-extra/trunk/test/clang-tidy/bugprone-argument-comment-literals.cpp
+++ clang-tools-extra/trunk/test/clang-tidy/bugprone-argument-comment-literals.cpp
@@ -15,10 +15,12 @@
 };
 
 #define FOO 1
+#define X(x) (x)
 
 void g(int a);
 void h(double b);
 void i(const char *c);
+void j(int a, int b, int c);
 
 double operator"" _km(long double);
 
@@ -106,6 +108,39 @@
   // CHECK-FIXES: h(/*b=*/1.0f);
   i(__FILE__);
 
+  j(1, X(1), X(1));
+  // CHECK-MESSAGES: [[@LINE-1]]:5: warning: argument comment missing for literal argument 'a' [bugprone-argument-comment]
+  // CHECK-FIXES: j(/*a=*/1, X(1), X(1));
+  j(/*a=*/1, X(1), X(1));
+
+  j(X(1), 1, X(1));
+  // CHECK-MESSAGES: [[@LINE-1]]:11: warning: argument comment missing for literal argument 'b' [bugprone-argument-comment]
+  // CHECK-FIXES: j(X(1), /*b=*/1, X(1));
+  j(X(1), /*b=*/1, X(1));
+
+  j(X(1), X(1), 1);
+  // CHECK-MESSAGES: [[@LINE-1]]:17: warning: argument comment missing for literal argument 'c' [bugprone-argument-comment]
+  // 

[PATCH] D67080: [clang-tidy] Fix bugprone-argument-comment bug if there are marcos.

2019-09-04 Thread Yubo Xie via Phabricator via cfe-commits
xyb added a comment.

Thanks. BTW, I can't commit the patch by myself.


Repository:
  rCTE Clang Tools Extra

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

https://reviews.llvm.org/D67080



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D67080: [clang-tidy] Fix bugprone-argument-comment bug if there are marcos.

2019-09-04 Thread Alexander Kornienko via Phabricator via cfe-commits
alexfh accepted this revision.
alexfh added a comment.
This revision is now accepted and ready to land.

LG. Thanks!




Comment at: clang-tools-extra/clang-tidy/bugprone/ArgumentCommentCheck.cpp:326
+  CharSourceRange ArgsRange =
+  MakeFileCharRange(Args[I]->getBeginLoc(), Args[I]->getEndLoc());
   Comments = getCommentsBeforeLoc(Ctx, ArgsRange.getBegin());

I don't know what motivation was to try parsing to the end of the arguments.  
But since no tests break, it should be fine to change.


Repository:
  rCTE Clang Tools Extra

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

https://reviews.llvm.org/D67080



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits