]> granicus.if.org Git - clang/commitdiff
Attach any tag type's documentation to its typedef if
authorFariborz Jahanian <fjahanian@apple.com>
Sat, 26 Jan 2013 20:49:30 +0000 (20:49 +0000)
committerFariborz Jahanian <fjahanian@apple.com>
Sat, 26 Jan 2013 20:49:30 +0000 (20:49 +0000)
latter does not have one of its own. // rdar://13067629

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@173586 91177308-0d34-0410-b5e6-96231b3b80d8

lib/AST/ASTContext.cpp
test/Index/annotate-comments-typedef.m

index 7ba64e32f352a49547370b9032365ebbb0727ea1..91073077002fe717c7b5a8ea6be3cee7cc1dec75 100644 (file)
@@ -431,9 +431,9 @@ comments::FullComment *ASTContext::getCommentForDecl(
       // Attach enum's documentation to its typedef if latter
       // does not have one of its own.
       QualType QT = TD->getUnderlyingType();
-      if (const EnumType *ET = QT->getAs<EnumType>())
-        if (const EnumDecl *ED = ET->getDecl())
-          if (comments::FullComment *FC = getCommentForDecl(ED, PP))
+      if (const TagType *TT = QT->getAs<TagType>())
+        if (const Decl *TD = TT->getDecl())
+          if (comments::FullComment *FC = getCommentForDecl(TD, PP))
             return cloneFullComment(FC, D);
     }
     return NULL;
index 6e5fb735209036a4ae11ebae3286c7f798e3744a..784c51ec8c3fb9ff77f59706672a391876247c25 100644 (file)
@@ -28,3 +28,9 @@ enum E {
 };
 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@E</USR><Declaration>typedef enum E E_T</Declaration><Abstract><Para> Documentation for E </Para></Abstract></Typedef>]
+
+/** Comment about Foo */
+typedef struct {
+         int iii;
+        } Foo;
+// CHECK: TypedefDecl=Foo:[[@LINE-1]]:11 (Definition) FullCommentAsHTML=[<p class="para-brief"> Comment about Foo </p>] FullCommentAsXML=[<Typedef file="{{[^"]+}}annotate-comments-typedef.m" line="[[@LINE-1]]" column="11"><Name>&lt;anonymous&gt;</Name><USR>c:@SA@Foo</USR><Declaration>typedef struct Foo Foo</Declaration><Abstract><Para> Comment about Foo </Para></Abstract></Typedef>]