annotate-comments.cpp 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229
  1. // Run lines are sensitive to line numbers and come below the code.
  2. #ifndef HEADER
  3. #define HEADER
  4. // Not a Doxygen comment. NOT_DOXYGEN
  5. void notdoxy1(void);
  6. /* Not a Doxygen comment. NOT_DOXYGEN */
  7. void notdoxy2(void);
  8. /*/ Not a Doxygen comment. NOT_DOXYGEN */
  9. void notdoxy3(void);
  10. /** Doxygen comment. isdoxy4 IS_DOXYGEN_SINGLE */
  11. void isdoxy4(void);
  12. /**
  13. * Doxygen comment. isdoxy5 IS_DOXYGEN_SINGLE */
  14. void isdoxy5(void);
  15. /**
  16. * Doxygen comment.
  17. * isdoxy6 IS_DOXYGEN_SINGLE */
  18. void isdoxy6(void);
  19. /**
  20. * Doxygen comment.
  21. * isdoxy7 IS_DOXYGEN_SINGLE
  22. */
  23. void isdoxy7(void);
  24. /*! Doxygen comment. isdoxy8 IS_DOXYGEN_SINGLE */
  25. void isdoxy8(void);
  26. /// Doxygen comment. isdoxy9 IS_DOXYGEN_SINGLE
  27. void isdoxy9(void);
  28. // Not a Doxygen comment. NOT_DOXYGEN
  29. /// Doxygen comment. isdoxy10 IS_DOXYGEN_SINGLE
  30. void isdoxy10(void);
  31. /// Doxygen comment. isdoxy11 IS_DOXYGEN_SINGLE
  32. // Not a Doxygen comment. NOT_DOXYGEN
  33. void isdoxy11(void);
  34. /** Doxygen comment. isdoxy12 IS_DOXYGEN_SINGLE */
  35. /* Not a Doxygen comment. NOT_DOXYGEN */
  36. void isdoxy12(void);
  37. /// Doxygen comment. isdoxy13 IS_DOXYGEN_START
  38. /// Doxygen comment. IS_DOXYGEN_END
  39. void isdoxy13(void);
  40. /// Doxygen comment. isdoxy14 IS_DOXYGEN_START
  41. /// Blah-blah-blah.
  42. /// Doxygen comment. IS_DOXYGEN_END
  43. void isdoxy14(void);
  44. /// Doxygen comment. isdoxy15 IS_DOXYGEN_START
  45. /** Blah-blah-blah */
  46. /// Doxygen comment. IS_DOXYGEN_END
  47. void isdoxy15(void);
  48. /** Blah-blah-blah. isdoxy16 IS_DOXYGEN_START *//** Blah */
  49. /// Doxygen comment. IS_DOXYGEN_END
  50. void isdoxy16(void);
  51. /// isdoxy17 IS_DOXYGEN_START
  52. // Not a Doxygen comment, but still picked up.
  53. /// IS_DOXYGEN_END
  54. void isdoxy17(void);
  55. unsigned
  56. // NOT_DOXYGEN
  57. /// isdoxy18 IS_DOXYGEN_START
  58. // Not a Doxygen comment, but still picked up.
  59. /// IS_DOXYGEN_END
  60. // NOT_DOXYGEN
  61. int isdoxy18(void);
  62. //! It all starts here. isdoxy19 IS_DOXYGEN_START
  63. /*! It's a little odd to continue line this,
  64. *
  65. * but we need more multi-line comments. */
  66. /// This comment comes before my other comments
  67. /** This is a block comment that is associated with the function f. It
  68. * runs for three lines. IS_DOXYGEN_END
  69. */
  70. void isdoxy19(int, int);
  71. // NOT IN THE COMMENT NOT_DOXYGEN
  72. /// This is a BCPL comment. isdoxy20 IS_DOXYGEN_START
  73. /// It has only two lines.
  74. /** But there are other blocks that are part of the comment, too. IS_DOXYGEN_END */
  75. void isdoxy20(int);
  76. void isdoxy21(int); ///< This is a member comment. isdoxy21 IS_DOXYGEN_SINGLE
  77. void isdoxy22(int); /*!< This is a member comment. isdoxy22 IS_DOXYGEN_SINGLE */
  78. void isdoxy23(int); /**< This is a member comment. isdoxy23 IS_DOXYGEN_SINGLE */
  79. void notdoxy24(int); // NOT_DOXYGEN
  80. /// IS_DOXYGEN_SINGLE
  81. struct isdoxy25 {
  82. };
  83. struct test26 {
  84. /// IS_DOXYGEN_SINGLE
  85. int isdoxy26;
  86. };
  87. struct test27 {
  88. int isdoxy27; ///< IS_DOXYGEN_SINGLE
  89. };
  90. struct notdoxy28 {
  91. }; ///< IS_DOXYGEN_NOT_ATTACHED
  92. /// IS_DOXYGEN_SINGLE
  93. enum isdoxy29 {
  94. };
  95. enum notdoxy30 {
  96. }; ///< IS_DOXYGEN_NOT_ATTACHED
  97. /// IS_DOXYGEN_SINGLE
  98. namespace isdoxy31 {
  99. };
  100. namespace notdoxy32 {
  101. }; ///< IS_DOXYGEN_NOT_ATTACHED
  102. class test33 {
  103. ///< IS_DOXYGEN_NOT_ATTACHED
  104. int isdoxy33; ///< isdoxy33 IS_DOXYGEN_SINGLE
  105. int isdoxy34; ///< isdoxy34 IS_DOXYGEN_SINGLE
  106. ///< IS_DOXYGEN_NOT_ATTACHED
  107. int isdoxy35, ///< isdoxy35 IS_DOXYGEN_SINGLE
  108. isdoxy36; ///< isdoxy36 IS_DOXYGEN_SINGLE
  109. ///< IS_DOXYGEN_NOT_ATTACHED
  110. int isdoxy37 ///< isdoxy37 IS_DOXYGEN_SINGLE
  111. , isdoxy38 ///< isdoxy38 IS_DOXYGEN_SINGLE
  112. , isdoxy39; ///< isdoxy39 IS_DOXYGEN_SINGLE
  113. };
  114. // Verified that Doxygen attaches these.
  115. /// isdoxy40 IS_DOXYGEN_SINGLE
  116. // NOT_DOXYGEN
  117. void isdoxy40(int);
  118. unsigned
  119. /// isdoxy41 IS_DOXYGEN_SINGLE
  120. // NOT_DOXYGEN
  121. int isdoxy41(int);
  122. class test42 {
  123. int isdoxy42; /* NOT_DOXYGEN */ ///< isdoxy42 IS_DOXYGEN_SINGLE
  124. };
  125. #endif
  126. // RUN: rm -rf %t
  127. // RUN: mkdir %t
  128. // RUN: %clang_cc1 -x c++ -emit-pch -o %t/out.pch %s
  129. // RUN: %clang_cc1 -x c++ -include-pch %t/out.pch -fsyntax-only %s
  130. // RUN: c-index-test -test-load-source all %s > %t/out.c-index-direct
  131. // RUN: c-index-test -test-load-tu %t/out.pch all > %t/out.c-index-pch
  132. // RUN: FileCheck %s -check-prefix=WRONG < %t/out.c-index-direct
  133. // RUN: FileCheck %s -check-prefix=WRONG < %t/out.c-index-pch
  134. // Declarations without Doxygen comments should not pick up some Doxygen comments.
  135. // WRONG-NOT: notdoxy{{.*}}Comment=
  136. // WRONG-NOT: test{{.*}}Comment=
  137. // Non-Doxygen comments should not be attached to anything.
  138. // WRONG-NOT: NOT_DOXYGEN
  139. // Some Doxygen comments are not attached to anything.
  140. // WRONG-NOT: IS_DOXYGEN_NOT_ATTACHED
  141. // Ensure we don't pick up extra comments.
  142. // WRONG-NOT: IS_DOXYGEN_START{{.*}}IS_DOXYGEN_START
  143. // WRONG-NOT: IS_DOXYGEN_END{{.*}}IS_DOXYGEN_END
  144. // RUN: FileCheck %s < %t/out.c-index-direct
  145. // RUN: FileCheck %s < %t/out.c-index-pch
  146. // CHECK: annotate-comments.cpp:16:6: FunctionDecl=isdoxy4:{{.*}} isdoxy4 IS_DOXYGEN_SINGLE
  147. // CHECK: annotate-comments.cpp:20:6: FunctionDecl=isdoxy5:{{.*}} isdoxy5 IS_DOXYGEN_SINGLE
  148. // CHECK: annotate-comments.cpp:25:6: FunctionDecl=isdoxy6:{{.*}} isdoxy6 IS_DOXYGEN_SINGLE
  149. // CHECK: annotate-comments.cpp:31:6: FunctionDecl=isdoxy7:{{.*}} isdoxy7 IS_DOXYGEN_SINGLE
  150. // CHECK: annotate-comments.cpp:34:6: FunctionDecl=isdoxy8:{{.*}} isdoxy8 IS_DOXYGEN_SINGLE
  151. // CHECK: annotate-comments.cpp:37:6: FunctionDecl=isdoxy9:{{.*}} isdoxy9 IS_DOXYGEN_SINGLE
  152. // CHECK: annotate-comments.cpp:41:6: FunctionDecl=isdoxy10:{{.*}} isdoxy10 IS_DOXYGEN_SINGLE
  153. // CHECK: annotate-comments.cpp:53:6: FunctionDecl=isdoxy13:{{.*}} isdoxy13 IS_DOXYGEN_START{{.*}} IS_DOXYGEN_END
  154. // CHECK: annotate-comments.cpp:58:6: FunctionDecl=isdoxy14:{{.*}} isdoxy14 IS_DOXYGEN_START{{.*}} IS_DOXYGEN_END
  155. // CHECK: annotate-comments.cpp:63:6: FunctionDecl=isdoxy15:{{.*}} isdoxy15 IS_DOXYGEN_START{{.*}} IS_DOXYGEN_END
  156. // CHECK: annotate-comments.cpp:67:6: FunctionDecl=isdoxy16:{{.*}} isdoxy16 IS_DOXYGEN_START{{.*}} IS_DOXYGEN_END
  157. // CHECK: annotate-comments.cpp:72:6: FunctionDecl=isdoxy17:{{.*}} isdoxy17 IS_DOXYGEN_START{{.*}} IS_DOXYGEN_END
  158. // CHECK: annotate-comments.cpp:80:5: FunctionDecl=isdoxy18:{{.*}} isdoxy18 IS_DOXYGEN_START{{.*}} IS_DOXYGEN_END
  159. // CHECK: annotate-comments.cpp:90:6: FunctionDecl=isdoxy19:{{.*}} isdoxy19 IS_DOXYGEN_START{{.*}} IS_DOXYGEN_END
  160. // CHECK: annotate-comments.cpp:96:6: FunctionDecl=isdoxy20:{{.*}} isdoxy20 IS_DOXYGEN_START{{.*}} IS_DOXYGEN_END
  161. // CHECK: annotate-comments.cpp:98:6: FunctionDecl=isdoxy21:{{.*}} isdoxy21 IS_DOXYGEN_SINGLE
  162. // CHECK: annotate-comments.cpp:100:6: FunctionDecl=isdoxy22:{{.*}} isdoxy22 IS_DOXYGEN_SINGLE
  163. // CHECK: annotate-comments.cpp:102:6: FunctionDecl=isdoxy23:{{.*}} isdoxy23 IS_DOXYGEN_SINGLE
  164. // CHECK: annotate-comments.cpp:107:8: StructDecl=isdoxy25:{{.*}} IS_DOXYGEN_SINGLE
  165. // CHECK: annotate-comments.cpp:112:7: FieldDecl=isdoxy26:{{.*}} IS_DOXYGEN_SINGLE
  166. // CHECK: annotate-comments.cpp:116:7: FieldDecl=isdoxy27:{{.*}} IS_DOXYGEN_SINGLE
  167. // CHECK: annotate-comments.cpp:123:6: EnumDecl=isdoxy29:{{.*}} IS_DOXYGEN_SINGLE
  168. // CHECK: annotate-comments.cpp:130:11: Namespace=isdoxy31:{{.*}} IS_DOXYGEN_SINGLE
  169. // CHECK: annotate-comments.cpp:138:7: FieldDecl=isdoxy33:{{.*}} isdoxy33 IS_DOXYGEN_SINGLE
  170. // CHECK: annotate-comments.cpp:139:7: FieldDecl=isdoxy34:{{.*}} isdoxy34 IS_DOXYGEN_SINGLE
  171. // CHECK: annotate-comments.cpp:142:7: FieldDecl=isdoxy35:{{.*}} isdoxy35 IS_DOXYGEN_SINGLE
  172. // CHECK: annotate-comments.cpp:143:7: FieldDecl=isdoxy36:{{.*}} isdoxy36 IS_DOXYGEN_SINGLE
  173. // CHECK: annotate-comments.cpp:146:7: FieldDecl=isdoxy37:{{.*}} isdoxy37 IS_DOXYGEN_SINGLE
  174. // CHECK: annotate-comments.cpp:147:7: FieldDecl=isdoxy38:{{.*}} isdoxy38 IS_DOXYGEN_SINGLE
  175. // CHECK: annotate-comments.cpp:148:7: FieldDecl=isdoxy39:{{.*}} isdoxy39 IS_DOXYGEN_SINGLE
  176. // CHECK: annotate-comments.cpp:155:6: FunctionDecl=isdoxy40:{{.*}} isdoxy40 IS_DOXYGEN_SINGLE
  177. // CHECK: annotate-comments.cpp:160:5: FunctionDecl=isdoxy41:{{.*}} isdoxy41 IS_DOXYGEN_SINGLE
  178. // CHECK: annotate-comments.cpp:163:7: FieldDecl=isdoxy42:{{.*}} isdoxy42 IS_DOXYGEN_SINGLE