diff options
| author | Fariborz Jahanian <fjahanian@apple.com> | 2013-06-18 22:40:39 +0000 |
|---|---|---|
| committer | Fariborz Jahanian <fjahanian@apple.com> | 2013-06-18 22:40:39 +0000 |
| commit | 5222608310cec6739aaf9f5a22c74618d3c3bd5d (patch) | |
| tree | 374d0c4e67fb6bc150206ddc05cf6c62a369b8e0 /clang | |
| parent | a2e7f9ab2bc4a144f094b48850ce7431ebb69b93 (diff) | |
| download | bcm5719-llvm-5222608310cec6739aaf9f5a22c74618d3c3bd5d.tar.gz bcm5719-llvm-5222608310cec6739aaf9f5a22c74618d3c3bd5d.zip | |
doc. parsing: Allow parameter name "..." for variadic functions/methods.
// rdar://14124644
llvm-svn: 184249
Diffstat (limited to 'clang')
| -rw-r--r-- | clang/include/clang/AST/CommentSema.h | 1 | ||||
| -rw-r--r-- | clang/lib/AST/CommentSema.cpp | 16 | ||||
| -rw-r--r-- | clang/test/Sema/warn-documentation.m | 19 |
3 files changed, 35 insertions, 1 deletions
diff --git a/clang/include/clang/AST/CommentSema.h b/clang/include/clang/AST/CommentSema.h index 15e454dcc38..490b88c1bb1 100644 --- a/clang/include/clang/AST/CommentSema.h +++ b/clang/include/clang/AST/CommentSema.h @@ -220,6 +220,7 @@ public: bool isUnionDecl(); bool isObjCInterfaceDecl(); bool isObjCProtocolDecl(); + bool isFunctionOrMethodVariadic(); ArrayRef<const ParmVarDecl *> getParamVars(); diff --git a/clang/lib/AST/CommentSema.cpp b/clang/lib/AST/CommentSema.cpp index c242eb0f606..e6a5b85ed66 100644 --- a/clang/lib/AST/CommentSema.cpp +++ b/clang/lib/AST/CommentSema.cpp @@ -720,7 +720,7 @@ void Sema::resolveParamCommandIndexes(const FullComment *FC) { SmallVector<ParamCommandComment *, 8> ParamVarDocs; ArrayRef<const ParmVarDecl *> 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<ObjCMethodDecl>(ThisDeclInfo->CurrentDecl); } + +bool Sema::isFunctionOrMethodVariadic() { + if (!isAnyFunctionDecl() && !isObjCMethodDecl()) + return false; + if (const FunctionDecl *FD = + dyn_cast<FunctionDecl>(ThisDeclInfo->CurrentDecl)) + return FD->isVariadic(); + if (const ObjCMethodDecl *MD = + dyn_cast<ObjCMethodDecl>(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/clang/test/Sema/warn-documentation.m b/clang/test/Sema/warn-documentation.m index 17dd92e6eba..e348dba3e0c 100644 --- a/clang/test/Sema/warn-documentation.m +++ b/clang/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, ...); |

