[docs] Add LICENSE.txt to the root of the mono-repo
[llvm-project.git] / clang / test / Index / comment-cplus-decls.cpp
blob15432a72aa043b780a1d05f3d7c6d3c08f81b24e
1 // RUN: rm -rf %t
2 // RUN: mkdir %t
3 // 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
4 // RUN: FileCheck %s < %t/out
5 // RUN: c-index-test -test-load-source all -comments-xml-schema=%S/../../bindings/xml/comment-xml-schema.rng -target x86_64-apple-darwin10 -std=c++98 %s > %t/98
6 // RUN: FileCheck %s < %t/98
7 // RUN: c-index-test -test-load-source all -comments-xml-schema=%S/../../bindings/xml/comment-xml-schema.rng -target x86_64-apple-darwin10 -std=c++11 %s > %t/11
8 // RUN: FileCheck %s < %t/11
10 // Ensure that XML we generate is not invalid.
11 // RUN: FileCheck %s -check-prefix=WRONG < %t/out
12 // RUN: FileCheck %s -check-prefix=WRONG < %t/98
13 // RUN: FileCheck %s -check-prefix=WRONG < %t/11
14 // WRONG-NOT: CommentXMLInvalid
15 // rdar://12378714
17 /**
18 * \brief plain c++ class
20 class Test
22 public:
23 /**
24 * \brief plain c++ constructor
26 Test () : reserved (new data()) {}
28 /**
29 * \brief plain c++ member function
31 unsigned getID() const
33 return reserved->objectID;
35 /**
36 * \brief plain c++ destructor
38 ~Test () {}
39 protected:
40 struct data {
41 unsigned objectID;
43 /**
44 * \brief plain c++ data field
46 data* reserved;
48 // CHECK: <Declaration>class Test {}</Declaration>
49 // CHECK: <Declaration>Test()</Declaration>
50 // CHECK: <Declaration>unsigned int getID() const</Declaration>
51 // CHECK: <Declaration>~Test(){{( noexcept)?}}</Declaration>
52 // CHECK: <Declaration>data *reserved</Declaration>
55 class S {
56 /**
57 * \brief Aaa
59 friend class Test;
60 /**
61 * \brief Bbb
63 friend void foo() {}
65 /**
66 * \brief Ccc
68 friend int int_func();
70 /**
71 * \brief Ddd
73 friend bool operator==(const Test &, const Test &);
75 /**
76 * \brief Eee
78 template <typename T> friend void TemplateFriend();
80 /**
81 * \brief Eee
83 template <typename T> friend class TemplateFriendClass;
86 // CHECK: <Declaration>friend class Test</Declaration>
87 // CHECK: <Declaration>friend void foo()</Declaration>
88 // CHECK: <Declaration>friend int int_func()</Declaration>
89 // CHECK: <Declaration>friend bool operator==(const Test &amp;, const Test &amp;)</Declaration>
90 // CHECK: <Declaration>friend template &lt;typename T&gt; void TemplateFriend()</Declaration>
91 // CHECK: <Declaration>friend template &lt;typename T&gt; class TemplateFriendClass</Declaration>
93 namespace test0 {
94 namespace ns {
95 void f(int);
98 struct A {
99 /**
100 * \brief Fff
102 friend void ns::f(int a);
105 // CHECK: <Declaration>friend void ns::f(int a)</Declaration>
107 namespace test1 {
108 template <class T> struct Outer {
109 void foo(T);
110 struct Inner {
112 * \brief Ggg
114 friend void Outer::foo(T);
118 // CHECK: <Declaration>friend void Outer&lt;T&gt;::foo(T)</Declaration>
120 namespace test2 {
121 namespace foo {
122 void Func(int x);
125 class Bar {
127 * \brief Hhh
129 friend void ::test2::foo::Func(int x);
132 // CHECK: <Declaration>friend void ::test2::foo::Func(int x)</Declaration>
134 namespace test3 {
135 template<class T> class vector {
136 public:
137 vector(int i) {}
139 * \brief Iii
141 void f(const T& t = T()) {}
143 class A {
144 private:
146 * \brief Jjj
148 friend void vector<A>::f(const A&);
151 // CHECK: <Declaration>void f(const T &amp;t = T())</Declaration>
152 // CHECK: <Declaration>friend void vector&lt;A&gt;::f(const A &amp;)</Declaration>
154 class MyClass
157 * \brief plain friend test.
159 friend class MyClass;
161 // CHECK: <Declaration>friend class MyClass</Declaration>
163 template<class _Tp> class valarray
165 private:
167 * \brief template friend test.
169 template <class T> friend class valarray;
171 // CHECK: <Declaration>template &lt;class T&gt; class valarray</Declaration>
172 // CHECK: <Declaration>friend template &lt;class T&gt; class valarray</Declaration>
174 class gslice
176 valarray<unsigned> __size_;