12 struct Base3
: Base1
, Base2
{
14 void memfun1(double) const;
18 struct Derived
: Base3
{
19 template <typename T
> Derived(T
);
27 Derived
*operator->() const;
30 void test(const Proxy
&p
) {
38 b
. // expected-error {{invalid use of member 'b' in static member function}}
44 static void foo(bool);
48 void foo(bool param
) {
49 Foo::foo( );// unresolved member expression with an implicit base
53 // RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:31:6 %s -o - | FileCheck -check-prefix=CHECK-CC1 --implicit-check-not="Derived : Derived(" %s
54 // CHECK-CC1: Base1 (InBase) : Base1::
55 // CHECK-CC1: member1 (InBase) : [#int#][#Base1::#]member1
56 // CHECK-CC1: member1 (InBase) : [#int#][#Base2::#]member1
57 // CHECK-CC1: member2 (InBase) : [#float#][#Base1::#]member2
58 // CHECK-CC1: member3 (InBase)
60 // CHECK-CC1: memfun1 (InBase) : [#void#][#Base3::#]memfun1(<#float#>)
61 // CHECK-CC1: memfun1 (InBase) : [#void#][#Base3::#]memfun1(<#double#>)[# const#]
62 // CHECK-CC1: memfun1 (Hidden,InBase) : [#void#]Base2::memfun1(<#int#>)
63 // CHECK-CC1: memfun2 (InBase) : [#void#][#Base3::#]memfun2(<#int#>)
64 // CHECK-CC1: memfun3 : [#int#]memfun3(<#int#>)
66 // Make sure this doesn't crash
67 // RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:38:7 %s -verify
69 // Make sure this also doesn't crash
70 // RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:49:14 %s
76 T
baseTemplateFunction();
81 template<typename T
, typename S
>
82 class TemplateClass
: public Base1
, public BaseTemplate
<T
> {
87 TemplateClass
<S
, T
> &relatedField
;
88 BaseTemplate
<S
> &relatedFunction();
90 void overload1(const T
&);
91 void overload1(const S
&);
94 template<typename T
, typename S
>
95 void completeDependentMembers(TemplateClass
<T
, S
> &object
,
96 TemplateClass
<int, S
> *object2
) {
99 // CHECK-CC2: baseTemplateField (InBase) : [#T#][#BaseTemplate<T>::#]baseTemplateField
100 // CHECK-CC2: baseTemplateFunction (InBase) : [#T#][#BaseTemplate<T>::#]baseTemplateFunction()
101 // CHECK-CC2: field : [#T#]field
102 // CHECK-CC2: function : [#T#]function()
103 // CHECK-CC2: member1 (InBase) : [#int#][#Base1::#]member1
104 // CHECK-CC2: member2 (InBase) : [#float#][#Base1::#]member2
105 // CHECK-CC2: overload1 : [#void#]overload1(<#const T &#>)
106 // CHECK-CC2: overload1 : [#void#]overload1(<#const S &#>)
108 // RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:97:10 %s -o - | FileCheck -check-prefix=CHECK-CC2 %s
109 // RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:98:12 %s -o - | FileCheck -check-prefix=CHECK-CC2 %s
111 auto copy_object
= object
;
112 auto copy_object2
= object2
;
115 // CHECK-AUTO: field : [#T#]field
116 // RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:113:10 %s -o - | FileCheck -check-prefix=CHECK-AUTO %s
117 // RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:114:12 %s -o - | FileCheck -check-prefix=CHECK-AUTO %s
119 object
.relatedField
.relatedFunction().baseTemplateField
;
120 // CHECK-DEP-CHAIN: baseTemplateField : [#T#]baseTemplateField
121 // RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:119:41 %s -o - | FileCheck -check-prefix=CHECK-DEP-CHAIN %s
125 void completeDependentSpecializedMembers(TemplateClass
<int, double> &object
,
126 TemplateClass
<int, double> *object2
) {
129 // CHECK-CC3: baseTemplateField (InBase) : [#int#][#BaseTemplate<int>::#]baseTemplateField
130 // CHECK-CC3: baseTemplateFunction (InBase) : [#int#][#BaseTemplate<int>::#]baseTemplateFunction()
131 // CHECK-CC3: field : [#int#]field
132 // CHECK-CC3: function : [#int#]function()
133 // CHECK-CC3: member1 (InBase) : [#int#][#Base1::#]member1
134 // CHECK-CC3: member2 (InBase) : [#float#][#Base1::#]member2
135 // CHECK-CC3: overload1 : [#void#]overload1(<#const int &#>)
136 // CHECK-CC3: overload1 : [#void#]overload1(<#const double &#>)
138 // RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:127:10 %s -o - | FileCheck -check-prefix=CHECK-CC3 %s
139 // RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:128:12 %s -o - | FileCheck -check-prefix=CHECK-CC3 %s
142 template <typename T
>
145 BaseTemplate
<int> o1
;
149 o1
.baseTemplateField
;
150 // CHECK-CC4: BaseTemplate : BaseTemplate::
151 // CHECK-CC4: baseTemplateField : [#int#]baseTemplateField
152 // CHECK-CC4: baseTemplateFunction : [#int#]baseTemplateFunction()
153 // RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:149:8 %s -o - | FileCheck -check-prefix=CHECK-CC4 %s
154 o2
.baseTemplateField
;
155 // CHECK-CC5: BaseTemplate : BaseTemplate::
156 // CHECK-CC5: baseTemplateField : [#T#]baseTemplateField
157 // CHECK-CC5: baseTemplateFunction : [#T#]baseTemplateFunction()
158 // RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:154:8 %s -o - | FileCheck -check-prefix=CHECK-CC5 %s
160 // CHECK-CC6: [#void#]function()
161 // CHECK-CC6: o1 : [#BaseTemplate<int>#]o1
162 // CHECK-CC6: o2 : [#BaseTemplate<T>#]o2
163 // RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:159:11 %s -o - | FileCheck -check-prefix=CHECK-CC6 %s
166 static void staticFn(T
&obj
);
172 void dependentColonColonCompletion() {
173 Template
<T
>::staticFn();
174 // CHECK-CC7: function : [#void#]function()
175 // CHECK-CC7: Nested : Nested
176 // CHECK-CC7: o1 : [#BaseTemplate<int>#]o1
177 // CHECK-CC7: o2 : [#BaseTemplate<T>#]o2
178 // CHECK-CC7: staticFn : [#void#]staticFn(<#T &obj#>)
179 // CHECK-CC7: Template : Template
180 // RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:173:16 %s -o - | FileCheck -check-prefix=CHECK-CC7 %s
181 typename Template
<T
>::Nested m
;
182 // RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:181:25 %s -o - | FileCheck -check-prefix=CHECK-CC7 %s
187 Derived
*operator->() const;
191 void test2(const Proxy2
&p
) {
195 void test3(const Proxy2
&p
) {
199 // RUN: %clang_cc1 -fsyntax-only -code-completion-with-fixits -code-completion-at=%s:192:6 %s -o - | FileCheck -check-prefix=CHECK-CC8 --implicit-check-not="Derived : Derived(" %s
200 // CHECK-CC8: Base1 (InBase) : Base1::
201 // CHECK-CC8: member1 (InBase) : [#int#][#Base1::#]member1
202 // CHECK-CC8: member1 (InBase) : [#int#][#Base2::#]member1
203 // CHECK-CC8: member2 (InBase) : [#float#][#Base1::#]member2
204 // CHECK-CC8: member3 (InBase) : [#double#][#Base2::#]member3
205 // CHECK-CC8: member4 : [#int#]member4
206 // CHECK-CC8: member5 : [#int#]member5 (requires fix-it: {192:4-192:6} to ".")
207 // CHECK-CC8: memfun1 (InBase) : [#void#][#Base3::#]memfun1(<#float#>)
208 // CHECK-CC8: memfun1 (InBase) : [#void#][#Base3::#]memfun1(<#double#>)[# const#]
209 // CHECK-CC8: memfun1 (Hidden,InBase) : [#void#]Base2::memfun1(<#int#>)
210 // CHECK-CC8: memfun2 (InBase) : [#void#][#Base3::#]memfun2(<#int#>)
211 // CHECK-CC8: memfun3 : [#int#]memfun3(<#int#>)
212 // CHECK-CC8: operator-> : [#Derived *#]operator->()[# const#] (requires fix-it: {192:4-192:6} to ".")
214 // RUN: %clang_cc1 -fsyntax-only -code-completion-with-fixits -code-completion-at=%s:196:6 %s -o - | FileCheck -check-prefix=CHECK-CC9 --implicit-check-not="Derived : Derived(" %s
215 // CHECK-CC9: Base1 (InBase) : Base1::
216 // CHECK-CC9: member1 (InBase) : [#int#][#Base1::#]member1 (requires fix-it: {196:4-196:5} to "->")
217 // CHECK-CC9: member1 (InBase) : [#int#][#Base2::#]member1 (requires fix-it: {196:4-196:5} to "->")
218 // CHECK-CC9: member2 (InBase) : [#float#][#Base1::#]member2 (requires fix-it: {196:4-196:5} to "->")
219 // CHECK-CC9: member3 (InBase) : [#double#][#Base2::#]member3 (requires fix-it: {196:4-196:5} to "->")
220 // CHECK-CC9: member4 : [#int#]member4 (requires fix-it: {196:4-196:5} to "->")
221 // CHECK-CC9: member5 : [#int#]member5
222 // CHECK-CC9: memfun1 (InBase) : [#void#][#Base3::#]memfun1(<#float#>) (requires fix-it: {196:4-196:5} to "->")
223 // CHECK-CC9: memfun1 (InBase) : [#void#][#Base3::#]memfun1(<#double#>)[# const#] (requires fix-it: {196:4-196:5} to "->")
224 // CHECK-CC9: memfun1 (Hidden,InBase) : [#void#]Base2::memfun1(<#int#>) (requires fix-it: {196:4-196:5} to "->")
225 // CHECK-CC9: memfun2 (InBase) : [#void#][#Base3::#]memfun2(<#int#>) (requires fix-it: {196:4-196:5} to "->")
226 // CHECK-CC9: memfun3 : [#int#]memfun3(<#int#>) (requires fix-it: {196:4-196:5} to "->")
227 // CHECK-CC9: operator-> : [#Derived *#]operator->()[# const#]
229 // These overload sets differ only by return type and this-qualifiers.
230 // So for any given callsite, only one is available.
232 double ConstOverload(char);
233 int ConstOverload(char) const;
235 int RefOverload(char) &;
236 double RefOverload(char) const&;
237 char RefOverload(char) &&;
239 void testLValue(Overloads
& Ref
) {
242 void testConstLValue(const Overloads
& ConstRef
) {
248 void testXValue(Overloads
& X
) {
249 static_cast<Overloads
&&>(X
).
252 // RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:240:7 %s -o - | FileCheck -check-prefix=CHECK-LVALUE %s \
253 // RUN: --implicit-check-not="[#int#]ConstOverload(" \
254 // RUN: --implicit-check-not="[#double#]RefOverload(" \
255 // RUN: --implicit-check-not="[#char#]RefOverload("
256 // CHECK-LVALUE-DAG: [#double#]ConstOverload(
257 // CHECK-LVALUE-DAG: [#int#]RefOverload(
259 // RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:243:12 %s -o - | FileCheck -check-prefix=CHECK-CONSTLVALUE %s \
260 // RUN: --implicit-check-not="[#double#]ConstOverload(" \
261 // RUN: --implicit-check-not="[#int#]RefOverload(" \
262 // RUN: --implicit-check-not="[#char#]RefOverload("
263 // CHECK-CONSTLVALUE: [#int#]ConstOverload(
264 // CHECK-CONSTLVALUE: [#double#]RefOverload(
266 // RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:246:15 %s -o - | FileCheck -check-prefix=CHECK-PRVALUE %s \
267 // RUN: --implicit-check-not="[#int#]ConstOverload(" \
268 // RUN: --implicit-check-not="[#int#]RefOverload(" \
269 // RUN: --implicit-check-not="[#double#]RefOverload("
270 // CHECK-PRVALUE: [#double#]ConstOverload(
271 // CHECK-PRVALUE: [#char#]RefOverload(
273 // RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:249:31 %s -o - | FileCheck -check-prefix=CHECK-XVALUE %s \
274 // RUN: --implicit-check-not="[#int#]ConstOverload(" \
275 // RUN: --implicit-check-not="[#int#]RefOverload(" \
276 // RUN: --implicit-check-not="[#double#]RefOverload("
277 // CHECK-XVALUE: [#double#]ConstOverload(
278 // CHECK-XVALUE: [#char#]RefOverload(
280 void testOverloadOperator() {
282 char operator=(int) const;
287 // RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:285:12 %s -o - | FileCheck -check-prefix=CHECK-OPER %s \
288 // RUN: --implicit-check-not="[#char#]operator=("
289 // CHECK-OPER: [#int#]operator=(
291 struct S
{ int member
; };
293 S
overloaded(double);
295 // No overload matches, but we have recovery-expr with the correct type.
298 // RUN: not %clang_cc1 -fsyntax-only -frecovery-ast -frecovery-ast-type -code-completion-at=%s:296:16 %s -o - | FileCheck -check-prefix=CHECK-RECOVERY %s
299 // CHECK-RECOVERY: [#int#]member
300 template <typename T
>
301 void fooDependent(T t
) {
302 // Overload not resolved, but we notice all candidates return the same type.
305 // RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:303:17 %s -o - | FileCheck -check-prefix=CHECK-OVERLOAD %s
306 // CHECK-OVERLOAD: [#int#]member
312 template <typename T
>
313 struct Derived2
: Base4
{};
315 template <typename T
>
316 void testMembersFromBasesInDependentContext() {
318 (void)X
.base4().base4();
319 // RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:318:19 %s -o - | FileCheck -check-prefix=CHECK-MEMBERS-FROM-BASE-DEPENDENT %s
320 // CHECK-MEMBERS-FROM-BASE-DEPENDENT: [#Base4#]base4
323 namespace members_using_fixits
{
332 void testMethod(Baz
* ptr
) {
335 // RUN: %clang_cc1 -fsyntax-only -code-completion-with-fixits -code-completion-at=%s:333:10 %s -o - | FileCheck -check-prefix=CHECK-METHOD-DECLARED-VIA-USING %s
336 // CHECK-METHOD-DECLARED-VIA-USING: [#void#]method() (requires fix-it: {333:8-333:9} to "->")
338 void testField(Baz
* ptr
) {
341 // RUN: %clang_cc1 -fsyntax-only -code-completion-with-fixits -code-completion-at=%s:339:10 %s -o - | FileCheck -check-prefix=CHECK-FIELD-DECLARED-VIA-USING %s
342 // CHECK-FIELD-DECLARED-VIA-USING: [#int#]field (requires fix-it: {339:8-339:9} to "->")