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