From: Alex Lorenz Date: Fri, 6 Oct 2017 20:51:04 +0000 (+0000) Subject: -Wdocumentation should allow '...' params in variadic function type aliases X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=c1458454c9b4c28723f31f50bbd97234cdee31de;p=clang -Wdocumentation should allow '...' params in variadic function type aliases rdar://34811344 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@315103 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/AST/CommentSema.cpp b/lib/AST/CommentSema.cpp index 403454d3ab..6c2019e1a7 100644 --- a/lib/AST/CommentSema.cpp +++ b/lib/AST/CommentSema.cpp @@ -813,7 +813,7 @@ bool Sema::isAnyFunctionDecl() { } bool Sema::isFunctionOrMethodVariadic() { - if (!isAnyFunctionDecl() && !isObjCMethodDecl() && !isFunctionTemplateDecl()) + if (!isFunctionDecl() || !ThisDeclInfo->CurrentDecl) return false; if (const FunctionDecl *FD = dyn_cast(ThisDeclInfo->CurrentDecl)) @@ -824,6 +824,14 @@ bool Sema::isFunctionOrMethodVariadic() { if (const ObjCMethodDecl *MD = dyn_cast(ThisDeclInfo->CurrentDecl)) return MD->isVariadic(); + if (const TypedefNameDecl *TD = + dyn_cast(ThisDeclInfo->CurrentDecl)) { + QualType Type = TD->getUnderlyingType(); + if (Type->isFunctionPointerType() || Type->isBlockPointerType()) + Type = Type->getPointeeType(); + if (const auto *FT = Type->getAs()) + return FT->isVariadic(); + } return false; } diff --git a/test/Sema/warn-documentation.cpp b/test/Sema/warn-documentation.cpp index ccf374ccd0..7ffaffc078 100644 --- a/test/Sema/warn-documentation.cpp +++ b/test/Sema/warn-documentation.cpp @@ -1282,3 +1282,25 @@ struct HasMoreFields { }; } + +/*! + * Function pointer typedef with variadic params. + * + * @param a + * works + * + * @param ... + * now should work too. + */ +typedef void (*VariadicFnType)(int a, ...); + +/*! + * Function pointer type alias with variadic params. + * + * @param a + * works + * + * @param ... + * now should work too. + */ +using VariadicFnType2 = void (*)(int a, ...); diff --git a/test/Sema/warn-documentation.m b/test/Sema/warn-documentation.m index 3c1a369c4b..18ab5bd9e0 100644 --- a/test/Sema/warn-documentation.m +++ b/test/Sema/warn-documentation.m @@ -299,3 +299,14 @@ void (^_Nullable blockPointerVariableThatLeadsNowhere)(); @property void (^blockReturnsNothing)(); @end + +/*! + * Block typedef with variadic params. + * + * @param a + * works + * + * @param ... + * now should work too. + */ +typedef void (^VariadicBlockType)(int a, ...);