]> granicus.if.org Git - clang/commitdiff
-Wdocumentation should allow '...' params in variadic function type aliases
authorAlex Lorenz <arphaman@gmail.com>
Fri, 6 Oct 2017 20:51:04 +0000 (20:51 +0000)
committerAlex Lorenz <arphaman@gmail.com>
Fri, 6 Oct 2017 20:51:04 +0000 (20:51 +0000)
rdar://34811344

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@315103 91177308-0d34-0410-b5e6-96231b3b80d8

lib/AST/CommentSema.cpp
test/Sema/warn-documentation.cpp
test/Sema/warn-documentation.m

index 403454d3ab7e63eaeb43b3191168cbdaa3be5087..6c2019e1a72b602fa402b31ccfc7f9c16a1163d0 100644 (file)
@@ -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<FunctionDecl>(ThisDeclInfo->CurrentDecl))
@@ -824,6 +824,14 @@ bool Sema::isFunctionOrMethodVariadic() {
   if (const ObjCMethodDecl *MD =
         dyn_cast<ObjCMethodDecl>(ThisDeclInfo->CurrentDecl))
     return MD->isVariadic();
+  if (const TypedefNameDecl *TD =
+          dyn_cast<TypedefNameDecl>(ThisDeclInfo->CurrentDecl)) {
+    QualType Type = TD->getUnderlyingType();
+    if (Type->isFunctionPointerType() || Type->isBlockPointerType())
+      Type = Type->getPointeeType();
+    if (const auto *FT = Type->getAs<FunctionProtoType>())
+      return FT->isVariadic();
+  }
   return false;
 }
 
index ccf374ccd060963083425fbab03918ec0a537e44..7ffaffc078494100c9dbe8cdd53cab0fae265d12 100644 (file)
@@ -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, ...);
index 3c1a369c4b14b69b3fda121dcc67a502639099bd..18ab5bd9e0968c5bbc63ba17603fb1764eb51947 100644 (file)
@@ -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, ...);