comment-cplus-decls.cpp
3.82 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
// 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
// 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
// RUN: FileCheck %s < %t/98
// 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
// RUN: FileCheck %s < %t/11
// Ensure that XML we generate is not invalid.
// RUN: FileCheck %s -check-prefix=WRONG < %t/out
// RUN: FileCheck %s -check-prefix=WRONG < %t/98
// RUN: FileCheck %s -check-prefix=WRONG < %t/11
// 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 {}</Declaration>
// CHECK: <Declaration>Test()</Declaration>
// CHECK: <Declaration>unsigned int getID() const</Declaration>
// CHECK: <Declaration>~Test(){{( noexcept)?}}</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</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 ns::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 Outer<T>::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 ::test2::foo::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 vector<A>::f(const test3::A &)</Declaration>
class MyClass
{
/**
* \brief plain friend test.
*/
friend class MyClass;
};
// CHECK: <Declaration>friend class MyClass</Declaration>
template<class _Tp> class valarray
{
private:
/**
* \brief template friend test.
*/
template <class T> friend class valarray;
};
// CHECK: <Declaration>template <class T> class valarray</Declaration>
// CHECK: <Declaration>friend template <class T> class valarray</Declaration>
class gslice
{
valarray<unsigned> __size_;
};