From 7e5e2d0c53b1b7253621d955089c0d14fe2a8078 Mon Sep 17 00:00:00 2001 From: Fariborz Jahanian Date: Tue, 18 Jun 2013 22:40:39 +0000 Subject: [PATCH] doc. parsing: Allow parameter name "..." for variadic functions/methods. // rdar://14124644 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@184249 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/clang/AST/CommentSema.h | 1 + lib/AST/CommentSema.cpp | 16 +++++++++++++++- test/Sema/warn-documentation.m | 19 +++++++++++++++++++ 3 files changed, 35 insertions(+), 1 deletion(-) diff --git a/include/clang/AST/CommentSema.h b/include/clang/AST/CommentSema.h index 15e454dcc3..490b88c1bb 100644 --- a/include/clang/AST/CommentSema.h +++ b/include/clang/AST/CommentSema.h @@ -220,6 +220,7 @@ public: bool isUnionDecl(); bool isObjCInterfaceDecl(); bool isObjCProtocolDecl(); + bool isFunctionOrMethodVariadic(); ArrayRef getParamVars(); diff --git a/lib/AST/CommentSema.cpp b/lib/AST/CommentSema.cpp index c242eb0f60..e6a5b85ed6 100644 --- a/lib/AST/CommentSema.cpp +++ b/lib/AST/CommentSema.cpp @@ -720,7 +720,7 @@ void Sema::resolveParamCommandIndexes(const FullComment *FC) { SmallVector ParamVarDocs; ArrayRef ParamVars = getParamVars(); - ParamVarDocs.resize(ParamVars.size(), NULL); + ParamVarDocs.resize(ParamVars.size() + isFunctionOrMethodVariadic(), NULL); // First pass over all \\param commands: resolve all parameter names. for (Comment::child_iterator I = FC->child_begin(), E = FC->child_end(); @@ -808,6 +808,18 @@ bool Sema::isObjCMethodDecl() { return isFunctionDecl() && ThisDeclInfo->CurrentDecl && isa(ThisDeclInfo->CurrentDecl); } + +bool Sema::isFunctionOrMethodVariadic() { + if (!isAnyFunctionDecl() && !isObjCMethodDecl()) + return false; + if (const FunctionDecl *FD = + dyn_cast(ThisDeclInfo->CurrentDecl)) + return FD->isVariadic(); + if (const ObjCMethodDecl *MD = + dyn_cast(ThisDeclInfo->CurrentDecl)) + return MD->isVariadic(); + return false; +} /// isFunctionPointerVarDecl - returns 'true' if declaration is a pointer to /// function decl. @@ -906,6 +918,8 @@ unsigned Sema::resolveParmVarReference(StringRef Name, if (II && II->getName() == Name) return i; } + if (Name == "..." && isFunctionOrMethodVariadic()) + return ParamVars.size(); return ParamCommandComment::InvalidParamIndex; } diff --git a/test/Sema/warn-documentation.m b/test/Sema/warn-documentation.m index 17dd92e6eb..e348dba3e0 100644 --- a/test/Sema/warn-documentation.m +++ b/test/Sema/warn-documentation.m @@ -215,3 +215,22 @@ int FooBar(); /// \brief comment -(void)meth {} @end + +// rdar://14124644 +@interface rdar14124644 +/// @param[in] arg somthing +/// @param[in] ... This is vararg +- (void) VarArgMeth : (id)arg, ...; +@end + +@implementation rdar14124644 +/// @param[in] arg somthing +/// @param[in] ... This is vararg +- (void) VarArgMeth : (id)arg, ... {} +@end + +/// @param[in] format somthing +/// @param[in] ... +/// Variable arguments that are needed for the printf style +/// format string \a format. +int printf(const char* format, ...); -- 2.40.0