[docs] Add LICENSE.txt to the root of the mono-repo
[llvm-project.git] / clang / test / Index / complete-documentation-templates.cpp
blobca24bc374d6a44667bc1fd7e8f9c55eadfd84f9e
1 // Note: the run lines follow their respective tests, since line/column numbers
2 // matter in this test.
4 /// This is T1.
5 template<typename T>
6 void T1(T t) { }
8 /// This is T2.
9 template<typename T>
10 void T2(T t) { }
12 /// This is T2<int>.
13 template<>
14 void T2(int t) { }
16 void test_CC1() {
20 // Check that implicit instantiations of class templates and members pick up
21 // comments from class templates and specializations.
23 /// This is T3.
24 template<typename T>
25 class T3 {
26 public:
27 /// This is T4.
28 static void T4();
30 /// This is T5.
31 static int T5;
33 /// This is T6.
34 void T6();
36 /// This is T7.
37 int T7;
39 /// This is T8.
40 class T8 {};
42 /// This is T9.
43 enum T9 {
44 /// This is T10.
45 T10
48 /// This is T11.
49 template<typename U>
50 void T11(U t) {}
52 typedef T3<double> T12;
55 void test_CC2_CC3_CC4() {
56 T3<int>::T4();
57 T3<int> t3;
58 t3.T6();
59 T3<int>::T8 t8;
62 /// This is T100.
63 template<typename T, typename U>
64 class T100 {
67 /// This is T100<int, T>.
68 template<typename T>
69 class T100<int, T> {
70 public:
71 /// This is T101.
72 static void T101();
74 /// This is T102.
75 static int T102;
77 /// This is T103.
78 void T103();
80 /// This is T104.
81 int T104;
83 /// This is T105.
84 class T105 {};
86 /// This is T106.
87 enum T106 {
88 /// This is T107.
89 T107
92 /// This is T108.
93 template<typename U>
94 void T108(U t) {}
96 typedef T100<double, T> T109;
98 typedef T100<double, double> T110;
101 void test_CC5_CC6_CC7() {
102 T100<int, long>::T101();
103 T100<int, long> t100;
104 t100.T103();
105 T100<int, long>::T105 t105;
108 // RUN: env CINDEXTEST_COMPLETION_BRIEF_COMMENTS=1 c-index-test -code-completion-at=%s:17:1 %s | FileCheck -check-prefix=CHECK-CC1 %s
109 // 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.)
112 // RUN: env CINDEXTEST_COMPLETION_BRIEF_COMMENTS=1 c-index-test -code-completion-at=%s:56:12 %s | FileCheck -check-prefix=CHECK-CC2 %s
113 // 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.)
116 // RUN: env CINDEXTEST_COMPLETION_BRIEF_COMMENTS=1 c-index-test -code-completion-at=%s:58:6 %s | FileCheck -check-prefix=CHECK-CC3 %s
117 // 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.)
121 // RUN: env CINDEXTEST_COMPLETION_BRIEF_COMMENTS=1 c-index-test -code-completion-at=%s:59:12 %s | FileCheck -check-prefix=CHECK-CC4 %s
122 // 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.)
131 // RUN: env CINDEXTEST_COMPLETION_BRIEF_COMMENTS=1 c-index-test -code-completion-at=%s:102:20 %s | FileCheck -check-prefix=CHECK-CC5 %s
132 // 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.)
135 // RUN: env CINDEXTEST_COMPLETION_BRIEF_COMMENTS=1 c-index-test -code-completion-at=%s:104:8 %s | FileCheck -check-prefix=CHECK-CC6 %s
136 // 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.)
140 // RUN: env CINDEXTEST_COMPLETION_BRIEF_COMMENTS=1 c-index-test -code-completion-at=%s:105:20 %s | FileCheck -check-prefix=CHECK-CC7 %s
141 // 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.)