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" />
|
||||
</optional>
|
||||
<zeroOrMore>
|
||||
<ref name="Attribute" />
|
||||
<ref name="Availability" />
|
||||
</zeroOrMore>
|
||||
<optional>
|
||||
<ref name="ResultDiscussion" />
|
||||
|
@ -287,7 +287,7 @@
|
|||
</element>
|
||||
</define>
|
||||
|
||||
<define name="Attribute">
|
||||
<define name="Availability">
|
||||
<element name="Availability">
|
||||
<attribute name="distribution">
|
||||
<data type="string" />
|
||||
|
|
|
@ -190,7 +190,7 @@ def Availability : InheritableAttr {
|
|||
[{static llvm::StringRef getPrettyPlatformName(llvm::StringRef Platform) {
|
||||
return llvm::StringSwitch<llvm::StringRef>(Platform)
|
||||
.Case("ios", "iOS")
|
||||
.Case("macosx", "Mac OS X")
|
||||
.Case("macosx", "OS X")
|
||||
.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() {
|
||||
f0(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);
|
||||
f4(0); // expected-error{{f4' is unavailable: obsoleted in Mac OS X 10.5}}
|
||||
f5(0); // expected-error{{'f5' is unavailable: not available on Mac OS X}}
|
||||
f4(0); // expected-error{{f4' is unavailable: obsoleted in OS X 10.5}}
|
||||
f5(0); // expected-error{{'f5' is unavailable: not available on OS X}}
|
||||
}
|
||||
|
||||
// rdar://10535640
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
// 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 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}}
|
||||
|
||||
void test_10095131() {
|
||||
ATSFontGetName("Hello"); // expected-warning {{'ATSFontGetName' is deprecated: first deprecated in Mac OS X 9.0 - use CTFontCopyFullName}}
|
||||
ATSFontGetPostScriptName(100); // expected-error {{'ATSFontGetPostScriptName' is unavailable: obsoleted in Mac OS X 9.0 - use ATSFontGetFullPostScriptName}}
|
||||
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 OS X 9.0 - use ATSFontGetFullPostScriptName}}
|
||||
}
|
||||
|
||||
// rdar://10711037
|
||||
|
|
|
@ -14,8 +14,8 @@
|
|||
@end
|
||||
|
||||
void f(A *a, B *b) {
|
||||
[a method]; // expected-warning{{'method' is deprecated: first deprecated in Mac OS X 10.2}}
|
||||
[b method]; // expected-warning {{'method' is deprecated: first deprecated in Mac OS X 10.2}}
|
||||
[a 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 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 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 OS X 10.2}}
|
||||
}
|
||||
|
|
|
@ -1173,59 +1173,53 @@ void CommentASTToXMLConverter::visitFullComment(const FullComment *C) {
|
|||
|
||||
if (DI->ThisDecl->hasAttrs()) {
|
||||
const AttrVec &Attrs = DI->ThisDecl->getAttrs();
|
||||
for (unsigned i = 0, e = Attrs.size(); i != e;) {
|
||||
const AvailabilityAttr *AA = dyn_cast<AvailabilityAttr>(Attrs[i++]);
|
||||
for (unsigned i = 0, e = Attrs.size(); i != e; i++) {
|
||||
const AvailabilityAttr *AA = dyn_cast<AvailabilityAttr>(Attrs[i]);
|
||||
if (!AA)
|
||||
continue;
|
||||
// availability attribute info.
|
||||
|
||||
|
||||
// 'availability' attribute.
|
||||
Result << "<Availability";
|
||||
StringRef distribution;
|
||||
StringRef Distribution;
|
||||
if (AA->getPlatform()) {
|
||||
distribution = AA->getPlatform()->getName();
|
||||
if (distribution == "macosx")
|
||||
distribution = "OSX";
|
||||
else
|
||||
distribution = "iOS";
|
||||
Distribution = AvailabilityAttr::getPrettyPlatformName(
|
||||
AA->getPlatform()->getName());
|
||||
if (Distribution.empty())
|
||||
Distribution = AA->getPlatform()->getName();
|
||||
}
|
||||
|
||||
Result << " distribution=\"";
|
||||
Result << distribution;
|
||||
Result << "\">";
|
||||
Result << " distribution=\"" << Distribution << "\">";
|
||||
VersionTuple IntroducedInVersion = AA->getIntroduced();
|
||||
if (!IntroducedInVersion.empty()) {
|
||||
Result << " <IntroducedInVersion>";
|
||||
Result << IntroducedInVersion.getAsString();
|
||||
Result << "</IntroducedInVersion>";
|
||||
Result << "<IntroducedInVersion>"
|
||||
<< IntroducedInVersion.getAsString()
|
||||
<< "</IntroducedInVersion>";
|
||||
}
|
||||
VersionTuple DeprecatedInVersion = AA->getDeprecated();
|
||||
if (!DeprecatedInVersion.empty()) {
|
||||
Result << " <DeprecatedInVersion>";
|
||||
Result << DeprecatedInVersion.getAsString();
|
||||
Result << "</DeprecatedInVersion>";
|
||||
Result << "<DeprecatedInVersion>"
|
||||
<< DeprecatedInVersion.getAsString()
|
||||
<< "</DeprecatedInVersion>";
|
||||
}
|
||||
VersionTuple RemovedAfterVersion = AA->getObsoleted();
|
||||
if (!RemovedAfterVersion.empty()) {
|
||||
Result << " <RemovedAfterVersion>";
|
||||
Result << RemovedAfterVersion.getAsString();
|
||||
Result << "</RemovedAfterVersion>";
|
||||
Result << "<RemovedAfterVersion>"
|
||||
<< RemovedAfterVersion.getAsString()
|
||||
<< "</RemovedAfterVersion>";
|
||||
}
|
||||
// 'deprecated' attribute.
|
||||
StringRef DeprecationSummary = AA->getMessage();
|
||||
if (!DeprecationSummary.empty()) {
|
||||
Result << " <DeprecationSummary>";
|
||||
Result << DeprecationSummary;
|
||||
Result << "</DeprecationSummary>";
|
||||
Result << " <DeprecationSummary>"
|
||||
<< DeprecationSummary
|
||||
<< "</DeprecationSummary>";
|
||||
}
|
||||
Result << " <Unavailable>";
|
||||
// 'unavailable' attribute.
|
||||
if (AA->getUnavailable())
|
||||
Result << "true";
|
||||
else
|
||||
Result << "false";
|
||||
Result << "</Unavailable>";
|
||||
Result << " </Availability>";
|
||||
Result << "<Unavailable>true</Unavailable>";
|
||||
Result << "</Availability>";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
{
|
||||
bool StartTagEmitted = false;
|
||||
for (unsigned i = 0, e = Parts.MiscBlocks.size(); i != e; ++i) {
|
||||
|
|
Loading…
Reference in New Issue