Skip to content
This repository was archived by the owner on Nov 1, 2021. It is now read-only.

Commit 2a46533

Browse files
author
Fariborz Jahanian
committed
[Doc parsing]: Add available and deprecated attribute info
to XML output. // rdar://12378879 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@165039 91177308-0d34-0410-b5e6-96231b3b80d8
1 parent 180d9d9 commit 2a46533

File tree

6 files changed

+56
-4
lines changed

6 files changed

+56
-4
lines changed

bindings/xml/comment-xml-schema.rng

+19-3
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,12 @@
8282
<zeroOrMore>
8383
<ref name="Availability" />
8484
</zeroOrMore>
85+
<zeroOrMore>
86+
<ref name="Deprecated" />
87+
</zeroOrMore>
88+
<zeroOrMore>
89+
<ref name="Unavailable" />
90+
</zeroOrMore>
8591
<optional>
8692
<ref name="ResultDiscussion" />
8793
</optional>
@@ -313,13 +319,23 @@
313319
</element>
314320
</optional>
315321
<optional>
316-
<element name="Unavailable">
317-
<data type="boolean" />
318-
</element>
322+
<ref name="Unavailable" />
319323
</optional>
320324
</element>
321325
</define>
322326

327+
<define name="Deprecated">
328+
<element name="Deprecated">
329+
<data type="boolean" />
330+
</element>
331+
</define>
332+
333+
<define name="Unavailable">
334+
<element name="Unavailable">
335+
<data type="boolean" />
336+
</element>
337+
</define>
338+
323339
<define name="Abstract">
324340
<element name="Abstract">
325341
<zeroOrMore>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Function>
3+
<Name>aaa</Name>
4+
<Abstract><Para>Aaa.</Para></Abstract>
5+
<Deprecated>true</Deprecated>
6+
</Function>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Function>
3+
<Name>aaa</Name>
4+
<Abstract><Para>Aaa.</Para></Abstract>
5+
<Unavailable>true</Unavailable>
6+
</Function>

test/Index/annotate-comments-availability-attrs.cpp

+17
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,20 @@ void cfunction_availability(int arg1, double d) __attribute__((availability(maco
1010

1111

1212
// CHECK: annotate-comments-availability-attrs.cpp:8:6: FunctionDecl=cfunction_availability:{{.*}} FullCommentAsXML=[<Function file="{{.*}}annotate-comments-availability-attrs.cpp" line="8" column="6"><Name>cfunction_availability</Name><USR>c:@F@cfunction_availability#I#d#</USR><Parameters><Parameter><Name>arg1</Name><Index>0</Index><Direction isExplicit="1">in</Direction><Discussion><Para> ZZZ </Para></Discussion></Parameter><Parameter><Name>d</Name><Index>1</Index><Direction isExplicit="1">out</Direction><Discussion><Para> xxx</Para></Discussion></Parameter></Parameters><Availability distribution="iOS"> <DeprecationSummary>not for iOS</DeprecationSummary><Unavailable>true</Unavailable></Availability><Availability distribution="OS X"><IntroducedInVersion>8.0</IntroducedInVersion><DeprecatedInVersion>9.0</DeprecatedInVersion><RemovedAfterVersion>10.0</RemovedAfterVersion> <DeprecationSummary>use availability_test</DeprecationSummary></Availability></Function>]
13+
14+
15+
/**
16+
* \param[in] arg1 ZZZ
17+
* \param[out] d xxx
18+
*/
19+
void dep(int arg1, double d) __attribute__((deprecated));
20+
21+
// CHECK: annotate-comments-availability-attrs.cpp:19:6: FunctionDecl=dep:{{.*}} FullCommentAsXML=[<Function file="{{.*}}annotate-comments-availability-attrs.cpp" line="19" column="6"><Name>dep</Name><USR>c:@F@dep#I#d#</USR><Parameters><Parameter><Name>arg1</Name><Index>0</Index><Direction isExplicit="1">in</Direction><Discussion><Para> ZZZ </Para></Discussion></Parameter><Parameter><Name>d</Name><Index>1</Index><Direction isExplicit="1">out</Direction><Discussion><Para> xxx </Para></Discussion></Parameter></Parameters><Deprecated>true</Deprecated></Function>
22+
23+
24+
/**
25+
* \param[in] arg1 ZZZ
26+
*/
27+
void unv(int arg1) __attribute__((unavailable));
28+
29+
// CHECK: annotate-comments-availability-attrs.cpp:27:6: FunctionDecl=unv:{{.*}} FullCommentAsXML=[<Function file="{{.*}}annotate-comments-availability-attrs.cpp" line="27" column="6"><Name>unv</Name><USR>c:@F@unv#I#</USR><Parameters><Parameter><Name>arg1</Name><Index>0</Index><Direction isExplicit="1">in</Direction><Discussion><Para> ZZZ </Para></Discussion></Parameter></Parameters><Unavailable>true</Unavailable></Function>

test/Index/comment-xml-schema.c

+2
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313
// RUN: xmllint --noout --relaxng %S/../../bindings/xml/comment-xml-schema.rng %S/Inputs/CommentXML/valid-function-09.xml
1414
//
1515
// RUN: xmllint --noout --relaxng %S/../../bindings/xml/comment-xml-schema.rng %S/Inputs/CommentXML/valid-availability-attr-01.xml
16+
// RUN: xmllint --noout --relaxng %S/../../bindings/xml/comment-xml-schema.rng %S/Inputs/CommentXML/valid-deprecated-attr.xml
17+
// RUN: xmllint --noout --relaxng %S/../../bindings/xml/comment-xml-schema.rng %S/Inputs/CommentXML/valid-unavailable-attr.xml
1618
//
1719
// RUN: xmllint --noout --relaxng %S/../../bindings/xml/comment-xml-schema.rng %S/Inputs/CommentXML/valid-class-01.xml
1820
// RUN: xmllint --noout --relaxng %S/../../bindings/xml/comment-xml-schema.rng %S/Inputs/CommentXML/valid-class-02.xml

tools/libclang/CXComment.cpp

+6-1
Original file line numberDiff line numberDiff line change
@@ -1175,8 +1175,13 @@ void CommentASTToXMLConverter::visitFullComment(const FullComment *C) {
11751175
const AttrVec &Attrs = DI->ThisDecl->getAttrs();
11761176
for (unsigned i = 0, e = Attrs.size(); i != e; i++) {
11771177
const AvailabilityAttr *AA = dyn_cast<AvailabilityAttr>(Attrs[i]);
1178-
if (!AA)
1178+
if (!AA) {
1179+
if (isa<DeprecatedAttr>(Attrs[i]))
1180+
Result << "<Deprecated>true</Deprecated>";
1181+
else if (isa<UnavailableAttr>(Attrs[i]))
1182+
Result << "<Unavailable>true</Unavailable>";
11791183
continue;
1184+
}
11801185

11811186
// 'availability' attribute.
11821187
Result << "<Availability";

0 commit comments

Comments
 (0)