summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlexander Kornienko <alexfh@google.com>2017-02-01 15:28:25 +0000
committerAlexander Kornienko <alexfh@google.com>2017-02-01 15:28:25 +0000
commit165fe63b4e16fe066663fbafffff5b49b95fd5e4 (patch)
tree4d3456f01f67fb94e25ee83991bd15202d27143d
parentc9a89f6936883f1a30a9ccc3fd5f74a3a74f6e33 (diff)
downloadbcm5719-llvm-165fe63b4e16fe066663fbafffff5b49b95fd5e4.tar.gz
bcm5719-llvm-165fe63b4e16fe066663fbafffff5b49b95fd5e4.zip
[clang-tidy] misc-argument-comment: ignore comments after arguments
llvm-svn: 293771
-rw-r--r--clang-tools-extra/clang-tidy/misc/ArgumentCommentCheck.cpp7
-rw-r--r--clang-tools-extra/test/clang-tidy/misc-argument-comment.cpp2
2 files changed, 7 insertions, 2 deletions
diff --git a/clang-tools-extra/clang-tidy/misc/ArgumentCommentCheck.cpp b/clang-tools-extra/clang-tidy/misc/ArgumentCommentCheck.cpp
index f80b9850afe..4c4e4a9ad32 100644
--- a/clang-tools-extra/clang-tidy/misc/ArgumentCommentCheck.cpp
+++ b/clang-tools-extra/clang-tidy/misc/ArgumentCommentCheck.cpp
@@ -67,16 +67,19 @@ getCommentsInRange(ASTContext *Ctx, CharSourceRange Range) {
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();
}
}
diff --git a/clang-tools-extra/test/clang-tidy/misc-argument-comment.cpp b/clang-tools-extra/test/clang-tidy/misc-argument-comment.cpp
index 37f0f9162d4..e20ba10f55f 100644
--- a/clang-tools-extra/test/clang-tidy/misc-argument-comment.cpp
+++ b/clang-tools-extra/test/clang-tidy/misc-argument-comment.cpp
@@ -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 {};
OpenPOWER on IntegriCloud