r177358 - documentation comment parsing. Added couple of

Fariborz Jahanian fjahanian at apple.com
Mon Mar 18 16:45:53 PDT 2013


Author: fjahanian
Date: Mon Mar 18 18:45:52 2013
New Revision: 177358

URL: http://llvm.org/viewvc/llvm-project?rev=177358&view=rev
Log:
documentation comment parsing. Added couple of 
top-level HeaderDoc tags @functiongroup and
@methodgroup to doc. tags recognized.
// rdar://12379114 

Modified:
    cfe/trunk/include/clang/AST/CommentCommands.td
    cfe/trunk/include/clang/Basic/DiagnosticCommentKinds.td
    cfe/trunk/lib/AST/CommentSema.cpp
    cfe/trunk/test/Sema/warn-documentation.m

Modified: cfe/trunk/include/clang/AST/CommentCommands.td
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/CommentCommands.td?rev=177358&r1=177357&r2=177358&view=diff
==============================================================================
--- cfe/trunk/include/clang/AST/CommentCommands.td (original)
+++ cfe/trunk/include/clang/AST/CommentCommands.td Mon Mar 18 18:45:52 2013
@@ -213,7 +213,9 @@ def Union     : RecordLikeDeclarationVer
 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">;

Modified: cfe/trunk/include/clang/Basic/DiagnosticCommentKinds.td
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticCommentKinds.td?rev=177358&r1=177357&r2=177358&view=diff
==============================================================================
--- cfe/trunk/include/clang/Basic/DiagnosticCommentKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticCommentKinds.td Mon Mar 18 18:45:52 2013
@@ -74,9 +74,10 @@ def warn_doc_param_not_attached_to_a_fun
   InGroup<Documentation>, 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<Documentation>, DefaultIgnore;
   
 def warn_doc_api_container_decl_mismatch : Warning<

Modified: cfe/trunk/lib/AST/CommentSema.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/CommentSema.cpp?rev=177358&r1=177357&r2=177358&view=diff
==============================================================================
--- cfe/trunk/lib/AST/CommentSema.cpp (original)
+++ cfe/trunk/lib/AST/CommentSema.cpp Mon Mar 18 18:45:52 2013
@@ -101,11 +101,17 @@ void Sema::checkFunctionDeclVerbatimLine
     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;

Modified: cfe/trunk/test/Sema/warn-documentation.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/warn-documentation.m?rev=177358&r1=177357&r2=177358&view=diff
==============================================================================
--- cfe/trunk/test/Sema/warn-documentation.m (original)
+++ cfe/trunk/test/Sema/warn-documentation.m Mon Mar 18 18:45:52 2013
@@ -123,6 +123,20 @@ typedef id OBJ;
 }
 @end
 
+// rdar://12379114
+// expected-warning at +4 {{'@methodgroup' command should be used in a comment attached to an Objective-C method declaration}}
+// expected-warning at +6 {{'@method' command should be used in a comment attached to an Objective-C method declaratio}}
+ at interface rdar12379114
+/*!
+ @methodgroup Creating a request
+*/
+/*!
+ @method initWithTimeout is the 2nd method
+*/
+typedef unsigned int NSTimeInterval;
+- (id)initWithTimeout:(NSTimeInterval)timeout;
+ at end
+
 // expected-warning at +2 {{'@protocol' command should not be used in a comment attached to a non-protocol declaration}}
 /*!
 @protocol PROTO





More information about the cfe-commits mailing list