[cfe-commits] r165039 - in /cfe/trunk: bindings/xml/comment-xml-schema.rng test/Index/Inputs/CommentXML/valid-deprecated-attr.xml test/Index/Inputs/CommentXML/valid-unavailable-attr.xml test/Index/annotate-comments-availability-attrs.cpp test/Index/comment-xml-schema.c tools/libclang/CXComment.cpp

Fariborz Jahanian fjahanian at apple.com
Tue Oct 2 13:05:47 PDT 2012


Author: fjahanian
Date: Tue Oct  2 15:05:47 2012
New Revision: 165039

URL: http://llvm.org/viewvc/llvm-project?rev=165039&view=rev
Log:
[Doc parsing]: Add available and deprecated attribute info
to XML output. // rdar://12378879

Added:
    cfe/trunk/test/Index/Inputs/CommentXML/valid-deprecated-attr.xml
    cfe/trunk/test/Index/Inputs/CommentXML/valid-unavailable-attr.xml
Modified:
    cfe/trunk/bindings/xml/comment-xml-schema.rng
    cfe/trunk/test/Index/annotate-comments-availability-attrs.cpp
    cfe/trunk/test/Index/comment-xml-schema.c
    cfe/trunk/tools/libclang/CXComment.cpp

Modified: cfe/trunk/bindings/xml/comment-xml-schema.rng
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/bindings/xml/comment-xml-schema.rng?rev=165039&r1=165038&r2=165039&view=diff
==============================================================================
--- cfe/trunk/bindings/xml/comment-xml-schema.rng (original)
+++ cfe/trunk/bindings/xml/comment-xml-schema.rng Tue Oct  2 15:05:47 2012
@@ -82,6 +82,12 @@
       <zeroOrMore>
         <ref name="Availability" />
       </zeroOrMore>
+      <zeroOrMore>
+        <ref name="Deprecated" />
+      </zeroOrMore>
+      <zeroOrMore>
+        <ref name="Unavailable" />
+      </zeroOrMore>
       <optional>
         <ref name="ResultDiscussion" />
       </optional>
@@ -313,13 +319,23 @@
         </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>

Added: cfe/trunk/test/Index/Inputs/CommentXML/valid-deprecated-attr.xml
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Index/Inputs/CommentXML/valid-deprecated-attr.xml?rev=165039&view=auto
==============================================================================
--- cfe/trunk/test/Index/Inputs/CommentXML/valid-deprecated-attr.xml (added)
+++ cfe/trunk/test/Index/Inputs/CommentXML/valid-deprecated-attr.xml Tue Oct  2 15:05:47 2012
@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Function>
+<Name>aaa</Name>
+<Abstract><Para>Aaa.</Para></Abstract>
+<Deprecated>true</Deprecated>
+</Function>

Added: cfe/trunk/test/Index/Inputs/CommentXML/valid-unavailable-attr.xml
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Index/Inputs/CommentXML/valid-unavailable-attr.xml?rev=165039&view=auto
==============================================================================
--- cfe/trunk/test/Index/Inputs/CommentXML/valid-unavailable-attr.xml (added)
+++ cfe/trunk/test/Index/Inputs/CommentXML/valid-unavailable-attr.xml Tue Oct  2 15:05:47 2012
@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Function>
+<Name>aaa</Name>
+<Abstract><Para>Aaa.</Para></Abstract>
+<Unavailable>true</Unavailable>
+</Function>

Modified: cfe/trunk/test/Index/annotate-comments-availability-attrs.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Index/annotate-comments-availability-attrs.cpp?rev=165039&r1=165038&r2=165039&view=diff
==============================================================================
--- cfe/trunk/test/Index/annotate-comments-availability-attrs.cpp (original)
+++ cfe/trunk/test/Index/annotate-comments-availability-attrs.cpp Tue Oct  2 15:05:47 2012
@@ -10,3 +10,20 @@
 
 
 // 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 at 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 at 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 at 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>

Modified: cfe/trunk/test/Index/comment-xml-schema.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Index/comment-xml-schema.c?rev=165039&r1=165038&r2=165039&view=diff
==============================================================================
--- cfe/trunk/test/Index/comment-xml-schema.c (original)
+++ cfe/trunk/test/Index/comment-xml-schema.c Tue Oct  2 15:05:47 2012
@@ -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

Modified: cfe/trunk/tools/libclang/CXComment.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/libclang/CXComment.cpp?rev=165039&r1=165038&r2=165039&view=diff
==============================================================================
--- cfe/trunk/tools/libclang/CXComment.cpp (original)
+++ cfe/trunk/tools/libclang/CXComment.cpp Tue Oct  2 15:05:47 2012
@@ -1175,8 +1175,13 @@
     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";





More information about the cfe-commits mailing list