blob: ca24bc374d6a44667bc1fd7e8f9c55eadfd84f9e [file] [log] [blame]
Dmitri Gribenko2125c902012-08-22 17:44:32 +00001// Note: the run lines follow their respective tests, since line/column numbers
2// matter in this test.
3
4/// This is T1.
5template<typename T>
6void T1(T t) { }
7
8/// This is T2.
9template<typename T>
10void T2(T t) { }
11
12/// This is T2<int>.
13template<>
14void T2(int t) { }
15
16void test_CC1() {
17
18}
19
20// Check that implicit instantiations of class templates and members pick up
21// comments from class templates and specializations.
22
23/// This is T3.
24template<typename T>
25class T3 {
26public:
27 /// This is T4.
28 static void T4();
29
30 /// This is T5.
31 static int T5;
32
33 /// This is T6.
34 void T6();
35
36 /// This is T7.
37 int T7;
38
39 /// This is T8.
40 class T8 {};
41
42 /// This is T9.
43 enum T9 {
44 /// This is T10.
45 T10
46 };
47
48 /// This is T11.
49 template<typename U>
50 void T11(U t) {}
51
52 typedef T3<double> T12;
53};
54
55void test_CC2_CC3_CC4() {
56 T3<int>::T4();
57 T3<int> t3;
58 t3.T6();
59 T3<int>::T8 t8;
60}
61
62/// This is T100.
63template<typename T, typename U>
64class T100 {
65};
66
67/// This is T100<int, T>.
68template<typename T>
69class T100<int, T> {
70public:
71 /// This is T101.
72 static void T101();
73
74 /// This is T102.
75 static int T102;
76
77 /// This is T103.
78 void T103();
79
80 /// This is T104.
81 int T104;
82
83 /// This is T105.
84 class T105 {};
85
86 /// This is T106.
87 enum T106 {
88 /// This is T107.
89 T107
90 };
91
92 /// This is T108.
93 template<typename U>
94 void T108(U t) {}
95
96 typedef T100<double, T> T109;
97
98 typedef T100<double, double> T110;
99};
100
101void test_CC5_CC6_CC7() {
102 T100<int, long>::T101();
103 T100<int, long> t100;
104 t100.T103();
105 T100<int, long>::T105 t105;
106}
107
Tim Northover931a4fe2013-08-12 12:51:05 +0000108// RUN: env CINDEXTEST_COMPLETION_BRIEF_COMMENTS=1 c-index-test -code-completion-at=%s:17:1 %s | FileCheck -check-prefix=CHECK-CC1 %s
Dmitri Gribenko2125c902012-08-22 17:44:32 +0000109// CHECK-CC1: FunctionTemplate:{ResultType void}{TypedText T1}{{.*}}(brief comment: This is T1.)
110// CHECK-CC1: FunctionTemplate:{ResultType void}{TypedText T2}{{.*}}(brief comment: This is T2.)
111
Tim Northover931a4fe2013-08-12 12:51:05 +0000112// RUN: env CINDEXTEST_COMPLETION_BRIEF_COMMENTS=1 c-index-test -code-completion-at=%s:56:12 %s | FileCheck -check-prefix=CHECK-CC2 %s
Dmitri Gribenko2125c902012-08-22 17:44:32 +0000113// CHECK-CC2: CXXMethod:{ResultType void}{TypedText T4}{{.*}}(brief comment: This is T4.)
114// CHECK-CC2: VarDecl:{ResultType int}{TypedText T5}{{.*}}(brief comment: This is T5.)
115
Tim Northover931a4fe2013-08-12 12:51:05 +0000116// RUN: env CINDEXTEST_COMPLETION_BRIEF_COMMENTS=1 c-index-test -code-completion-at=%s:58:6 %s | FileCheck -check-prefix=CHECK-CC3 %s
Dmitri Gribenko2125c902012-08-22 17:44:32 +0000117// CHECK-CC3: FunctionTemplate:{ResultType void}{TypedText T11}{{.*}}(brief comment: This is T11.)
118// CHECK-CC3: CXXMethod:{ResultType void}{TypedText T6}{{.*}}(brief comment: This is T6.)
119// CHECK-CC3: FieldDecl:{ResultType int}{TypedText T7}{{.*}}(brief comment: This is T7.)
120
Tim Northover931a4fe2013-08-12 12:51:05 +0000121// RUN: env CINDEXTEST_COMPLETION_BRIEF_COMMENTS=1 c-index-test -code-completion-at=%s:59:12 %s | FileCheck -check-prefix=CHECK-CC4 %s
Dmitri Gribenko2125c902012-08-22 17:44:32 +0000122// CHECK-CC4: EnumConstantDecl:{ResultType T3<int>::T9}{TypedText T10}{{.*}}(brief comment: This is T10.)
123// FIXME: after we implement propagating comments through typedefs, this
124// typedef for implicit instantiation should pick up the documentation
125// comment from class template.
126// CHECK-CC4: TypedefDecl:{TypedText T12}
127// CHECK-CC4-SHOULD-BE: TypedefDecl:{TypedText T12}{{.*}}(brief comment: This is T3.)
128// CHECK-CC4: ClassDecl:{TypedText T8}{{.*}}(brief comment: This is T8.)
129// CHECK-CC4: EnumDecl:{TypedText T9}{{.*}}(brief comment: This is T9.)
130
Tim Northover931a4fe2013-08-12 12:51:05 +0000131// RUN: env CINDEXTEST_COMPLETION_BRIEF_COMMENTS=1 c-index-test -code-completion-at=%s:102:20 %s | FileCheck -check-prefix=CHECK-CC5 %s
Dmitri Gribenko2125c902012-08-22 17:44:32 +0000132// CHECK-CC5: CXXMethod:{ResultType void}{TypedText T101}{{.*}}(brief comment: This is T101.)
133// CHECK-CC5: VarDecl:{ResultType int}{TypedText T102}{{.*}}(brief comment: This is T102.)
134
Tim Northover931a4fe2013-08-12 12:51:05 +0000135// RUN: env CINDEXTEST_COMPLETION_BRIEF_COMMENTS=1 c-index-test -code-completion-at=%s:104:8 %s | FileCheck -check-prefix=CHECK-CC6 %s
Dmitri Gribenko2125c902012-08-22 17:44:32 +0000136// CHECK-CC6: CXXMethod:{ResultType void}{TypedText T103}{{.*}}(brief comment: This is T103.)
137// CHECK-CC6: FieldDecl:{ResultType int}{TypedText T104}{{.*}}(brief comment: This is T104.)
138// CHECK-CC6: FunctionTemplate:{ResultType void}{TypedText T108}{{.*}}(brief comment: This is T108.)
139
Tim Northover931a4fe2013-08-12 12:51:05 +0000140// RUN: env CINDEXTEST_COMPLETION_BRIEF_COMMENTS=1 c-index-test -code-completion-at=%s:105:20 %s | FileCheck -check-prefix=CHECK-CC7 %s
Dmitri Gribenko2125c902012-08-22 17:44:32 +0000141// CHECK-CC7: ClassDecl:{TypedText T105}{{.*}}(brief comment: This is T105.)
142// CHECK-CC7: EnumDecl:{TypedText T106}{{.*}}(brief comment: This is T106.)
143// CHECK-CC7: EnumConstantDecl:{ResultType T100<int, long>::T106}{TypedText T107}{{.*}}(brief comment: This is T107.)
144// FIXME: after we implement propagating comments through typedefs, these two
145// typedefs for implicit instantiations should pick up the documentation
146// comment from class template.
147// CHECK-CC7: TypedefDecl:{TypedText T109}
148// CHECK-CC7: TypedefDecl:{TypedText T110}
149// CHECK-CC7-SHOULD-BE: TypedefDecl:{TypedText T109}{{.*}}(brief comment: This is T100.)
150// CHECK-CC7-SHOULD-BE: TypedefDecl:{TypedText T110}{{.*}}(brief comment: This is T100.)
151