r184329 - documentation parsing: patch to make @class work for

Fariborz Jahanian fjahanian at apple.com
Wed Jun 19 11:08:03 PDT 2013


Author: fjahanian
Date: Wed Jun 19 13:08:03 2013
New Revision: 184329

URL: http://llvm.org/viewvc/llvm-project?rev=184329&view=rev
Log:
documentation parsing: patch to make @class work for
class templates; and similarly, @function  works for 
function templates. // rdar://14124702

Modified:
    cfe/trunk/include/clang/AST/CommentSema.h
    cfe/trunk/lib/AST/CommentSema.cpp
    cfe/trunk/test/Sema/warn-documentation.cpp

Modified: cfe/trunk/include/clang/AST/CommentSema.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/CommentSema.h?rev=184329&r1=184328&r2=184329&view=diff
==============================================================================
--- cfe/trunk/include/clang/AST/CommentSema.h (original)
+++ cfe/trunk/include/clang/AST/CommentSema.h Wed Jun 19 13:08:03 2013
@@ -220,6 +220,8 @@ public:
   bool isUnionDecl();
   bool isObjCInterfaceDecl();
   bool isObjCProtocolDecl();
+  bool isClassTemplateDecl();
+  bool isFunctionTemplateDecl();
 
   ArrayRef<const ParmVarDecl *> getParamVars();
 

Modified: cfe/trunk/lib/AST/CommentSema.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/CommentSema.cpp?rev=184329&r1=184328&r2=184329&view=diff
==============================================================================
--- cfe/trunk/lib/AST/CommentSema.cpp (original)
+++ cfe/trunk/lib/AST/CommentSema.cpp Wed Jun 19 13:08:03 2013
@@ -99,10 +99,10 @@ void Sema::checkFunctionDeclVerbatimLine
   unsigned DiagSelect;
   switch (Comment->getCommandID()) {
     case CommandTraits::KCI_function:
-      DiagSelect = !isAnyFunctionDecl() ? 1 : 0;
+      DiagSelect = (!isAnyFunctionDecl() && !isFunctionTemplateDecl())? 1 : 0;
       break;
     case CommandTraits::KCI_functiongroup:
-      DiagSelect = !isAnyFunctionDecl() ? 2 : 0;
+      DiagSelect = (!isAnyFunctionDecl() && !isFunctionTemplateDecl())? 2 : 0;
       break;
     case CommandTraits::KCI_method:
       DiagSelect = !isObjCMethodDecl() ? 3 : 0;
@@ -131,7 +131,7 @@ void Sema::checkContainerDeclVerbatimLin
   unsigned DiagSelect;
   switch (Comment->getCommandID()) {
     case CommandTraits::KCI_class:
-      DiagSelect = !isClassOrStructDecl() ? 1 : 0;
+      DiagSelect = (!isClassOrStructDecl() && !isClassTemplateDecl()) ? 1 : 0;
       // Allow @class command on @interface declarations.
       // FIXME. Currently, \class and @class are indistinguishable. So,
       // \class is also allowed on an @interface declaration
@@ -870,6 +870,24 @@ bool Sema::isClassOrStructDecl() {
          isa<RecordDecl>(ThisDeclInfo->CurrentDecl) &&
          !isUnionDecl();
 }
+  
+bool Sema::isClassTemplateDecl() {
+  if (!ThisDeclInfo)
+    return false;
+  if (!ThisDeclInfo->IsFilled)
+    inspectThisDecl();
+  return ThisDeclInfo->CurrentDecl &&
+          (isa<ClassTemplateDecl>(ThisDeclInfo->CurrentDecl));
+}
+
+bool Sema::isFunctionTemplateDecl() {
+  if (!ThisDeclInfo)
+    return false;
+  if (!ThisDeclInfo->IsFilled)
+    inspectThisDecl();
+  return ThisDeclInfo->CurrentDecl &&
+  (isa<FunctionTemplateDecl>(ThisDeclInfo->CurrentDecl));
+}
 
 bool Sema::isObjCInterfaceDecl() {
   if (!ThisDeclInfo)

Modified: cfe/trunk/test/Sema/warn-documentation.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/warn-documentation.cpp?rev=184329&r1=184328&r2=184329&view=diff
==============================================================================
--- cfe/trunk/test/Sema/warn-documentation.cpp (original)
+++ cfe/trunk/test/Sema/warn-documentation.cpp Wed Jun 19 13:08:03 2013
@@ -950,3 +950,47 @@ class C1;
   @struct S3;
 */
 class S3;
+
+// rdar://14124702
+//----------------------------------------------------------------------
+/// @class Predicate Predicate.h "lldb/Host/Predicate.h"
+/// @brief A C++ wrapper class for providing threaded access to a value
+/// of type T.
+///
+/// A templatized class.
+/// specified values.
+//----------------------------------------------------------------------
+template <class T, class T1>
+class Predicate
+{
+};
+
+//----------------------------------------------------------------------
+/// @class Predicate<int, char> Predicate.h "lldb/Host/Predicate.h"
+/// @brief A C++ wrapper class for providing threaded access to a value
+/// of type T.
+///
+/// A template specilization class.
+//----------------------------------------------------------------------
+template<> class Predicate<int, char>
+{
+};
+
+//----------------------------------------------------------------------
+/// @class Predicate<T, int> Predicate.h "lldb/Host/Predicate.h"
+/// @brief A C++ wrapper class for providing threaded access to a value
+/// of type T.
+///
+/// A partial specialization template class.
+//----------------------------------------------------------------------
+template<class T> class Predicate<T, int>
+{
+};
+
+/*!     @function test_function
+*/
+template <class T> T test_function (T arg);
+
+/*!     @function test_function<int>
+*/
+template <> int test_function<int> (int arg);





More information about the cfe-commits mailing list