From: Fariborz Jahanian Date: Fri, 28 Sep 2012 22:35:49 +0000 (+0000) Subject: [Doc parsing] Add availability information to generated Comment XML. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=257e2e836160c7e55cf160b7cae8e5665f988a5e;p=clang [Doc parsing] Add availability information to generated Comment XML. (I still need to add a test once I figure it out). Reviewed off-line by Doug. // rdar://12378879 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@164861 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/bindings/xml/comment-xml-schema.rng b/bindings/xml/comment-xml-schema.rng index 3942903788..1438e3c351 100644 --- a/bindings/xml/comment-xml-schema.rng +++ b/bindings/xml/comment-xml-schema.rng @@ -79,6 +79,9 @@ + + + @@ -284,6 +287,39 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tools/libclang/CXComment.cpp b/tools/libclang/CXComment.cpp index 4e26a9e984..a132a0d1ba 100644 --- a/tools/libclang/CXComment.cpp +++ b/tools/libclang/CXComment.cpp @@ -1170,7 +1170,62 @@ void CommentASTToXMLConverter::visitFullComment(const FullComment *C) { visit(Parts.Returns); Result << ""; } - + + 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++]); + if (!AA) + continue; + // availability attribute info. + + Result << "getPlatform()) { + distribution = AA->getPlatform()->getName(); + if (distribution == "macosx") + distribution = "OSX"; + else + distribution = "iOS"; + } + + Result << " distribution=\""; + Result << distribution; + Result << "\">"; + VersionTuple IntroducedInVersion = AA->getIntroduced(); + if (!IntroducedInVersion.empty()) { + Result << " "; + Result << IntroducedInVersion.getAsString(); + Result << ""; + } + VersionTuple DeprecatedInVersion = AA->getDeprecated(); + if (!DeprecatedInVersion.empty()) { + Result << " "; + Result << DeprecatedInVersion.getAsString(); + Result << ""; + } + VersionTuple RemovedAfterVersion = AA->getObsoleted(); + if (!RemovedAfterVersion.empty()) { + Result << " "; + Result << RemovedAfterVersion.getAsString(); + Result << ""; + } + StringRef DeprecationSummary = AA->getMessage(); + if (!DeprecationSummary.empty()) { + Result << " "; + Result << DeprecationSummary; + Result << ""; + } + Result << " "; + if (AA->getUnavailable()) + Result << "true"; + else + Result << "false"; + Result << ""; + Result << " "; + } + } + { bool StartTagEmitted = false; for (unsigned i = 0, e = Parts.MiscBlocks.size(); i != e; ++i) {