[cfe-commits] r165066 - 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 tools/libclang/CXComment.cpp
Fariborz Jahanian
fjahanian at apple.com
Tue Oct 2 16:01:04 PDT 2012
Author: fjahanian
Date: Tue Oct 2 18:01:04 2012
New Revision: 165066
URL: http://llvm.org/viewvc/llvm-project?rev=165066&view=rev
Log:
[Doc parse]: SUpport for message in deprecated/unavailable
attribute going iinto XML document.
Modified:
cfe/trunk/bindings/xml/comment-xml-schema.rng
cfe/trunk/test/Index/Inputs/CommentXML/valid-deprecated-attr.xml
cfe/trunk/test/Index/Inputs/CommentXML/valid-unavailable-attr.xml
cfe/trunk/test/Index/annotate-comments-availability-attrs.cpp
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=165066&r1=165065&r2=165066&view=diff
==============================================================================
--- cfe/trunk/bindings/xml/comment-xml-schema.rng (original)
+++ cfe/trunk/bindings/xml/comment-xml-schema.rng Tue Oct 2 18:01:04 2012
@@ -326,13 +326,17 @@
<define name="Deprecated">
<element name="Deprecated">
- <data type="boolean" />
+ <optional>
+ <data type="string" />
+ </optional>
</element>
</define>
<define name="Unavailable">
<element name="Unavailable">
- <data type="boolean" />
+ <optional>
+ <data type="string" />
+ </optional>
</element>
</define>
Modified: 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=165066&r1=165065&r2=165066&view=diff
==============================================================================
--- cfe/trunk/test/Index/Inputs/CommentXML/valid-deprecated-attr.xml (original)
+++ cfe/trunk/test/Index/Inputs/CommentXML/valid-deprecated-attr.xml Tue Oct 2 18:01:04 2012
@@ -2,5 +2,5 @@
<Function>
<Name>aaa</Name>
<Abstract><Para>Aaa.</Para></Abstract>
-<Deprecated>true</Deprecated>
+<Deprecated>since OS X 10.6</Deprecated>
</Function>
Modified: 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=165066&r1=165065&r2=165066&view=diff
==============================================================================
--- cfe/trunk/test/Index/Inputs/CommentXML/valid-unavailable-attr.xml (original)
+++ cfe/trunk/test/Index/Inputs/CommentXML/valid-unavailable-attr.xml Tue Oct 2 18:01:04 2012
@@ -2,5 +2,6 @@
<Function>
<Name>aaa</Name>
<Abstract><Para>Aaa.</Para></Abstract>
-<Unavailable>true</Unavailable>
+<Deprecated>Since iOS 4.0</Deprecated>
+<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=165066&r1=165065&r2=165066&view=diff
==============================================================================
--- cfe/trunk/test/Index/annotate-comments-availability-attrs.cpp (original)
+++ cfe/trunk/test/Index/annotate-comments-availability-attrs.cpp Tue Oct 2 18:01:04 2012
@@ -9,7 +9,7 @@
__attribute__((availability(ios,unavailable, message="not for iOS")));
-// 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>]
+// 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/></Availability><Availability distribution="OS X"><IntroducedInVersion>8.0</IntroducedInVersion><DeprecatedInVersion>9.0</DeprecatedInVersion><RemovedAfterVersion>10.0</RemovedAfterVersion> <DeprecationSummary>use availability_test</DeprecationSummary></Availability></Function>]
/**
@@ -18,7 +18,7 @@
*/
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>
+// 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/></Function>
/**
@@ -26,4 +26,4 @@
*/
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>
+// 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/></Function>
Modified: cfe/trunk/tools/libclang/CXComment.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/libclang/CXComment.cpp?rev=165066&r1=165065&r2=165066&view=diff
==============================================================================
--- cfe/trunk/tools/libclang/CXComment.cpp (original)
+++ cfe/trunk/tools/libclang/CXComment.cpp Tue Oct 2 18:01:04 2012
@@ -1176,10 +1176,24 @@
for (unsigned i = 0, e = Attrs.size(); i != e; i++) {
const AvailabilityAttr *AA = dyn_cast<AvailabilityAttr>(Attrs[i]);
if (!AA) {
- if (isa<DeprecatedAttr>(Attrs[i]))
- Result << "<Deprecated>true</Deprecated>";
- else if (isa<UnavailableAttr>(Attrs[i]))
- Result << "<Unavailable>true</Unavailable>";
+ if (const DeprecatedAttr *DA = dyn_cast<DeprecatedAttr>(Attrs[i])) {
+ if (DA->getMessage().empty())
+ Result << "<Deprecated/>";
+ else {
+ Result << "<Deprecated>"
+ << DA->getMessage()
+ << "</Deprecated>";
+ }
+ }
+ else if (const UnavailableAttr *UA = dyn_cast<UnavailableAttr>(Attrs[i])) {
+ if (UA->getMessage().empty())
+ Result << "<Unavailable/>";
+ else {
+ Result << "<Unavailable>"
+ << UA->getMessage()
+ << "</Unavailable>";
+ }
+ }
continue;
}
@@ -1220,7 +1234,7 @@
}
// 'unavailable' attribute.
if (AA->getUnavailable())
- Result << "<Unavailable>true</Unavailable>";
+ Result << "<Unavailable/>";
Result << "</Availability>";
}
}
More information about the cfe-commits
mailing list