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 // rdar://12378714 16 17 /** 18 * \brief plain c++ class 19 */ 20 class Test 21 { 22 public: 23 /** 24 * \brief plain c++ constructor 25 */ Test()26 Test () : reserved (new data()) {} 27 28 /** 29 * \brief plain c++ member function 30 */ getID() const31 unsigned getID() const 32 { 33 return reserved->objectID; 34 } 35 /** 36 * \brief plain c++ destructor 37 */ ~Test()38 ~Test () {} 39 protected: 40 struct data { 41 unsigned objectID; 42 }; 43 /** 44 * \brief plain c++ data field 45 */ 46 data* reserved; 47 }; 48 // CHECK: <Declaration>class Test {}</Declaration> 49 // CHECK: <Declaration>Test()</Declaration> 50 // CHECK: <Declaration>unsigned int getID() const</Declaration> 51 // CHECK: <Declaration>~Test(){{( noexcept)?}}</Declaration> 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 */ foo()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 }; 86 // CHECK: <Declaration>friend class Test</Declaration> 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 ns::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 Outer<T>::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 ::test2::foo::Func(int x)</Declaration> 133 134 namespace test3 { 135 template<class T> class vector { 136 public: vector(int i)137 vector(int i) {} 138 /** 139 * \brief Iii 140 */ f(const T & t=T ())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 vector<A>::f(const test3::A &)</Declaration> 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 }; 171 // CHECK: <Declaration>template <class T> class valarray</Declaration> 172 // CHECK: <Declaration>friend template <class T> class valarray</Declaration> 173 174 class gslice 175 { 176 valarray<unsigned> __size_; 177 }; 178