blob: 463aa9e792916939b20b0383f8908e33d1b11e7a [file] [log] [blame]
Fariborz Jahanianbfc3ef52012-12-05 00:38:44 +00001// 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
Charles Li58a221a2017-02-13 17:56:30 +00005// 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
Fariborz Jahanianbfc3ef52012-12-05 00:38:44 +00009
10// Ensure that XML we generate is not invalid.
11// RUN: FileCheck %s -check-prefix=WRONG < %t/out
Charles Li58a221a2017-02-13 17:56:30 +000012// RUN: FileCheck %s -check-prefix=WRONG < %t/98
13// RUN: FileCheck %s -check-prefix=WRONG < %t/11
Fariborz Jahanianbfc3ef52012-12-05 00:38:44 +000014// WRONG-NOT: CommentXMLInvalid
15// rdar://12378714
16
17/**
18 * \brief plain c++ class
19*/
20class Test
21{
22public:
23/**
24 * \brief plain c++ constructor
25*/
26 Test () : reserved (new data()) {}
27
28/**
29 * \brief plain c++ member function
30*/
31 unsigned getID() const
32 {
33 return reserved->objectID;
34 }
35/**
36 * \brief plain c++ destructor
37*/
38 ~Test () {}
39protected:
40 struct data {
41 unsigned objectID;
42 };
43/**
44 * \brief plain c++ data field
45*/
46 data* reserved;
47};
Manuel Klimeke7d10a12013-01-10 13:24:24 +000048// CHECK: <Declaration>class Test {}</Declaration>
Serge Pavlova67a4d22016-11-10 08:49:37 +000049// CHECK: <Declaration>Test() : reserved(new Test::data()) {}</Declaration>
Fariborz Jahanianbfc3ef52012-12-05 00:38:44 +000050// CHECK: <Declaration>unsigned int getID() const</Declaration>
Charles Li58a221a2017-02-13 17:56:30 +000051// CHECK: <Declaration>~Test(){{( noexcept)?}}</Declaration>
Fariborz Jahanianbfc3ef52012-12-05 00:38:44 +000052// CHECK: <Declaration>Test::data *reserved</Declaration>
53
54
55class S {
56/**
57 * \brief Aaa
58*/
59 friend class Test;
60/**
61 * \brief Bbb
62*/
63 friend void foo() {}
64
65/**
66 * \brief Ccc
67*/
68 friend int int_func();
69
70/**
71 * \brief Ddd
72*/
73 friend bool operator==(const Test &, const Test &);
74
75/**
76 * \brief Eee
77*/
78template <typename T> friend void TemplateFriend();
79
80/**
81 * \brief Eee
82*/
83 template <typename T> friend class TemplateFriendClass;
84
85};
Fariborz Jahanian7a16a022012-12-21 21:43:05 +000086// CHECK: <Declaration>friend class Test</Declaration>
Fariborz Jahanianbfc3ef52012-12-05 00:38:44 +000087// 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>
92
93namespace test0 {
94 namespace ns {
95 void f(int);
96 }
97
98 struct A {
99/**
100 * \brief Fff
101*/
102 friend void ns::f(int a);
103 };
104}
105// CHECK: <Declaration>friend void f(int a)</Declaration>
106
107namespace test1 {
108 template <class T> struct Outer {
109 void foo(T);
110 struct Inner {
111/**
112 * \brief Ggg
113*/
114 friend void Outer::foo(T);
115 };
116 };
117}
118// CHECK: <Declaration>friend void foo(T)</Declaration>
119
120namespace test2 {
121 namespace foo {
122 void Func(int x);
123 }
124
125 class Bar {
126/**
127 * \brief Hhh
128*/
129 friend void ::test2::foo::Func(int x);
130 };
131}
132// CHECK: <Declaration>friend void Func(int x)</Declaration>
133
134namespace test3 {
135 template<class T> class vector {
136 public:
137 vector(int i) {}
138/**
139 * \brief Iii
140*/
141 void f(const T& t = T()) {}
142 };
143 class A {
144 private:
145/**
146 * \brief Jjj
147*/
148 friend void vector<A>::f(const A&);
149 };
150}
151// CHECK: <Declaration>void f(const T &amp;t = T())</Declaration>
152// CHECK: <Declaration>friend void f(const test3::A &amp;)</Declaration>
Fariborz Jahanian7a16a022012-12-21 21:43:05 +0000153
154class MyClass
155{
156/**
157 * \brief plain friend test.
158*/
159 friend class MyClass;
160};
161// CHECK: <Declaration>friend class MyClass</Declaration>
162
163template<class _Tp> class valarray
164{
165private:
166/**
167 * \brief template friend test.
168*/
169 template <class T> friend class valarray;
170};
Dmitri Gribenkoa9cc2492013-01-07 18:45:48 +0000171// CHECK: <Declaration>template &lt;class T&gt; class valarray</Declaration>
Fariborz Jahanian7a16a022012-12-21 21:43:05 +0000172// CHECK: <Declaration>friend template &lt;class T&gt; class valarray</Declaration>
173
174class gslice
175{
176 valarray<unsigned> __size_;
177};