summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--clang-tools-extra/clang-tidy/misc/ArgumentCommentCheck.cpp9
-rw-r--r--clang-tools-extra/test/clang-tidy/arg-comments.cpp17
2 files changed, 23 insertions, 3 deletions
diff --git a/clang-tools-extra/clang-tidy/misc/ArgumentCommentCheck.cpp b/clang-tools-extra/clang-tidy/misc/ArgumentCommentCheck.cpp
index 4f7b535bd56..c408c9cabe6 100644
--- a/clang-tools-extra/clang-tidy/misc/ArgumentCommentCheck.cpp
+++ b/clang-tools-extra/clang-tidy/misc/ArgumentCommentCheck.cpp
@@ -119,6 +119,15 @@ void ArgumentCommentCheck::checkCallArgs(ASTContext *Ctx,
IdentifierInfo *II = PVD->getIdentifier();
if (!II)
continue;
+ if (auto Template = Callee->getTemplateInstantiationPattern()) {
+ // Don't warn on arguments for parameters instantiated from template
+ // parameter packs. If we find more arguments than the template definition
+ // has, it also means that they correspond to a parameter pack.
+ if (Template->getNumParams() <= i ||
+ Template->getParamDecl(i)->isParameterPack()) {
+ continue;
+ }
+ }
SourceLocation BeginSLoc, EndSLoc = Args[i]->getLocStart();
if (i == 0)
diff --git a/clang-tools-extra/test/clang-tidy/arg-comments.cpp b/clang-tools-extra/test/clang-tidy/arg-comments.cpp
index 57deb1dc647..922c26627cb 100644
--- a/clang-tools-extra/test/clang-tidy/arg-comments.cpp
+++ b/clang-tools-extra/test/clang-tidy/arg-comments.cpp
@@ -7,11 +7,10 @@ void ffff(int xxxx, int yyyy);
void f(int x, int y);
void g() {
- // CHECK: [[@LINE+5]]:5: warning: argument name 'y' in comment does not match parameter name 'x'
+ // CHECK: [[@LINE+4]]:5: warning: argument name 'y' in comment does not match parameter name 'x'
// CHECK: :[[@LINE-3]]:12: note: 'x' declared here
- // CHECK: [[@LINE+3]]:14: warning: argument name 'z' in comment does not match parameter name 'y'
+ // CHECK: [[@LINE+2]]:14: warning: argument name 'z' in comment does not match parameter name 'y'
// CHECK: :[[@LINE-5]]:19: note: 'y' declared here
- // CHECK-NOT: warning
f(/*y=*/0, /*z=*/0);
}
@@ -27,3 +26,15 @@ void h() {
(void)NewCallback(&ffff, /*xxxx=*/11, /*yyyy=*/22);
(void)NewPermanentCallback(&ffff, /*xxxx=*/11, /*yyyy=*/22);
}
+
+template<typename... Args>
+void variadic(Args&&... args);
+
+template<typename... Args>
+void variadic2(int zzz, Args&&... args);
+
+void templates() {
+ variadic(/*xxx=*/0, /*yyy=*/1);
+ variadic2(/*zzZ=*/0, /*xxx=*/1, /*yyy=*/2);
+ // CHECK: [[@LINE-1]]:13: warning: argument name 'zzZ' in comment does not match parameter name 'zzz'
+}
OpenPOWER on IntegriCloud