[cfe-commits] r173626 - Comment parsing: attach any tag type's documentation to its typedef if latter
Dmitri Gribenko
gribozavr at gmail.com
Sun Jan 27 13:18:39 PST 2013
Author: gribozavr
Date: Sun Jan 27 15:18:39 2013
New Revision: 173626
URL: http://llvm.org/viewvc/llvm-project?rev=173626&view=rev
Log:
Comment parsing: attach any tag type's documentation to its typedef if latter
does not have one of its own. // rdar://13067629
Original patch (r173586 and r173587) by Fariborz Jahanian, modified by me.
Modified:
cfe/trunk/lib/AST/ASTContext.cpp
cfe/trunk/test/Index/annotate-comments-typedef.m
cfe/trunk/test/Sema/warn-documentation.cpp
Modified: cfe/trunk/lib/AST/ASTContext.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ASTContext.cpp?rev=173626&r1=173625&r2=173626&view=diff
==============================================================================
--- cfe/trunk/lib/AST/ASTContext.cpp (original)
+++ cfe/trunk/lib/AST/ASTContext.cpp Sun Jan 27 15:18:39 2013
@@ -85,6 +85,14 @@ RawComment *ASTContext::getRawCommentFor
return NULL;
}
+ if (const ClassTemplateSpecializationDecl *CTSD =
+ dyn_cast<ClassTemplateSpecializationDecl>(D)) {
+ TemplateSpecializationKind TSK = CTSD->getSpecializationKind();
+ if (TSK == TSK_ImplicitInstantiation ||
+ TSK == TSK_Undeclared)
+ return NULL;
+ }
+
if (const EnumDecl *ED = dyn_cast<EnumDecl>(D)) {
if (ED->getTemplateSpecializationKind() == TSK_ImplicitInstantiation)
return NULL;
@@ -428,12 +436,12 @@ comments::FullComment *ASTContext::getCo
return cloneFullComment(FC, D);
}
else if (const TypedefDecl *TD = dyn_cast<TypedefDecl>(D)) {
- // Attach enum's documentation to its typedef if latter
+ // Attach any tag type'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;
Modified: cfe/trunk/test/Index/annotate-comments-typedef.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Index/annotate-comments-typedef.m?rev=173626&r1=173625&r2=173626&view=diff
==============================================================================
--- cfe/trunk/test/Index/annotate-comments-typedef.m (original)
+++ cfe/trunk/test/Index/annotate-comments-typedef.m Sun Jan 27 15:18:39 2013
@@ -27,4 +27,23 @@ enum E {
E_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>]
+// CHECK: EnumDecl=E:[[@LINE-6]]:6 (Definition) {{.*}} BriefComment=[Documentation for E] FullCommentAsHTML=[<p class="para-brief"> Documentation for E </p>] FullCommentAsXML=[<Enum file="{{[^"]+}}annotate-comments-typedef.m" line="[[@LINE-6]]" column="6"><Name>E</Name><USR>c:@E at E</USR><Declaration>enum E {}</Declaration><Abstract><Para> Documentation for E </Para></Abstract></Enum>]
+// CHECK: TypedefDecl=E_T:[[@LINE-2]]:16 (Definition) FullCommentAsHTML=[<p class="para-brief"> Documentation for E </p>] FullCommentAsXML=[<Typedef file="{{[^"]+}}annotate-comments-typedef.m" line="[[@LINE-2]]" 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>]
+
+
+/** 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><anonymous></Name><USR>c:@SA at Foo</USR><Declaration>typedef struct Foo Foo</Declaration><Abstract><Para> Comment about Foo </Para></Abstract></Typedef>]
+// CHECK: StructDecl=:[[@LINE-4]]:9 (Definition) {{.*}} BriefComment=[Comment about Foo] FullCommentAsHTML=[<p class="para-brief"> Comment about Foo </p>] FullCommentAsXML=[<Class file="{{[^"]+}}annotate-comments-typedef.m" line="[[@LINE-4]]" column="9"><Name><anonymous></Name><USR>c:@SA at Foo</USR><Declaration>struct {}</Declaration><Abstract><Para> Comment about Foo </Para></Abstract></Class>]
+
+
+struct Foo1 {
+ int iii;
+};
+/** About Foo1T */
+typedef struct Foo1 Foo1T;
+// FIXME: we don't attach this comment to 'struct Foo1'
+// CHECK: TypedefDecl=Foo1T:[[@LINE-2]]:21 (Definition) {{.*}} FullCommentAsHTML=[<p class="para-brief"> About Foo1T </p>] FullCommentAsXML=[<Typedef file="{{[^"]+}}annotate-comments-typedef.m" line="[[@LINE-2]]" column="21"><Name>Foo1T</Name><USR>c:annotate-comments-typedef.m@{{[0-9]+}}@T at Foo1T</USR><Declaration>typedef struct Foo1 Foo1T</Declaration><Abstract><Para> About Foo1T </Para></Abstract></Typedef>]
+
Modified: cfe/trunk/test/Sema/warn-documentation.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/warn-documentation.cpp?rev=173626&r1=173625&r2=173626&view=diff
==============================================================================
--- cfe/trunk/test/Sema/warn-documentation.cpp (original)
+++ cfe/trunk/test/Sema/warn-documentation.cpp Sun Jan 27 15:18:39 2013
@@ -377,6 +377,29 @@ using test_tparam14 = test_tparam13<T, i
template<typename T>
using test_tparam15 = test_tparam13<T, int>;
+// ----
+
+/// \tparam T Aaa
+template<typename T>
+class test_tparam16 { };
+
+typedef test_tparam16<int> test_tparam17;
+typedef test_tparam16<double> test_tparam18;
+
+// ----
+
+template<typename T>
+class test_tparam19;
+
+typedef test_tparam19<int> test_tparam20;
+typedef test_tparam19<double> test_tparam21;
+
+/// \tparam T Aaa
+template<typename T>
+class test_tparam19 { };
+
+// ----
+
/// Aaa
/// \deprecated Bbb
More information about the cfe-commits
mailing list