Fariborz Jahanian | bfc3ef5 | 2012-12-05 00:38:44 +0000 | [diff] [blame] | 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 |
Charles Li | 58a221a | 2017-02-13 17:56:30 +0000 | [diff] [blame^] | 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 |
Fariborz Jahanian | bfc3ef5 | 2012-12-05 00:38:44 +0000 | [diff] [blame] | 9 | |
| 10 | // Ensure that XML we generate is not invalid. |
| 11 | // RUN: FileCheck %s -check-prefix=WRONG < %t/out |
Charles Li | 58a221a | 2017-02-13 17:56:30 +0000 | [diff] [blame^] | 12 | // RUN: FileCheck %s -check-prefix=WRONG < %t/98 |
| 13 | // RUN: FileCheck %s -check-prefix=WRONG < %t/11 |
Fariborz Jahanian | bfc3ef5 | 2012-12-05 00:38:44 +0000 | [diff] [blame] | 14 | // WRONG-NOT: CommentXMLInvalid |
| 15 | // rdar://12378714 |
| 16 | |
| 17 | /** |
| 18 | * \brief plain c++ class |
| 19 | */ |
| 20 | class Test |
| 21 | { |
| 22 | public: |
| 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 () {} |
| 39 | protected: |
| 40 | struct data { |
| 41 | unsigned objectID; |
| 42 | }; |
| 43 | /** |
| 44 | * \brief plain c++ data field |
| 45 | */ |
| 46 | data* reserved; |
| 47 | }; |
Manuel Klimek | e7d10a1 | 2013-01-10 13:24:24 +0000 | [diff] [blame] | 48 | // CHECK: <Declaration>class Test {}</Declaration> |
Serge Pavlov | a67a4d2 | 2016-11-10 08:49:37 +0000 | [diff] [blame] | 49 | // CHECK: <Declaration>Test() : reserved(new Test::data()) {}</Declaration> |
Fariborz Jahanian | bfc3ef5 | 2012-12-05 00:38:44 +0000 | [diff] [blame] | 50 | // CHECK: <Declaration>unsigned int getID() const</Declaration> |
Charles Li | 58a221a | 2017-02-13 17:56:30 +0000 | [diff] [blame^] | 51 | // CHECK: <Declaration>~Test(){{( noexcept)?}}</Declaration> |
Fariborz Jahanian | bfc3ef5 | 2012-12-05 00:38:44 +0000 | [diff] [blame] | 52 | // CHECK: <Declaration>Test::data *reserved</Declaration> |
| 53 | |
| 54 | |
| 55 | class 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 | */ |
| 78 | template <typename T> friend void TemplateFriend(); |
| 79 | |
| 80 | /** |
| 81 | * \brief Eee |
| 82 | */ |
| 83 | template <typename T> friend class TemplateFriendClass; |
| 84 | |
| 85 | }; |
Fariborz Jahanian | 7a16a02 | 2012-12-21 21:43:05 +0000 | [diff] [blame] | 86 | // CHECK: <Declaration>friend class Test</Declaration> |
Fariborz Jahanian | bfc3ef5 | 2012-12-05 00:38:44 +0000 | [diff] [blame] | 87 | // CHECK: <Declaration>friend void foo()</Declaration> |
| 88 | // CHECK: <Declaration>friend int int_func()</Declaration> |
| 89 | // CHECK: <Declaration>friend bool operator==(const Test &, const Test &)</Declaration> |
| 90 | // CHECK: <Declaration>friend template <typename T> void TemplateFriend()</Declaration> |
| 91 | // CHECK: <Declaration>friend template <typename T> class TemplateFriendClass</Declaration> |
| 92 | |
| 93 | namespace 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 | |
| 107 | namespace 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 | |
| 120 | namespace 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 | |
| 134 | namespace 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 &t = T())</Declaration> |
| 152 | // CHECK: <Declaration>friend void f(const test3::A &)</Declaration> |
Fariborz Jahanian | 7a16a02 | 2012-12-21 21:43:05 +0000 | [diff] [blame] | 153 | |
| 154 | class MyClass |
| 155 | { |
| 156 | /** |
| 157 | * \brief plain friend test. |
| 158 | */ |
| 159 | friend class MyClass; |
| 160 | }; |
| 161 | // CHECK: <Declaration>friend class MyClass</Declaration> |
| 162 | |
| 163 | template<class _Tp> class valarray |
| 164 | { |
| 165 | private: |
| 166 | /** |
| 167 | * \brief template friend test. |
| 168 | */ |
| 169 | template <class T> friend class valarray; |
| 170 | }; |
Dmitri Gribenko | a9cc249 | 2013-01-07 18:45:48 +0000 | [diff] [blame] | 171 | // CHECK: <Declaration>template <class T> class valarray</Declaration> |
Fariborz Jahanian | 7a16a02 | 2012-12-21 21:43:05 +0000 | [diff] [blame] | 172 | // CHECK: <Declaration>friend template <class T> class valarray</Declaration> |
| 173 | |
| 174 | class gslice |
| 175 | { |
| 176 | valarray<unsigned> __size_; |
| 177 | }; |