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