From 35760a8937289d456968479b0406fe864eb06501 Mon Sep 17 00:00:00 2001 From: Fariborz Jahanian Date: Fri, 28 Sep 2012 22:35:49 +0000 Subject: [PATCH] [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 llvm-svn: 164861 --- clang/bindings/xml/comment-xml-schema.rng | 36 +++++++++++++++++++ clang/tools/libclang/CXComment.cpp | 57 ++++++++++++++++++++++++++++++- 2 files changed, 92 insertions(+), 1 deletion(-) diff --git a/clang/bindings/xml/comment-xml-schema.rng b/clang/bindings/xml/comment-xml-schema.rng index 3942903..1438e3c 100644 --- a/clang/bindings/xml/comment-xml-schema.rng +++ b/clang/bindings/xml/comment-xml-schema.rng @@ -79,6 +79,9 @@ + + + @@ -284,6 +287,39 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/clang/tools/libclang/CXComment.cpp b/clang/tools/libclang/CXComment.cpp index 4e26a9e..a132a0d 100644 --- a/clang/tools/libclang/CXComment.cpp +++ b/clang/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) { -- 2.7.4