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