From: Fariborz Jahanian Date: Tue, 2 Oct 2012 20:05:47 +0000 (+0000) Subject: [Doc parsing]: Add available and deprecated attribute info X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=2a46533633441176e93b484739a0a27e07150b63;p=clang [Doc parsing]: Add available and deprecated attribute info to XML output. // rdar://12378879 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@165039 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/bindings/xml/comment-xml-schema.rng b/bindings/xml/comment-xml-schema.rng index 1a2eb16441..4197bc83a5 100644 --- a/bindings/xml/comment-xml-schema.rng +++ b/bindings/xml/comment-xml-schema.rng @@ -82,6 +82,12 @@ + + + + + + @@ -313,13 +319,23 @@ - - - + + + + + + + + + + + + + diff --git a/test/Index/Inputs/CommentXML/valid-deprecated-attr.xml b/test/Index/Inputs/CommentXML/valid-deprecated-attr.xml new file mode 100644 index 0000000000..5452b9394f --- /dev/null +++ b/test/Index/Inputs/CommentXML/valid-deprecated-attr.xml @@ -0,0 +1,6 @@ + + +aaa +Aaa. +true + diff --git a/test/Index/Inputs/CommentXML/valid-unavailable-attr.xml b/test/Index/Inputs/CommentXML/valid-unavailable-attr.xml new file mode 100644 index 0000000000..342ce44a49 --- /dev/null +++ b/test/Index/Inputs/CommentXML/valid-unavailable-attr.xml @@ -0,0 +1,6 @@ + + +aaa +Aaa. +true + diff --git a/test/Index/annotate-comments-availability-attrs.cpp b/test/Index/annotate-comments-availability-attrs.cpp index 6fb99a1b5c..cc3af073ec 100644 --- a/test/Index/annotate-comments-availability-attrs.cpp +++ b/test/Index/annotate-comments-availability-attrs.cpp @@ -10,3 +10,20 @@ void cfunction_availability(int arg1, double d) __attribute__((availability(maco // 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] + + +/** + * \param[in] arg1 ZZZ + * \param[out] d xxx + */ +void dep(int arg1, double d) __attribute__((deprecated)); + +// CHECK: annotate-comments-availability-attrs.cpp:19:6: FunctionDecl=dep:{{.*}} FullCommentAsXML=[depc:@F@dep#I#d#arg10in ZZZ d1out xxx true + + +/** + * \param[in] arg1 ZZZ + */ +void unv(int arg1) __attribute__((unavailable)); + +// CHECK: annotate-comments-availability-attrs.cpp:27:6: FunctionDecl=unv:{{.*}} FullCommentAsXML=[unvc:@F@unv#I#arg10in ZZZ true diff --git a/test/Index/comment-xml-schema.c b/test/Index/comment-xml-schema.c index dad6c8a694..7e7e3315f1 100644 --- a/test/Index/comment-xml-schema.c +++ b/test/Index/comment-xml-schema.c @@ -13,6 +13,8 @@ // RUN: xmllint --noout --relaxng %S/../../bindings/xml/comment-xml-schema.rng %S/Inputs/CommentXML/valid-function-09.xml // // RUN: xmllint --noout --relaxng %S/../../bindings/xml/comment-xml-schema.rng %S/Inputs/CommentXML/valid-availability-attr-01.xml +// RUN: xmllint --noout --relaxng %S/../../bindings/xml/comment-xml-schema.rng %S/Inputs/CommentXML/valid-deprecated-attr.xml +// RUN: xmllint --noout --relaxng %S/../../bindings/xml/comment-xml-schema.rng %S/Inputs/CommentXML/valid-unavailable-attr.xml // // RUN: xmllint --noout --relaxng %S/../../bindings/xml/comment-xml-schema.rng %S/Inputs/CommentXML/valid-class-01.xml // RUN: xmllint --noout --relaxng %S/../../bindings/xml/comment-xml-schema.rng %S/Inputs/CommentXML/valid-class-02.xml diff --git a/tools/libclang/CXComment.cpp b/tools/libclang/CXComment.cpp index 1e0679f22a..a0a5512814 100644 --- a/tools/libclang/CXComment.cpp +++ b/tools/libclang/CXComment.cpp @@ -1175,8 +1175,13 @@ void CommentASTToXMLConverter::visitFullComment(const FullComment *C) { const AttrVec &Attrs = DI->ThisDecl->getAttrs(); for (unsigned i = 0, e = Attrs.size(); i != e; i++) { const AvailabilityAttr *AA = dyn_cast(Attrs[i]); - if (!AA) + if (!AA) { + if (isa(Attrs[i])) + Result << "true"; + else if (isa(Attrs[i])) + Result << "true"; continue; + } // 'availability' attribute. Result << "