From: Fariborz Jahanian Date: Mon, 1 Oct 2012 18:42:25 +0000 (+0000) Subject: availability in structured documents. Takes X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=c491c3f27aabda38ff269c36c4de144b6905170b;p=platform%2Fupstream%2Fllvm.git availability in structured documents. Takes care of comments by Dimitri and Doug. llvm-svn: 164957 --- diff --git a/clang/bindings/xml/comment-xml-schema.rng b/clang/bindings/xml/comment-xml-schema.rng index 8302d9d..1a2eb16 100644 --- a/clang/bindings/xml/comment-xml-schema.rng +++ b/clang/bindings/xml/comment-xml-schema.rng @@ -80,7 +80,7 @@ - + @@ -287,7 +287,7 @@ - + diff --git a/clang/include/clang/Basic/Attr.td b/clang/include/clang/Basic/Attr.td index 7406ce2..67ef8be 100644 --- a/clang/include/clang/Basic/Attr.td +++ b/clang/include/clang/Basic/Attr.td @@ -190,7 +190,7 @@ def Availability : InheritableAttr { [{static llvm::StringRef getPrettyPlatformName(llvm::StringRef Platform) { return llvm::StringSwitch(Platform) .Case("ios", "iOS") - .Case("macosx", "Mac OS X") + .Case("macosx", "OS X") .Default(llvm::StringRef()); } }]; } diff --git a/clang/test/Index/Inputs/CommentXML/valid-availability-attr-01.xml b/clang/test/Index/Inputs/CommentXML/valid-availability-attr-01.xml new file mode 100644 index 0000000..94cbc9a --- /dev/null +++ b/clang/test/Index/Inputs/CommentXML/valid-availability-attr-01.xml @@ -0,0 +1,7 @@ + + + 8.0 + 9.0 + 10.0 + use availability_test + diff --git a/clang/test/Index/annotate-comments-availability-attrs.cpp b/clang/test/Index/annotate-comments-availability-attrs.cpp new file mode 100644 index 0000000..6fb99a1 --- /dev/null +++ b/clang/test/Index/annotate-comments-availability-attrs.cpp @@ -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=[cfunction_availabilityc:@F@cfunction_availability#I#d#arg10in ZZZ d1out xxx not for iOStrue8.09.010.0 use availability_test] diff --git a/clang/test/Sema/attr-availability-macosx.c b/clang/test/Sema/attr-availability-macosx.c index 781523a..468e930 100644 --- a/clang/test/Sema/attr-availability-macosx.c +++ b/clang/test/Sema/attr-availability-macosx.c @@ -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 diff --git a/clang/test/Sema/attr-availability.c b/clang/test/Sema/attr-availability.c index b4a6f96..e0c541e 100644 --- a/clang/test/Sema/attr-availability.c +++ b/clang/test/Sema/attr-availability.c @@ -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 diff --git a/clang/test/SemaObjC/attr-availability.m b/clang/test/SemaObjC/attr-availability.m index 7c9ff0f..ed6b760 100644 --- a/clang/test/SemaObjC/attr-availability.m +++ b/clang/test/SemaObjC/attr-availability.m @@ -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}} } diff --git a/clang/tools/libclang/CXComment.cpp b/clang/tools/libclang/CXComment.cpp index a132a0d..1e0679f 100644 --- a/clang/tools/libclang/CXComment.cpp +++ b/clang/tools/libclang/CXComment.cpp @@ -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(Attrs[i++]); + for (unsigned i = 0, e = Attrs.size(); i != e; i++) { + const AvailabilityAttr *AA = dyn_cast(Attrs[i]); if (!AA) continue; - // availability attribute info. - + + // 'availability' attribute. Result << "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 << " "; - Result << IntroducedInVersion.getAsString(); - Result << ""; + Result << "" + << IntroducedInVersion.getAsString() + << ""; } VersionTuple DeprecatedInVersion = AA->getDeprecated(); if (!DeprecatedInVersion.empty()) { - Result << " "; - Result << DeprecatedInVersion.getAsString(); - Result << ""; + Result << "" + << DeprecatedInVersion.getAsString() + << ""; } VersionTuple RemovedAfterVersion = AA->getObsoleted(); if (!RemovedAfterVersion.empty()) { - Result << " "; - Result << RemovedAfterVersion.getAsString(); - Result << ""; + Result << "" + << RemovedAfterVersion.getAsString() + << ""; } + // 'deprecated' attribute. StringRef DeprecationSummary = AA->getMessage(); if (!DeprecationSummary.empty()) { - Result << " "; - Result << DeprecationSummary; - Result << ""; + Result << " " + << DeprecationSummary + << ""; } - Result << " "; + // 'unavailable' attribute. if (AA->getUnavailable()) - Result << "true"; - else - Result << "false"; - Result << ""; - Result << " "; + Result << "true"; + Result << ""; } } - + { bool StartTagEmitted = false; for (unsigned i = 0, e = Parts.MiscBlocks.size(); i != e; ++i) {