177 lines · cpp
1// RUN: rm -rf %t2// RUN: mkdir %t3// 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/out4// RUN: FileCheck %s < %t/out5// 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/986// RUN: FileCheck %s < %t/987// 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/118// RUN: FileCheck %s < %t/119 10// Ensure that XML we generate is not invalid.11// RUN: FileCheck %s -check-prefix=WRONG < %t/out12// RUN: FileCheck %s -check-prefix=WRONG < %t/9813// RUN: FileCheck %s -check-prefix=WRONG < %t/1114// WRONG-NOT: CommentXMLInvalid15 16/**17 * \brief plain c++ class18*/19class Test20{21public:22/**23 * \brief plain c++ constructor24*/25 Test () : reserved (new data()) {}26 27/**28 * \brief plain c++ member function29*/30 unsigned getID() const31 {32 return reserved->objectID;33 }34/**35 * \brief plain c++ destructor36*/37 ~Test () {}38protected:39 struct data {40 unsigned objectID;41 };42/**43 * \brief plain c++ data field44*/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 54class S {55/**56 * \brief Aaa57*/58 friend class Test;59/**60 * \brief Bbb61*/62 friend void foo() {}63 64/**65 * \brief Ccc66*/67 friend int int_func();68 69/**70 * \brief Ddd71*/72 friend bool operator==(const Test &, const Test &);73 74/**75 * \brief Eee76*/77template <typename T> friend void TemplateFriend();78 79/**80 * \brief Eee81*/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 92namespace test0 {93 namespace ns {94 void f(int);95 }96 97 struct A {98/**99 * \brief Fff100*/101 friend void ns::f(int a);102 };103}104// CHECK: <Declaration>friend void ns::f(int a)</Declaration>105 106namespace test1 {107 template <class T> struct Outer {108 void foo(T);109 struct Inner {110/**111 * \brief Ggg112*/113 friend void Outer::foo(T);114 };115 };116}117// CHECK: <Declaration>friend void Outer<T>::foo(T)</Declaration>118 119namespace test2 {120 namespace foo {121 void Func(int x);122 }123 124 class Bar {125/**126 * \brief Hhh127*/128 friend void ::test2::foo::Func(int x);129 };130}131// CHECK: <Declaration>friend void ::test2::foo::Func(int x)</Declaration>132 133namespace test3 {134 template<class T> class vector {135 public:136 vector(int i) {}137/**138 * \brief Iii139*/140 void f(const T& t = T()) {}141 };142 class A {143 private:144/**145 * \brief Jjj146*/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 153class MyClass154{155/**156 * \brief plain friend test.157*/158 friend class MyClass;159};160// CHECK: <Declaration>friend class MyClass</Declaration>161 162template<class _Tp> class valarray163{164private: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 173class gslice174{175 valarray<unsigned> __size_;176};177