diff options
author | Fariborz Jahanian <fjahanian@apple.com> | 2012-12-05 00:38:44 +0000 |
---|---|---|
committer | Fariborz Jahanian <fjahanian@apple.com> | 2012-12-05 00:38:44 +0000 |
commit | 8920eb7a957f3b0bc4a8213ecdaec9a7fcd139ea (patch) | |
tree | 387de9b16138ab3b579b50480249f6909fcf1d42 /test/Index/comment-cplus-decls.cpp | |
parent | fb4afc2fc659faff43a6df4c1d0e07df9c90479d (diff) |
Testing C++ declarations embedded in
<declaration> tag of Comment XML and
added support for friend declaration printing.
This is wip. // rdar://12378714
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@169346 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/Index/comment-cplus-decls.cpp')
-rw-r--r-- | test/Index/comment-cplus-decls.cpp | 146 |
1 files changed, 146 insertions, 0 deletions
diff --git a/test/Index/comment-cplus-decls.cpp b/test/Index/comment-cplus-decls.cpp new file mode 100644 index 0000000000..3d997a5007 --- /dev/null +++ b/test/Index/comment-cplus-decls.cpp @@ -0,0 +1,146 @@ +// RUN: rm -rf %t +// RUN: mkdir %t +// RUN: c-index-test -test-load-source all -comments-xml-schema=%S/../../bindings/xml/comment-xml-schema.rng -target x86_64-apple-darwin10 %s > %t/out +// RUN: FileCheck %s < %t/out + +// Ensure that XML we generate is not invalid. +// RUN: FileCheck %s -check-prefix=WRONG < %t/out +// WRONG-NOT: CommentXMLInvalid +// rdar://12378714 + +/** + * \brief plain c++ class +*/ +class Test +{ +public: +/** + * \brief plain c++ constructor +*/ + Test () : reserved (new data()) {} + +/** + * \brief plain c++ member function +*/ + unsigned getID() const + { + return reserved->objectID; + } +/** + * \brief plain c++ destructor +*/ + ~Test () {} +protected: + struct data { + unsigned objectID; + }; +/** + * \brief plain c++ data field +*/ + data* reserved; +}; +// CHECK: <Declaration>class Test {\n}</Declaration> +// CHECK: <Declaration>Test() : reserved(new Test::data())</Declaration> +// CHECK: <Declaration>unsigned int getID() const</Declaration> +// CHECK: <Declaration>void ~Test()</Declaration> +// CHECK: <Declaration>Test::data *reserved</Declaration> + + +class S { +/** + * \brief Aaa +*/ + friend class Test; +/** + * \brief Bbb +*/ + friend void foo() {} + +/** + * \brief Ccc +*/ + friend int int_func(); + +/** + * \brief Ddd +*/ + friend bool operator==(const Test &, const Test &); + +/** + * \brief Eee +*/ +template <typename T> friend void TemplateFriend(); + +/** + * \brief Eee +*/ + template <typename T> friend class TemplateFriendClass; + +}; +// CHECK: <Declaration>friend class Test {\n}</Declaration> +// CHECK: <Declaration>friend void foo()</Declaration> +// CHECK: <Declaration>friend int int_func()</Declaration> +// CHECK: <Declaration>friend bool operator==(const Test &, const Test &)</Declaration> +// CHECK: <Declaration>friend template <typename T> void TemplateFriend()</Declaration> +// CHECK: <Declaration>friend template <typename T> class TemplateFriendClass</Declaration> + +namespace test0 { + namespace ns { + void f(int); + } + + struct A { +/** + * \brief Fff +*/ + friend void ns::f(int a); + }; +} +// CHECK: <Declaration>friend void f(int a)</Declaration> + +namespace test1 { + template <class T> struct Outer { + void foo(T); + struct Inner { +/** + * \brief Ggg +*/ + friend void Outer::foo(T); + }; + }; +} +// CHECK: <Declaration>friend void foo(T)</Declaration> + +namespace test2 { + namespace foo { + void Func(int x); + } + + class Bar { +/** + * \brief Hhh +*/ + friend void ::test2::foo::Func(int x); + }; +} +// CHECK: <Declaration>friend void Func(int x)</Declaration> + +namespace test3 { + template<class T> class vector { + public: + vector(int i) {} +/** + * \brief Iii +*/ + void f(const T& t = T()) {} + }; + class A { + private: +/** + * \brief Jjj +*/ + friend void vector<A>::f(const A&); + }; +} +// CHECK: <Declaration>void f(const T &t = T())</Declaration> +// CHECK: <Declaration>friend void f(const test3::A &)</Declaration> |