regex for version tuples.
llvm-svn: 165104
</element>
</define>
- <define name="Availability">
- <element name="Availability">
- <attribute name="distribution">
- <data type="string" />
- </attribute>
- <optional>
- <element name="IntroducedInVersion">
- <data type="float" />
- </element>
- </optional>
- <optional>
- <element name="DeprecatedInVersion">
- <data type="float" />
- </element>
- </optional>
- <optional>
- <element name="RemovedAfterVersion">
- <data type="float" />
- </element>
- </optional>
- <optional>
- <element name="DeprecationSummary">
- <data type="string" />
- </element>
- </optional>
- <optional>
- <ref name="Unavailable" />
- </optional>
- </element>
- </define>
-
- <define name="Deprecated">
- <element name="Deprecated">
- <optional>
- <data type="string" />
- </optional>
- </element>
- </define>
-
- <define name="Unavailable">
- <element name="Unavailable">
- <optional>
- <data type="string" />
- </optional>
- </element>
- </define>
-
<define name="Abstract">
<element name="Abstract">
<zeroOrMore>
</element>
</define>
+ <define name="Availability">
+ <element name="Availability">
+ <attribute name="distribution">
+ <data type="string" />
+ </attribute>
+ <optional>
+ <element name="IntroducedInVersion">
+ <data type="string">
+ <param name="pattern">\d+|\d+\.\d+|\d+\.\d+.\d+</param>
+ </data>
+ </element>
+ </optional>
+ <optional>
+ <element name="DeprecatedInVersion">
+ <data type="string">
+ <param name="pattern">\d+|\d+\.\d+|\d+\.\d+.\d+</param>
+ </data>
+ </element>
+ </optional>
+ <optional>
+ <element name="RemovedAfterVersion">
+ <data type="string">
+ <param name="pattern">\d+|\d+\.\d+|\d+\.\d+.\d+</param>
+ </data>
+ </element>
+ </optional>
+ <optional>
+ <element name="DeprecationSummary">
+ <data type="string" />
+ </element>
+ </optional>
+ <optional>
+ <ref name="Unavailable" />
+ </optional>
+ </element>
+ </define>
+
+ <define name="Deprecated">
+ <element name="Deprecated">
+ <optional>
+ <data type="string" />
+ </optional>
+ </element>
+ </define>
+
+ <define name="Unavailable">
+ <element name="Unavailable">
+ <optional>
+ <data type="string" />
+ </optional>
+ </element>
+ </define>
+
<define name="ResultDiscussion">
<element name="ResultDiscussion">
<zeroOrMore>
--- /dev/null
+<?xml version="1.0" encoding="utf-8"?>
+<Function>
+<Name>aaa</Name>
+<Abstract><Para>Aaa.</Para></Abstract>
+<Availability distribution="OS X">
+ <IntroducedInVersion>8.0.1</IntroducedInVersion>
+ <DeprecatedInVersion>9.0.1</DeprecatedInVersion>
+ <RemovedAfterVersion>10.0.1</RemovedAfterVersion>
+ <DeprecationSummary>use availability_test</DeprecationSummary>
+</Availability>
+</Function>
-// RUN: c-index-test -test-load-source all -comments-xml-schema=%S/../../bindings/xml/comment-xml-schema.rng %s | FileCheck %s
// rdar://12378879
-/**
- * \param[in] arg1 ZZZ
- * \param[out] d xxx
-*/
-void cfunction_availability(int arg1, double d) __attribute__((availability(macosx,obsoleted=10.0,introduced=8.0,deprecated=9.0, message="use availability_test")))
- __attribute__((availability(ios,unavailable, message="not for iOS")));
+// RUN: rm -rf %t
+// RUN: mkdir %t
+// RUN: c-index-test -test-load-source all -comments-xml-schema=%S/../../bindings/xml/comment-xml-schema.rng %s > %t/out
+// RUN: FileCheck %s < %t/out
+// Ensure that XML we generate is not invalid.
+// RUN: FileCheck %s -check-prefix=WRONG < %t/out
+// WRONG-NOT: CommentXMLInvalid
-// 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/></Availability><Availability distribution="OS X"><IntroducedInVersion>8.0</IntroducedInVersion><DeprecatedInVersion>9.0</DeprecatedInVersion><RemovedAfterVersion>10.0</RemovedAfterVersion> <DeprecationSummary>use availability_test</DeprecationSummary></Availability></Function>]
+/// Aaa.
+void attr_availability_1() __attribute__((availability(macosx,obsoleted=10.0,introduced=8.0,deprecated=9.0, message="use availability_test in <foo.h>")))
+ __attribute__((availability(ios,unavailable, message="not for iOS")));
+// CHECK: annotate-comments-availability-attrs.cpp:13:6: FunctionDecl=attr_availability_1:{{.*}} FullCommentAsXML=[<Function file="{{[^"]+}}annotate-comments-availability-attrs.cpp" line="13" column="6"><Name>attr_availability_1</Name><USR>c:@F@attr_availability_1#</USR><Abstract><Para> Aaa.</Para></Abstract><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 in <foo.h></DeprecationSummary></Availability></Function>]
-/**
- * \param[in] arg1 ZZZ
- * \param[out] d xxx
- */
-void dep(int arg1, double d) __attribute__((deprecated));
+/// Aaa.
+void attr_availability_2() __attribute__((availability(macosx,obsoleted=10.0.1,introduced=8.0.1,deprecated=9.0.1)));
-// 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/></Function>
+// CHECK: annotate-comments-availability-attrs.cpp:19:6: FunctionDecl=attr_availability_2:{{.*}} FullCommentAsXML=[<Function file="{{[^"]+}}annotate-comments-availability-attrs.cpp" line="19" column="6"><Name>attr_availability_2</Name><USR>c:@F@attr_availability_2#</USR><Abstract><Para> Aaa.</Para></Abstract><Availability distribution="OS X"><IntroducedInVersion>8.0.1</IntroducedInVersion><DeprecatedInVersion>9.0.1</DeprecatedInVersion><RemovedAfterVersion>10.0.1</RemovedAfterVersion></Availability></Function>]
+/// Aaa.
+void attr_deprecated_1() __attribute__((deprecated));
-/**
- * \param[in] arg1 ZZZ
- */
-void unv(int arg1) __attribute__((unavailable));
+// CHECK: annotate-comments-availability-attrs.cpp:24:6: FunctionDecl=attr_deprecated_1:{{.*}} FullCommentAsXML=[<Function file="{{[^"]+}}annotate-comments-availability-attrs.cpp" line="24" column="6"><Name>attr_deprecated_1</Name><USR>c:@F@attr_deprecated_1#</USR><Abstract><Para> Aaa.</Para></Abstract><Deprecated/></Function>]
+
+/// Aaa.
+void attr_deprecated_2() __attribute__((deprecated("message 1 <foo.h>")));
+
+// CHECK: annotate-comments-availability-attrs.cpp:29:6: FunctionDecl=attr_deprecated_2:{{.*}} FullCommentAsXML=[<Function file="{{[^"]+}}annotate-comments-availability-attrs.cpp" line="29" column="6"><Name>attr_deprecated_2</Name><USR>c:@F@attr_deprecated_2#</USR><Abstract><Para> Aaa.</Para></Abstract><Deprecated>message 1 <foo.h></Deprecated></Function>]
+
+/// Aaa.
+void attr_unavailable_1() __attribute__((unavailable));
+
+// CHECK: annotate-comments-availability-attrs.cpp:34:6: FunctionDecl=attr_unavailable_1:{{.*}} FullCommentAsXML=[<Function file="{{[^"]+}}annotate-comments-availability-attrs.cpp" line="34" column="6"><Name>attr_unavailable_1</Name><USR>c:@F@attr_unavailable_1#</USR><Abstract><Para> Aaa.</Para></Abstract><Unavailable/></Function>]
+
+/// Aaa.
+void attr_unavailable_2() __attribute__((unavailable("message 2 <foo.h>")));
+
+// CHECK: annotate-comments-availability-attrs.cpp:39:6: FunctionDecl=attr_unavailable_2:{{.*}} FullCommentAsXML=[<Function file="{{[^"]+}}annotate-comments-availability-attrs.cpp" line="39" column="6"><Name>attr_unavailable_2</Name><USR>c:@F@attr_unavailable_2#</USR><Abstract><Para> Aaa.</Para></Abstract><Unavailable>message 2 <foo.h></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@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>
// 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-availability-attr-02.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
//
if (DA->getMessage().empty())
Result << "<Deprecated/>";
else {
- Result << "<Deprecated>"
- << DA->getMessage()
- << "</Deprecated>";
+ Result << "<Deprecated>";
+ appendToResultWithXMLEscaping(DA->getMessage());
+ Result << "</Deprecated>";
}
}
else if (const UnavailableAttr *UA = dyn_cast<UnavailableAttr>(Attrs[i])) {
if (UA->getMessage().empty())
Result << "<Unavailable/>";
else {
- Result << "<Unavailable>"
- << UA->getMessage()
- << "</Unavailable>";
+ Result << "<Unavailable>";
+ appendToResultWithXMLEscaping(UA->getMessage());
+ Result << "</Unavailable>";
}
}
continue;
<< RemovedAfterVersion.getAsString()
<< "</RemovedAfterVersion>";
}
- // 'deprecated' attribute.
StringRef DeprecationSummary = AA->getMessage();
if (!DeprecationSummary.empty()) {
- Result << " <DeprecationSummary>"
- << DeprecationSummary
- << "</DeprecationSummary>";
+ Result << "<DeprecationSummary>";
+ appendToResultWithXMLEscaping(DeprecationSummary);
+ Result << "</DeprecationSummary>";
}
- // 'unavailable' attribute.
if (AA->getUnavailable())
Result << "<Unavailable/>";
Result << "</Availability>";