From abbcbaeb4ce5b28bf188ce406e3541c00063db12 Mon Sep 17 00:00:00 2001 From: Fariborz Jahanian Date: Mon, 18 Mar 2013 23:45:52 +0000 Subject: [PATCH] documentation comment parsing. Added couple of top-level HeaderDoc tags @functiongroup and @methodgroup to doc. tags recognized. // rdar://12379114 llvm-svn: 177358 --- clang/include/clang/AST/CommentCommands.td | 2 ++ .../include/clang/Basic/DiagnosticCommentKinds.td | 7 ++++--- clang/lib/AST/CommentSema.cpp | 10 ++++++++-- clang/test/Sema/warn-documentation.m | 14 ++++++++++++++ 4 files changed, 28 insertions(+), 5 deletions(-) diff --git a/clang/include/clang/AST/CommentCommands.td b/clang/include/clang/AST/CommentCommands.td index e2178342270b..9587ace87caf 100644 --- a/clang/include/clang/AST/CommentCommands.td +++ b/clang/include/clang/AST/CommentCommands.td @@ -213,7 +213,9 @@ def Union : RecordLikeDeclarationVerbatimLineCommand<"union">; def Category : DeclarationVerbatimLineCommand<"category">; def Template : DeclarationVerbatimLineCommand<"template">; def Function : FunctionDeclarationVerbatimLineCommand<"function">; +def FunctionGroup : FunctionDeclarationVerbatimLineCommand<"functiongroup">; def Method : FunctionDeclarationVerbatimLineCommand<"method">; +def MethodGroup : FunctionDeclarationVerbatimLineCommand<"methodgroup">; def Callback : FunctionDeclarationVerbatimLineCommand<"callback">; def Const : DeclarationVerbatimLineCommand<"const">; def Constant : DeclarationVerbatimLineCommand<"constant">; diff --git a/clang/include/clang/Basic/DiagnosticCommentKinds.td b/clang/include/clang/Basic/DiagnosticCommentKinds.td index 7682b85a137a..3880e0e5b4fa 100644 --- a/clang/include/clang/Basic/DiagnosticCommentKinds.td +++ b/clang/include/clang/Basic/DiagnosticCommentKinds.td @@ -74,9 +74,10 @@ def warn_doc_param_not_attached_to_a_function_decl : Warning< InGroup, DefaultIgnore; def warn_doc_function_method_decl_mismatch : Warning< - "'%select{\\|@}0%select{function|method|callback}1' command should be " - "used in a comment attached to " - "%select{a function|an Objective-C method|a pointer to function}2 declaration">, + "'%select{\\|@}0%select{function|functiongroup|method|methodgroup|callback}1' " + "command should be used in a comment attached to " + "%select{a function|a function|an Objective-C method|an Objective-C method|" + "a pointer to function}2 declaration">, InGroup, DefaultIgnore; def warn_doc_api_container_decl_mismatch : Warning< diff --git a/clang/lib/AST/CommentSema.cpp b/clang/lib/AST/CommentSema.cpp index e6367c97557c..e0138d5f3f27 100644 --- a/clang/lib/AST/CommentSema.cpp +++ b/clang/lib/AST/CommentSema.cpp @@ -101,11 +101,17 @@ void Sema::checkFunctionDeclVerbatimLine(const BlockCommandComment *Comment) { case CommandTraits::KCI_function: DiagSelect = !isAnyFunctionDecl() ? 1 : 0; break; + case CommandTraits::KCI_functiongroup: + DiagSelect = !isAnyFunctionDecl() ? 2 : 0; + break; case CommandTraits::KCI_method: - DiagSelect = !isObjCMethodDecl() ? 2 : 0; + DiagSelect = !isObjCMethodDecl() ? 3 : 0; + break; + case CommandTraits::KCI_methodgroup: + DiagSelect = !isObjCMethodDecl() ? 4 : 0; break; case CommandTraits::KCI_callback: - DiagSelect = !isFunctionPointerVarDecl() ? 3 : 0; + DiagSelect = !isFunctionPointerVarDecl() ? 5 : 0; break; default: DiagSelect = 0; diff --git a/clang/test/Sema/warn-documentation.m b/clang/test/Sema/warn-documentation.m index 98c499356183..1e3acf1d7238 100644 --- a/clang/test/Sema/warn-documentation.m +++ b/clang/test/Sema/warn-documentation.m @@ -123,6 +123,20 @@ typedef id OBJ; } @end +// rdar://12379114 +// expected-warning@+4 {{'@methodgroup' command should be used in a comment attached to an Objective-C method declaration}} +// expected-warning@+6 {{'@method' command should be used in a comment attached to an Objective-C method declaratio}} +@interface rdar12379114 +/*! + @methodgroup Creating a request +*/ +/*! + @method initWithTimeout is the 2nd method +*/ +typedef unsigned int NSTimeInterval; +- (id)initWithTimeout:(NSTimeInterval)timeout; +@end + // expected-warning@+2 {{'@protocol' command should not be used in a comment attached to a non-protocol declaration}} /*! @protocol PROTO