[cfe-commits] r173516 - in /cfe/trunk: lib/AST/ASTContext.cpp test/Index/annotate-comments-typedef.m

Fariborz Jahanian fjahanian at apple.com
Fri Jan 25 14:48:32 PST 2013


Author: fjahanian
Date: Fri Jan 25 16:48:32 2013
New Revision: 173516

URL: http://llvm.org/viewvc/llvm-project?rev=173516&view=rev
Log:
Attach enum's documentation to its typedef if
latter does not have one of its own. // rdar://13067629

Added:
    cfe/trunk/test/Index/annotate-comments-typedef.m
Modified:
    cfe/trunk/lib/AST/ASTContext.cpp

Modified: cfe/trunk/lib/AST/ASTContext.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ASTContext.cpp?rev=173516&r1=173515&r2=173516&view=diff
==============================================================================
--- cfe/trunk/lib/AST/ASTContext.cpp (original)
+++ cfe/trunk/lib/AST/ASTContext.cpp Fri Jan 25 16:48:32 2013
@@ -434,6 +434,16 @@ comments::FullComment *ASTContext::getCo
         }
       }
     }
+    else if (const TypedefDecl *TD = dyn_cast<TypedefDecl>(D)) {
+      QualType QT = TD->getUnderlyingType();
+      if (const EnumType *ET = QT->getAs<EnumType>()) {
+        if (const EnumDecl *ED = ET->getDecl())
+          if (comments::FullComment *FC = getCommentForDecl(ED, PP)) {
+            comments::FullComment *CFC = cloneFullComment(FC, D);
+            return CFC;
+          }
+      }
+    }
     return NULL;
   }
   

Added: cfe/trunk/test/Index/annotate-comments-typedef.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Index/annotate-comments-typedef.m?rev=173516&view=auto
==============================================================================
--- cfe/trunk/test/Index/annotate-comments-typedef.m (added)
+++ cfe/trunk/test/Index/annotate-comments-typedef.m Fri Jan 25 16:48:32 2013
@@ -0,0 +1,30 @@
+// RUN: rm -rf %t
+// RUN: mkdir %t
+// RUN: c-index-test -test-load-source all -comments-xml-schema=%S/../../bindings/xml/comment-xml-schema.rng %s > %t/out
+// RUN: FileCheck %s < %t/out
+// rdar://13067629
+
+// Ensure that XML we generate is not invalid.
+// RUN: FileCheck %s -check-prefix=WRONG < %t/out
+// WRONG-NOT: CommentXMLInvalid
+
+/** Documentation for NSUInteger */
+typedef unsigned int NSUInteger;
+
+/** Documentation for MyEnum */
+typedef enum : NSUInteger {
+        MyEnumFoo, /**< value Foo */
+        MyEnumBar, /**< value Bar */
+        MyEnumBaz, /**< value Baz */
+} MyEnum;
+// CHECK: TypedefDecl=MyEnum:[[@LINE-1]]:3 (Definition) FullCommentAsHTML=[<p class="para-brief"> Documentation for MyEnum </p>] FullCommentAsXML=[<Typedef file="{{[^"]+}}annotate-comments-typedef.m" line="[[@LINE-1]]" column="3"><Name><anonymous></Name><USR>c:@EA at MyEnum</USR><Declaration>typedef enum MyEnum MyEnum</Declaration><Abstract><Para> Documentation for MyEnum </Para></Abstract></Typedef>] CommentXMLValid
+
+
+/** Documentation for E */
+enum E {
+        MyEnumFoo, /**< value Foo */
+        MyEnumBar, /**< value Bar */
+        MyEnumBaz, /**< value Baz */
+};
+typedef enum E E_T;
+// CHECK: TypedefDecl=E_T:[[@LINE-1]]:16 (Definition) FullCommentAsHTML=[<p class="para-brief"> Documentation for E </p>] FullCommentAsXML=[<Typedef file="{{[^"]+}}annotate-comments-typedef.m" line="[[@LINE-1]]" column="16"><Name>E</Name><USR>c:@E at E</USR><Declaration>typedef enum E E_T</Declaration><Abstract><Para> Documentation for E </Para></Abstract></Typedef>] CommentXMLValid





More information about the cfe-commits mailing list