aboutsummaryrefslogtreecommitdiff
path: root/tools/libclang/CXComment.cpp
diff options
context:
space:
mode:
authorFariborz Jahanian <fjahanian@apple.com>2012-09-28 22:35:49 +0000
committerFariborz Jahanian <fjahanian@apple.com>2012-09-28 22:35:49 +0000
commit257e2e836160c7e55cf160b7cae8e5665f988a5e (patch)
treee705b82a71e24d705e0d708a83dbbc1662da8c59 /tools/libclang/CXComment.cpp
parent20441c59a00afb949e53121c55f8a58da17ba79e (diff)
[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
Diffstat (limited to 'tools/libclang/CXComment.cpp')
-rw-r--r--tools/libclang/CXComment.cpp57
1 files changed, 56 insertions, 1 deletions
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 << "</ResultDiscussion>";
}
-
+
+ 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++]);
+ if (!AA)
+ continue;
+ // availability attribute info.
+
+ Result << "<Availability";
+ StringRef distribution;
+ if (AA->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 << " <IntroducedInVersion>";
+ Result << IntroducedInVersion.getAsString();
+ Result << "</IntroducedInVersion>";
+ }
+ VersionTuple DeprecatedInVersion = AA->getDeprecated();
+ if (!DeprecatedInVersion.empty()) {
+ Result << " <DeprecatedInVersion>";
+ Result << DeprecatedInVersion.getAsString();
+ Result << "</DeprecatedInVersion>";
+ }
+ VersionTuple RemovedAfterVersion = AA->getObsoleted();
+ if (!RemovedAfterVersion.empty()) {
+ Result << " <RemovedAfterVersion>";
+ Result << RemovedAfterVersion.getAsString();
+ Result << "</RemovedAfterVersion>";
+ }
+ StringRef DeprecationSummary = AA->getMessage();
+ if (!DeprecationSummary.empty()) {
+ Result << " <DeprecationSummary>";
+ Result << DeprecationSummary;
+ Result << "</DeprecationSummary>";
+ }
+ Result << " <Unavailable>";
+ if (AA->getUnavailable())
+ Result << "true";
+ else
+ Result << "false";
+ Result << "</Unavailable>";
+ Result << " </Availability>";
+ }
+ }
+
{
bool StartTagEmitted = false;
for (unsigned i = 0, e = Parts.MiscBlocks.size(); i != e; ++i) {