r204235 - Comment parsing: recognize \param ... on function templates with variadic
Dmitri Gribenko
gribozavr at gmail.com
Wed Mar 19 06:59:36 PDT 2014
Author: gribozavr
Date: Wed Mar 19 08:59:36 2014
New Revision: 204235
URL: http://llvm.org/viewvc/llvm-project?rev=204235&view=rev
Log:
Comment parsing: recognize \param ... on function templates with variadic
parameters
Patch by Joe Ranieri.
Modified:
cfe/trunk/lib/AST/CommentSema.cpp
cfe/trunk/test/Sema/warn-documentation.cpp
Modified: cfe/trunk/lib/AST/CommentSema.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/CommentSema.cpp?rev=204235&r1=204234&r2=204235&view=diff
==============================================================================
--- cfe/trunk/lib/AST/CommentSema.cpp (original)
+++ cfe/trunk/lib/AST/CommentSema.cpp Wed Mar 19 08:59:36 2014
@@ -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<FunctionDecl>(ThisDeclInfo->CurrentDecl))
return FD->isVariadic();
+ if (const FunctionTemplateDecl *FTD =
+ dyn_cast<FunctionTemplateDecl>(ThisDeclInfo->CurrentDecl))
+ return FTD->getTemplatedDecl()->isVariadic();
if (const ObjCMethodDecl *MD =
dyn_cast<ObjCMethodDecl>(ThisDeclInfo->CurrentDecl))
return MD->isVariadic();
Modified: cfe/trunk/test/Sema/warn-documentation.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/warn-documentation.cpp?rev=204235&r1=204234&r2=204235&view=diff
==============================================================================
--- cfe/trunk/test/Sema/warn-documentation.cpp (original)
+++ cfe/trunk/test/Sema/warn-documentation.cpp Wed Mar 19 08:59:36 2014
@@ -371,6 +371,26 @@ int test_vararg_param3(int aaa);
int test_vararg_param4();
+/// \param aaa Aaa
+/// \param ... Vararg
+template<typename T>
+int test_template_vararg_param1(int aaa, ...);
+
+/// \param ... Vararg
+template<typename T>
+int test_template_vararg_param2(...);
+
+// expected-warning at +1 {{parameter '...' not found in the function declaration}} expected-note at +1 {{did you mean 'aaa'?}}
+/// \param ... Vararg
+template<typename T>
+int test_template_vararg_param3(int aaa);
+
+// expected-warning at +1 {{parameter '...' not found in the function declaration}}
+/// \param ... Vararg
+template<typename T>
+int test_template_vararg_param4();
+
+
// expected-warning at +1 {{'\tparam' command used in a comment that is not attached to a template declaration}}
/// \tparam T Aaa
int test_tparam1;
More information about the cfe-commits
mailing list