[clang-tools-extra] r217039 - ClangTidy misc-argument-comment check: don't check arguments to template
Alexander Kornienko
alexfh at google.com
Wed Sep 3 07:56:30 PDT 2014
Author: alexfh
Date: Wed Sep 3 09:56:30 2014
New Revision: 217039
URL: http://llvm.org/viewvc/llvm-project?rev=217039&view=rev
Log:
ClangTidy misc-argument-comment check: don't check arguments to template
parameter packs.
Summary:
This disables this check for std::bind and similar functions that use
parameter packs to forward arguments to a different function. Name of the
parameter pack argument doesn't matter.
Reviewers: klimek
Reviewed By: klimek
Subscribers: cfe-commits
Differential Revision: http://reviews.llvm.org/D5168
Modified:
clang-tools-extra/trunk/clang-tidy/misc/ArgumentCommentCheck.cpp
clang-tools-extra/trunk/test/clang-tidy/arg-comments.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=217039&r1=217038&r2=217039&view=diff
==============================================================================
--- clang-tools-extra/trunk/clang-tidy/misc/ArgumentCommentCheck.cpp (original)
+++ clang-tools-extra/trunk/clang-tidy/misc/ArgumentCommentCheck.cpp Wed Sep 3 09:56:30 2014
@@ -119,6 +119,15 @@ void ArgumentCommentCheck::checkCallArgs
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)
Modified: clang-tools-extra/trunk/test/clang-tidy/arg-comments.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/arg-comments.cpp?rev=217039&r1=217038&r2=217039&view=diff
==============================================================================
--- clang-tools-extra/trunk/test/clang-tidy/arg-comments.cpp (original)
+++ clang-tools-extra/trunk/test/clang-tidy/arg-comments.cpp Wed Sep 3 09:56:30 2014
@@ -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'
+}
More information about the cfe-commits
mailing list