2
0

comment-cplus-decls.cpp 3.3 KB

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