forked from OSchip/llvm-project
availability in structured documents. Takes
care of comments by Dimitri and Doug. llvm-svn: 164957
This commit is contained in:
parent
3c837abd2b
commit
c491c3f27a
|
@ -80,7 +80,7 @@
|
||||||
<ref name="Parameters" />
|
<ref name="Parameters" />
|
||||||
</optional>
|
</optional>
|
||||||
<zeroOrMore>
|
<zeroOrMore>
|
||||||
<ref name="Attribute" />
|
<ref name="Availability" />
|
||||||
</zeroOrMore>
|
</zeroOrMore>
|
||||||
<optional>
|
<optional>
|
||||||
<ref name="ResultDiscussion" />
|
<ref name="ResultDiscussion" />
|
||||||
|
@ -287,7 +287,7 @@
|
||||||
</element>
|
</element>
|
||||||
</define>
|
</define>
|
||||||
|
|
||||||
<define name="Attribute">
|
<define name="Availability">
|
||||||
<element name="Availability">
|
<element name="Availability">
|
||||||
<attribute name="distribution">
|
<attribute name="distribution">
|
||||||
<data type="string" />
|
<data type="string" />
|
||||||
|
|
|
@ -190,7 +190,7 @@ def Availability : InheritableAttr {
|
||||||
[{static llvm::StringRef getPrettyPlatformName(llvm::StringRef Platform) {
|
[{static llvm::StringRef getPrettyPlatformName(llvm::StringRef Platform) {
|
||||||
return llvm::StringSwitch<llvm::StringRef>(Platform)
|
return llvm::StringSwitch<llvm::StringRef>(Platform)
|
||||||
.Case("ios", "iOS")
|
.Case("ios", "iOS")
|
||||||
.Case("macosx", "Mac OS X")
|
.Case("macosx", "OS X")
|
||||||
.Default(llvm::StringRef());
|
.Default(llvm::StringRef());
|
||||||
} }];
|
} }];
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,7 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<Availability distribution="OS X">
|
||||||
|
<IntroducedInVersion>8.0</IntroducedInVersion>
|
||||||
|
<DeprecatedInVersion>9.0</DeprecatedInVersion>
|
||||||
|
<RemovedAfterVersion>10.0</RemovedAfterVersion>
|
||||||
|
<DeprecationSummary>use availability_test</DeprecationSummary>
|
||||||
|
</Availability>
|
|
@ -0,0 +1,12 @@
|
||||||
|
// 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")));
|
||||||
|
|
||||||
|
|
||||||
|
// 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>]
|
|
@ -10,10 +10,10 @@ void f5(int) __attribute__((availability(ios,introduced=3.2), availability(macos
|
||||||
void test() {
|
void test() {
|
||||||
f0(0);
|
f0(0);
|
||||||
f1(0);
|
f1(0);
|
||||||
f2(0); // expected-warning{{'f2' is deprecated: first deprecated in Mac OS X 10.5}}
|
f2(0); // expected-warning{{'f2' is deprecated: first deprecated in OS X 10.5}}
|
||||||
f3(0);
|
f3(0);
|
||||||
f4(0); // expected-error{{f4' is unavailable: obsoleted in Mac OS X 10.5}}
|
f4(0); // expected-error{{f4' is unavailable: obsoleted in OS X 10.5}}
|
||||||
f5(0); // expected-error{{'f5' is unavailable: not available on Mac OS X}}
|
f5(0); // expected-error{{'f5' is unavailable: not available on OS X}}
|
||||||
}
|
}
|
||||||
|
|
||||||
// rdar://10535640
|
// rdar://10535640
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
// RUN: %clang_cc1 -triple x86_64-apple-darwin9 -fsyntax-only -verify %s
|
// RUN: %clang_cc1 -triple x86_64-apple-darwin9 -fsyntax-only -verify %s
|
||||||
|
|
||||||
void f0() __attribute__((availability(macosx,introduced=10.4,deprecated=10.2))); // expected-warning{{feature cannot be deprecated in Mac OS X version 10.2 before it was introduced in version 10.4; attribute ignored}}
|
void f0() __attribute__((availability(macosx,introduced=10.4,deprecated=10.2))); // expected-warning{{feature cannot be deprecated in OS X version 10.2 before it was introduced in version 10.4; attribute ignored}}
|
||||||
void f1() __attribute__((availability(ios,obsoleted=2.1,deprecated=3.0))); // expected-warning{{feature cannot be obsoleted in iOS version 2.1 before it was deprecated in version 3.0; attribute ignored}}
|
void f1() __attribute__((availability(ios,obsoleted=2.1,deprecated=3.0))); // expected-warning{{feature cannot be obsoleted in iOS version 2.1 before it was deprecated in version 3.0; attribute ignored}}
|
||||||
void f2() __attribute__((availability(ios,introduced=2.1,deprecated=2.1)));
|
void f2() __attribute__((availability(ios,introduced=2.1,deprecated=2.1)));
|
||||||
|
|
||||||
|
@ -14,8 +14,8 @@ extern void
|
||||||
ATSFontGetPostScriptName(int flags) __attribute__((availability(macosx,introduced=8.0,obsoleted=9.0, message="use ATSFontGetFullPostScriptName"))); // expected-note {{function has been explicitly marked unavailable here}}
|
ATSFontGetPostScriptName(int flags) __attribute__((availability(macosx,introduced=8.0,obsoleted=9.0, message="use ATSFontGetFullPostScriptName"))); // expected-note {{function has been explicitly marked unavailable here}}
|
||||||
|
|
||||||
void test_10095131() {
|
void test_10095131() {
|
||||||
ATSFontGetName("Hello"); // expected-warning {{'ATSFontGetName' is deprecated: first deprecated in Mac OS X 9.0 - use CTFontCopyFullName}}
|
ATSFontGetName("Hello"); // expected-warning {{'ATSFontGetName' is deprecated: first deprecated in OS X 9.0 - use CTFontCopyFullName}}
|
||||||
ATSFontGetPostScriptName(100); // expected-error {{'ATSFontGetPostScriptName' is unavailable: obsoleted in Mac OS X 9.0 - use ATSFontGetFullPostScriptName}}
|
ATSFontGetPostScriptName(100); // expected-error {{'ATSFontGetPostScriptName' is unavailable: obsoleted in OS X 9.0 - use ATSFontGetFullPostScriptName}}
|
||||||
}
|
}
|
||||||
|
|
||||||
// rdar://10711037
|
// rdar://10711037
|
||||||
|
|
|
@ -14,8 +14,8 @@
|
||||||
@end
|
@end
|
||||||
|
|
||||||
void f(A *a, B *b) {
|
void f(A *a, B *b) {
|
||||||
[a method]; // expected-warning{{'method' is deprecated: first deprecated in Mac OS X 10.2}}
|
[a method]; // expected-warning{{'method' is deprecated: first deprecated in OS X 10.2}}
|
||||||
[b method]; // expected-warning {{'method' is deprecated: first deprecated in Mac OS X 10.2}}
|
[b method]; // expected-warning {{'method' is deprecated: first deprecated in OS X 10.2}}
|
||||||
[a proto_method]; // expected-warning{{'proto_method' is deprecated: first deprecated in Mac OS X 10.2}}
|
[a proto_method]; // expected-warning{{'proto_method' is deprecated: first deprecated in OS X 10.2}}
|
||||||
[b proto_method]; // expected-warning{{'proto_method' is deprecated: first deprecated in Mac OS X 10.2}}
|
[b proto_method]; // expected-warning{{'proto_method' is deprecated: first deprecated in OS X 10.2}}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1173,59 +1173,53 @@ void CommentASTToXMLConverter::visitFullComment(const FullComment *C) {
|
||||||
|
|
||||||
if (DI->ThisDecl->hasAttrs()) {
|
if (DI->ThisDecl->hasAttrs()) {
|
||||||
const AttrVec &Attrs = DI->ThisDecl->getAttrs();
|
const AttrVec &Attrs = DI->ThisDecl->getAttrs();
|
||||||
for (unsigned i = 0, e = Attrs.size(); i != e;) {
|
for (unsigned i = 0, e = Attrs.size(); i != e; i++) {
|
||||||
const AvailabilityAttr *AA = dyn_cast<AvailabilityAttr>(Attrs[i++]);
|
const AvailabilityAttr *AA = dyn_cast<AvailabilityAttr>(Attrs[i]);
|
||||||
if (!AA)
|
if (!AA)
|
||||||
continue;
|
continue;
|
||||||
// availability attribute info.
|
|
||||||
|
// 'availability' attribute.
|
||||||
Result << "<Availability";
|
Result << "<Availability";
|
||||||
StringRef distribution;
|
StringRef Distribution;
|
||||||
if (AA->getPlatform()) {
|
if (AA->getPlatform()) {
|
||||||
distribution = AA->getPlatform()->getName();
|
Distribution = AvailabilityAttr::getPrettyPlatformName(
|
||||||
if (distribution == "macosx")
|
AA->getPlatform()->getName());
|
||||||
distribution = "OSX";
|
if (Distribution.empty())
|
||||||
else
|
Distribution = AA->getPlatform()->getName();
|
||||||
distribution = "iOS";
|
|
||||||
}
|
}
|
||||||
|
Result << " distribution=\"" << Distribution << "\">";
|
||||||
Result << " distribution=\"";
|
|
||||||
Result << distribution;
|
|
||||||
Result << "\">";
|
|
||||||
VersionTuple IntroducedInVersion = AA->getIntroduced();
|
VersionTuple IntroducedInVersion = AA->getIntroduced();
|
||||||
if (!IntroducedInVersion.empty()) {
|
if (!IntroducedInVersion.empty()) {
|
||||||
Result << " <IntroducedInVersion>";
|
Result << "<IntroducedInVersion>"
|
||||||
Result << IntroducedInVersion.getAsString();
|
<< IntroducedInVersion.getAsString()
|
||||||
Result << "</IntroducedInVersion>";
|
<< "</IntroducedInVersion>";
|
||||||
}
|
}
|
||||||
VersionTuple DeprecatedInVersion = AA->getDeprecated();
|
VersionTuple DeprecatedInVersion = AA->getDeprecated();
|
||||||
if (!DeprecatedInVersion.empty()) {
|
if (!DeprecatedInVersion.empty()) {
|
||||||
Result << " <DeprecatedInVersion>";
|
Result << "<DeprecatedInVersion>"
|
||||||
Result << DeprecatedInVersion.getAsString();
|
<< DeprecatedInVersion.getAsString()
|
||||||
Result << "</DeprecatedInVersion>";
|
<< "</DeprecatedInVersion>";
|
||||||
}
|
}
|
||||||
VersionTuple RemovedAfterVersion = AA->getObsoleted();
|
VersionTuple RemovedAfterVersion = AA->getObsoleted();
|
||||||
if (!RemovedAfterVersion.empty()) {
|
if (!RemovedAfterVersion.empty()) {
|
||||||
Result << " <RemovedAfterVersion>";
|
Result << "<RemovedAfterVersion>"
|
||||||
Result << RemovedAfterVersion.getAsString();
|
<< RemovedAfterVersion.getAsString()
|
||||||
Result << "</RemovedAfterVersion>";
|
<< "</RemovedAfterVersion>";
|
||||||
}
|
}
|
||||||
|
// 'deprecated' attribute.
|
||||||
StringRef DeprecationSummary = AA->getMessage();
|
StringRef DeprecationSummary = AA->getMessage();
|
||||||
if (!DeprecationSummary.empty()) {
|
if (!DeprecationSummary.empty()) {
|
||||||
Result << " <DeprecationSummary>";
|
Result << " <DeprecationSummary>"
|
||||||
Result << DeprecationSummary;
|
<< DeprecationSummary
|
||||||
Result << "</DeprecationSummary>";
|
<< "</DeprecationSummary>";
|
||||||
}
|
}
|
||||||
Result << " <Unavailable>";
|
// 'unavailable' attribute.
|
||||||
if (AA->getUnavailable())
|
if (AA->getUnavailable())
|
||||||
Result << "true";
|
Result << "<Unavailable>true</Unavailable>";
|
||||||
else
|
Result << "</Availability>";
|
||||||
Result << "false";
|
|
||||||
Result << "</Unavailable>";
|
|
||||||
Result << " </Availability>";
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
bool StartTagEmitted = false;
|
bool StartTagEmitted = false;
|
||||||
for (unsigned i = 0, e = Parts.MiscBlocks.size(); i != e; ++i) {
|
for (unsigned i = 0, e = Parts.MiscBlocks.size(); i != e; ++i) {
|
||||||
|
|
Loading…
Reference in New Issue