Revert "[llvm] Improve llvm.objectsize computation by computing GEP, alloca and mallo...
[llvm-project.git] / clang / test / Index / comment-cplus-decls.cpp
blob376dd6a07755eeee67942100220f4c335f71508d
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
16 /**
17 * \brief plain c++ class
19 class Test
21 public:
22 /**
23 * \brief plain c++ constructor
25 Test () : reserved (new data()) {}
27 /**
28 * \brief plain c++ member function
30 unsigned getID() const
32 return reserved->objectID;
34 /**
35 * \brief plain c++ destructor
37 ~Test () {}
38 protected:
39 struct data {
40 unsigned objectID;
42 /**
43 * \brief plain c++ data field
45 data* reserved;
47 // CHECK: <Declaration>class Test {}</Declaration>
48 // CHECK: <Declaration>Test()</Declaration>
49 // CHECK: <Declaration>unsigned int getID() const</Declaration>
50 // CHECK: <Declaration>~Test(){{( noexcept)?}}</Declaration>
51 // CHECK: <Declaration>data *reserved</Declaration>
54 class S {
55 /**
56 * \brief Aaa
58 friend class Test;
59 /**
60 * \brief Bbb
62 friend void foo() {}
64 /**
65 * \brief Ccc
67 friend int int_func();
69 /**
70 * \brief Ddd
72 friend bool operator==(const Test &, const Test &);
74 /**
75 * \brief Eee
77 template <typename T> friend void TemplateFriend();
79 /**
80 * \brief Eee
82 template <typename T> friend class TemplateFriendClass;
85 // CHECK: <Declaration>friend class Test</Declaration>
86 // CHECK: <Declaration>friend void foo()</Declaration>
87 // CHECK: <Declaration>friend int int_func()</Declaration>
88 // CHECK: <Declaration>friend bool operator==(const Test &amp;, const Test &amp;)</Declaration>
89 // CHECK: <Declaration>friend template &lt;typename T&gt; void TemplateFriend()</Declaration>
90 // CHECK: <Declaration>friend template &lt;typename T&gt; class TemplateFriendClass</Declaration>
92 namespace test0 {
93 namespace ns {
94 void f(int);
97 struct A {
98 /**
99 * \brief Fff
101 friend void ns::f(int a);
104 // CHECK: <Declaration>friend void ns::f(int a)</Declaration>
106 namespace test1 {
107 template <class T> struct Outer {
108 void foo(T);
109 struct Inner {
111 * \brief Ggg
113 friend void Outer::foo(T);
117 // CHECK: <Declaration>friend void Outer&lt;T&gt;::foo(T)</Declaration>
119 namespace test2 {
120 namespace foo {
121 void Func(int x);
124 class Bar {
126 * \brief Hhh
128 friend void ::test2::foo::Func(int x);
131 // CHECK: <Declaration>friend void ::test2::foo::Func(int x)</Declaration>
133 namespace test3 {
134 template<class T> class vector {
135 public:
136 vector(int i) {}
138 * \brief Iii
140 void f(const T& t = T()) {}
142 class A {
143 private:
145 * \brief Jjj
147 friend void vector<A>::f(const A&);
150 // CHECK: <Declaration>void f(const T &amp;t = T())</Declaration>
151 // CHECK: <Declaration>friend void vector&lt;A&gt;::f(const A &amp;)</Declaration>
153 class MyClass
156 * \brief plain friend test.
158 friend class MyClass;
160 // CHECK: <Declaration>friend class MyClass</Declaration>
162 template<class _Tp> class valarray
164 private:
166 * \brief template friend test.
168 template <class T> friend class valarray;
170 // CHECK: <Declaration>template &lt;class T&gt; class valarray</Declaration>
171 // CHECK: <Declaration>friend template &lt;class T&gt; class valarray</Declaration>
173 class gslice
175 valarray<unsigned> __size_;