xref: /aosp_15_r20/external/clang/test/Index/parse-all-comments.c (revision 67e74705e28f6214e480b399dd47ea732279e315)
1*67e74705SXin Li // Run lines are sensitive to line numbers and come below the code.
2*67e74705SXin Li 
3*67e74705SXin Li #ifndef HEADER
4*67e74705SXin Li #define HEADER
5*67e74705SXin Li 
6*67e74705SXin Li // Not a Doxygen comment.  notdoxy1 NOT_DOXYGEN
7*67e74705SXin Li void notdoxy1(void);
8*67e74705SXin Li 
9*67e74705SXin Li /* Not a Doxygen comment.  notdoxy2 NOT_DOXYGEN */
10*67e74705SXin Li void notdoxy2(void);
11*67e74705SXin Li 
12*67e74705SXin Li /*/ Not a Doxygen comment.  notdoxy3 NOT_DOXYGEN */
13*67e74705SXin Li void notdoxy3(void);
14*67e74705SXin Li 
15*67e74705SXin Li /** Doxygen comment.  isdoxy4 IS_DOXYGEN_SINGLE */
16*67e74705SXin Li void isdoxy4(void);
17*67e74705SXin Li 
18*67e74705SXin Li /*! Doxygen comment.  isdoxy5 IS_DOXYGEN_SINGLE */
19*67e74705SXin Li void isdoxy5(void);
20*67e74705SXin Li 
21*67e74705SXin Li /// Doxygen comment.  isdoxy6 IS_DOXYGEN_SINGLE
22*67e74705SXin Li void isdoxy6(void);
23*67e74705SXin Li 
24*67e74705SXin Li /* BLOCK_ORDINARY_COMMENT */
25*67e74705SXin Li // ORDINARY COMMENT
26*67e74705SXin Li /// This is a BCPL comment. IS_DOXYGEN_START
27*67e74705SXin Li /// It has only two lines.
28*67e74705SXin Li /** But there are other blocks that are part of the comment, too.  IS_DOXYGEN_END */
29*67e74705SXin Li void multi_line_comment_plus_ordinary(int);
30*67e74705SXin Li 
31*67e74705SXin Li // MULTILINE COMMENT
32*67e74705SXin Li //
33*67e74705SXin Li // WITH EMPTY LINE
34*67e74705SXin Li void multi_line_comment_empty_line(int);
35*67e74705SXin Li 
36*67e74705SXin Li int notdoxy7; // Not a Doxygen juxtaposed comment.  notdoxy7 NOT_DOXYGEN
37*67e74705SXin Li int notdoxy8; // Not a Doxygen juxtaposed comment.  notdoxy8 NOT_DOXYGEN
38*67e74705SXin Li 
39*67e74705SXin Li int trdoxy9;  /// A Doxygen non-trailing comment.  trdoxyA IS_DOXYGEN_SINGLE
40*67e74705SXin Li int trdoxyA;
41*67e74705SXin Li 
42*67e74705SXin Li int trdoxyB;  // Not a Doxygen trailing comment.  PART_ONE
43*67e74705SXin Li               // It's a multiline one too.  trdoxyB NOT_DOXYGEN
44*67e74705SXin Li int trdoxyC;
45*67e74705SXin Li 
46*67e74705SXin Li int trdoxyD;  // Not a Doxygen trailing comment.   trdoxyD NOT_DOXYGEN
47*67e74705SXin Li               /// This comment doesn't get merged.   trdoxyE IS_DOXYGEN
48*67e74705SXin Li int trdoxyE;
49*67e74705SXin Li 
50*67e74705SXin Li int trdoxyF;  /// A Doxygen non-trailing comment that gets dropped on the floor.
51*67e74705SXin Li               // This comment will also be dropped.
52*67e74705SXin Li int trdoxyG;  // This one won't.  trdoxyG NOT_DOXYGEN
53*67e74705SXin Li 
54*67e74705SXin Li int trdoxyH;  ///< A Doxygen trailing comment.  PART_ONE
55*67e74705SXin Li               // This one gets merged with it.  trdoxyH SOME_DOXYGEN
56*67e74705SXin Li int trdoxyI;  // This one doesn't.  trdoxyI NOT_DOXYGEN
57*67e74705SXin Li 
58*67e74705SXin Li int trdoxyJ;  // Not a Doxygen trailing comment.  PART_ONE
59*67e74705SXin Li               ///< This one gets merged with it.  trdoxyJ SOME_DOXYGEN
60*67e74705SXin Li int trdoxyK;  // This one doesn't.  trdoxyK NOT_DOXYGEN
61*67e74705SXin Li 
62*67e74705SXin Li int trdoxyL;  // Not a Doxygen trailing comment.  trdoxyL NOT_DOXYGEN
63*67e74705SXin Li // This one shouldn't get merged.  trdoxyM NOT_DOXYGEN
64*67e74705SXin Li int trdoxyM;
65*67e74705SXin Li 
66*67e74705SXin Li int trdoxyN;  ///< A Doxygen trailing comment.  trdoxyN IS_DOXYGEN
67*67e74705SXin Li   // This one shouldn't get merged.  trdoxyO NOT_DOXYGEN
68*67e74705SXin Li int trdoxyO;
69*67e74705SXin Li 
70*67e74705SXin Li 
71*67e74705SXin Li #endif
72*67e74705SXin Li 
73*67e74705SXin Li // RUN: rm -rf %t
74*67e74705SXin Li // RUN: mkdir %t
75*67e74705SXin Li 
76*67e74705SXin Li // RUN: c-index-test -write-pch %t/out.pch -fparse-all-comments -x c++ -std=c++11 %s
77*67e74705SXin Li 
78*67e74705SXin Li // RUN: c-index-test -test-load-source all -comments-xml-schema=%S/../../bindings/xml/comment-xml-schema.rng %s -std=c++11 -fparse-all-comments > %t/out.c-index-direct
79*67e74705SXin Li // RUN: c-index-test -test-load-tu %t/out.pch all > %t/out.c-index-pch
80*67e74705SXin Li 
81*67e74705SXin Li // RUN: FileCheck %s -check-prefix=WRONG < %t/out.c-index-direct
82*67e74705SXin Li // RUN: FileCheck %s -check-prefix=WRONG < %t/out.c-index-pch
83*67e74705SXin Li 
84*67e74705SXin Li // Ensure that XML is not invalid
85*67e74705SXin Li // WRONG-NOT: CommentXMLInvalid
86*67e74705SXin Li 
87*67e74705SXin Li // RUN: FileCheck %s < %t/out.c-index-direct
88*67e74705SXin Li // RUN: FileCheck %s < %t/out.c-index-pch
89*67e74705SXin Li 
90*67e74705SXin Li // CHECK: parse-all-comments.c:7:6: FunctionDecl=notdoxy1:{{.*}} notdoxy1 NOT_DOXYGEN
91*67e74705SXin Li // CHECK: parse-all-comments.c:10:6: FunctionDecl=notdoxy2:{{.*}} notdoxy2 NOT_DOXYGEN
92*67e74705SXin Li // CHECK: parse-all-comments.c:13:6: FunctionDecl=notdoxy3:{{.*}} notdoxy3 NOT_DOXYGEN
93*67e74705SXin Li // CHECK: parse-all-comments.c:16:6: FunctionDecl=isdoxy4:{{.*}} isdoxy4 IS_DOXYGEN_SINGLE
94*67e74705SXin Li // CHECK: parse-all-comments.c:19:6: FunctionDecl=isdoxy5:{{.*}} isdoxy5 IS_DOXYGEN_SINGLE
95*67e74705SXin Li // CHECK: parse-all-comments.c:22:6: FunctionDecl=isdoxy6:{{.*}} isdoxy6 IS_DOXYGEN_SINGLE
96*67e74705SXin Li // CHECK: parse-all-comments.c:29:6: FunctionDecl=multi_line_comment_plus_ordinary:{{.*}} BLOCK_ORDINARY_COMMENT {{.*}} ORDINARY COMMENT {{.*}} IS_DOXYGEN_START {{.*}} IS_DOXYGEN_END
97*67e74705SXin Li // CHECK: parse-all-comments.c:34:6: FunctionDecl=multi_line_comment_empty_line:{{.*}} MULTILINE COMMENT{{.*}}\n{{.*}}\n{{.*}} WITH EMPTY LINE
98*67e74705SXin Li // CHECK: parse-all-comments.c:36:5: VarDecl=notdoxy7:{{.*}} notdoxy7 NOT_DOXYGEN
99*67e74705SXin Li // CHECK: parse-all-comments.c:37:5: VarDecl=notdoxy8:{{.*}} notdoxy8 NOT_DOXYGEN
100*67e74705SXin Li // CHECK-NOT: parse-all-comments.c:39:5: VarDecl=trdoxy9:{{.*}} trdoxyA IS_DOXYGEN_SINGLE
101*67e74705SXin Li // CHECK: parse-all-comments.c:40:5: VarDecl=trdoxyA:{{.*}} trdoxyA IS_DOXYGEN_SINGLE
102*67e74705SXin Li // CHECK: parse-all-comments.c:42:5: VarDecl=trdoxyB:{{.*}} PART_ONE {{.*}} trdoxyB NOT_DOXYGEN
103*67e74705SXin Li // CHECK-NOT: parse-all-comments.c:44:5: VarDecl=trdoxyC:{{.*}} trdoxyB NOT_DOXYGEN
104*67e74705SXin Li // CHECK: parse-all-comments.c:46:5: VarDecl=trdoxyD:{{.*}} trdoxyD NOT_DOXYGEN
105*67e74705SXin Li // CHECK: parse-all-comments.c:48:5: VarDecl=trdoxyE:{{.*}} trdoxyE IS_DOXYGEN
106*67e74705SXin Li // CHECK-NOT: parse-all-comments.c:50:5: VarDecl=trdoxyF:{{.*}} RawComment
107*67e74705SXin Li // CHECK: parse-all-comments.c:52:5: VarDecl=trdoxyG:{{.*}} trdoxyG NOT_DOXYGEN
108*67e74705SXin Li // CHECK: parse-all-comments.c:54:5: VarDecl=trdoxyH:{{.*}} PART_ONE {{.*}} trdoxyH SOME_DOXYGEN
109*67e74705SXin Li // CHECK: parse-all-comments.c:56:5: VarDecl=trdoxyI:{{.*}} trdoxyI NOT_DOXYGEN
110*67e74705SXin Li // CHECK: parse-all-comments.c:58:5: VarDecl=trdoxyJ:{{.*}} PART_ONE {{.*}} trdoxyJ SOME_DOXYGEN
111*67e74705SXin Li // CHECK: parse-all-comments.c:60:5: VarDecl=trdoxyK:{{.*}} trdoxyK NOT_DOXYGEN
112*67e74705SXin Li // CHECK: parse-all-comments.c:62:5: VarDecl=trdoxyL:{{.*}} trdoxyL NOT_DOXYGEN
113*67e74705SXin Li // CHECK: parse-all-comments.c:64:5: VarDecl=trdoxyM:{{.*}} trdoxyM NOT_DOXYGEN
114*67e74705SXin Li // CHECK: parse-all-comments.c:66:5: VarDecl=trdoxyN:{{.*}} trdoxyN IS_DOXYGEN
115*67e74705SXin Li // CHECK: parse-all-comments.c:68:5: VarDecl=trdoxyO:{{.*}} trdoxyO NOT_DOXYGEN
116