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