From: Dmitri Gribenko Date: Wed, 19 Mar 2014 13:59:36 +0000 (+0000) Subject: Comment parsing: recognize \param ... on function templates with variadic X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=2fea8f7f7c5e519c65194544adde16a0d83433a6;p=clang Comment parsing: recognize \param ... on function templates with variadic parameters Patch by Joe Ranieri. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@204235 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/AST/CommentSema.cpp b/lib/AST/CommentSema.cpp index 0ae00820fd..e51f8781c1 100644 --- a/lib/AST/CommentSema.cpp +++ b/lib/AST/CommentSema.cpp @@ -792,11 +792,14 @@ bool Sema::isAnyFunctionDecl() { } bool Sema::isFunctionOrMethodVariadic() { - if (!isAnyFunctionDecl() && !isObjCMethodDecl()) + if (!isAnyFunctionDecl() && !isObjCMethodDecl() && !isFunctionTemplateDecl()) return false; if (const FunctionDecl *FD = dyn_cast(ThisDeclInfo->CurrentDecl)) return FD->isVariadic(); + if (const FunctionTemplateDecl *FTD = + dyn_cast(ThisDeclInfo->CurrentDecl)) + return FTD->getTemplatedDecl()->isVariadic(); if (const ObjCMethodDecl *MD = dyn_cast(ThisDeclInfo->CurrentDecl)) return MD->isVariadic(); diff --git a/test/Sema/warn-documentation.cpp b/test/Sema/warn-documentation.cpp index ad7ab181a7..ed25d949f5 100644 --- a/test/Sema/warn-documentation.cpp +++ b/test/Sema/warn-documentation.cpp @@ -371,6 +371,26 @@ int test_vararg_param3(int aaa); int test_vararg_param4(); +/// \param aaa Aaa +/// \param ... Vararg +template +int test_template_vararg_param1(int aaa, ...); + +/// \param ... Vararg +template +int test_template_vararg_param2(...); + +// expected-warning@+1 {{parameter '...' not found in the function declaration}} expected-note@+1 {{did you mean 'aaa'?}} +/// \param ... Vararg +template +int test_template_vararg_param3(int aaa); + +// expected-warning@+1 {{parameter '...' not found in the function declaration}} +/// \param ... Vararg +template +int test_template_vararg_param4(); + + // expected-warning@+1 {{'\tparam' command used in a comment that is not attached to a template declaration}} /// \tparam T Aaa int test_tparam1;