]> granicus.if.org Git - clang/commitdiff
[Doc parsing]: Add available and deprecated attribute info
authorFariborz Jahanian <fjahanian@apple.com>
Tue, 2 Oct 2012 20:05:47 +0000 (20:05 +0000)
committerFariborz Jahanian <fjahanian@apple.com>
Tue, 2 Oct 2012 20:05:47 +0000 (20:05 +0000)
to XML output. // rdar://12378879

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

bindings/xml/comment-xml-schema.rng
test/Index/Inputs/CommentXML/valid-deprecated-attr.xml [new file with mode: 0644]
test/Index/Inputs/CommentXML/valid-unavailable-attr.xml [new file with mode: 0644]
test/Index/annotate-comments-availability-attrs.cpp
test/Index/comment-xml-schema.c
tools/libclang/CXComment.cpp

index 1a2eb164419d434d771e4fa09f885cad364ee561..4197bc83a58b45097894de96df18a2beda136e22 100644 (file)
       <zeroOrMore>
         <ref name="Availability" />
       </zeroOrMore>
+      <zeroOrMore>
+        <ref name="Deprecated" />
+      </zeroOrMore>
+      <zeroOrMore>
+        <ref name="Unavailable" />
+      </zeroOrMore>
       <optional>
         <ref name="ResultDiscussion" />
       </optional>
         </element>
       </optional>
       <optional>
-        <element name="Unavailable">
-          <data type="boolean" />
-        </element>
+        <ref name="Unavailable" />
       </optional>
     </element>
   </define>
 
+  <define name="Deprecated">
+    <element name="Deprecated">
+      <data type="boolean" />
+    </element>
+  </define>
+
+  <define name="Unavailable">
+    <element name="Unavailable">
+      <data type="boolean" />
+    </element>
+  </define>
+
   <define name="Abstract">
     <element name="Abstract">
       <zeroOrMore>
diff --git a/test/Index/Inputs/CommentXML/valid-deprecated-attr.xml b/test/Index/Inputs/CommentXML/valid-deprecated-attr.xml
new file mode 100644 (file)
index 0000000..5452b93
--- /dev/null
@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Function>
+<Name>aaa</Name>
+<Abstract><Para>Aaa.</Para></Abstract>
+<Deprecated>true</Deprecated>
+</Function>
diff --git a/test/Index/Inputs/CommentXML/valid-unavailable-attr.xml b/test/Index/Inputs/CommentXML/valid-unavailable-attr.xml
new file mode 100644 (file)
index 0000000..342ce44
--- /dev/null
@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Function>
+<Name>aaa</Name>
+<Abstract><Para>Aaa.</Para></Abstract>
+<Unavailable>true</Unavailable>
+</Function>
index 6fb99a1b5c6d6f041cc89b99e83479fa498fe10b..cc3af073ecc78be55afa3d9246f2d7bbec5daee0 100644 (file)
@@ -10,3 +10,20 @@ void cfunction_availability(int arg1, double d) __attribute__((availability(maco
 
 
 // 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>]
+
+
+/**
+ * \param[in] arg1 ZZZ
+ * \param[out] d xxx
+ */
+void dep(int arg1, double d) __attribute__((deprecated));
+
+// 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>
+
+
+/**
+ * \param[in] arg1 ZZZ
+ */
+void unv(int arg1) __attribute__((unavailable));
+
+// 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>
index dad6c8a6948a26df8eaed2a1aa56f29a7cd62334..7e7e3315f176d1de2924c0175c2e0a57ae7bbb34 100644 (file)
@@ -13,6 +13,8 @@
 // RUN: xmllint --noout --relaxng %S/../../bindings/xml/comment-xml-schema.rng %S/Inputs/CommentXML/valid-function-09.xml
 //
 // RUN: xmllint --noout --relaxng %S/../../bindings/xml/comment-xml-schema.rng %S/Inputs/CommentXML/valid-availability-attr-01.xml
+// RUN: xmllint --noout --relaxng %S/../../bindings/xml/comment-xml-schema.rng %S/Inputs/CommentXML/valid-deprecated-attr.xml
+// RUN: xmllint --noout --relaxng %S/../../bindings/xml/comment-xml-schema.rng %S/Inputs/CommentXML/valid-unavailable-attr.xml
 //
 // RUN: xmllint --noout --relaxng %S/../../bindings/xml/comment-xml-schema.rng %S/Inputs/CommentXML/valid-class-01.xml
 // RUN: xmllint --noout --relaxng %S/../../bindings/xml/comment-xml-schema.rng %S/Inputs/CommentXML/valid-class-02.xml
index 1e0679f22a62fcce05a50149194713a91c0ff2de..a0a5512814a559bbafcde86ba17454f0bedc6329 100644 (file)
@@ -1175,8 +1175,13 @@ void CommentASTToXMLConverter::visitFullComment(const FullComment *C) {
     const AttrVec &Attrs = DI->ThisDecl->getAttrs();
     for (unsigned i = 0, e = Attrs.size(); i != e; i++) {
       const AvailabilityAttr *AA = dyn_cast<AvailabilityAttr>(Attrs[i]);
-      if (!AA)
+      if (!AA) {
+        if (isa<DeprecatedAttr>(Attrs[i]))
+          Result << "<Deprecated>true</Deprecated>";
+        else if (isa<UnavailableAttr>(Attrs[i]))
+          Result << "<Unavailable>true</Unavailable>";
         continue;
+      }
 
       // 'availability' attribute.
       Result << "<Availability";