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 */ 14 class Test 15 { 16 public: 17 /** 18 * \brief plain c++ constructor 19 */ Test()20 Test () : reserved (new data()) {} 21 22 /** 23 * \brief plain c++ member function 24 */ getID() const25 unsigned getID() const 26 { 27 return reserved->objectID; 28 } 29 /** 30 * \brief plain c++ destructor 31 */ ~Test()32 ~Test () {} 33 protected: 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 49 class S { 50 /** 51 * \brief Aaa 52 */ 53 friend class Test; 54 /** 55 * \brief Bbb 56 */ foo()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 */ 72 template <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 &, const Test &)</Declaration> 84 // CHECK: <Declaration>friend template <typename T> void TemplateFriend()</Declaration> 85 // CHECK: <Declaration>friend template <typename T> class TemplateFriendClass</Declaration> 86 87 namespace 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 101 namespace 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 114 namespace 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 128 namespace test3 { 129 template<class T> class vector { 130 public: vector(int i)131 vector(int i) {} 132 /** 133 * \brief Iii 134 */ f(const T & t=T ())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 &t = T())</Declaration> 146 // CHECK: <Declaration>friend void f(const test3::A &)</Declaration> 147 148 class MyClass 149 { 150 /** 151 * \brief plain friend test. 152 */ 153 friend class MyClass; 154 }; 155 // CHECK: <Declaration>friend class MyClass</Declaration> 156 157 template<class _Tp> class valarray 158 { 159 private: 160 /** 161 * \brief template friend test. 162 */ 163 template <class T> friend class valarray; 164 }; 165 // CHECK: <Declaration>template <class T> class valarray</Declaration> 166 // CHECK: <Declaration>friend template <class T> class valarray</Declaration> 167 168 class gslice 169 { 170 valarray<unsigned> __size_; 171 }; 172