blob: 5789d3b9fa07e3a7e251d1fc75ebc8ae557469ae [file] [log] [blame]
Douglas Gregor3ac73852009-11-09 16:04:45 +00001// Code-completion through the C interface
Douglas Gregorac06a7c2009-11-09 16:06:30 +00002#include "nonexistent_header.h"
Douglas Gregor3ac73852009-11-09 16:04:45 +00003struct X {
4 int member;
Douglas Gregorff4393c2009-11-09 21:35:27 +00005
6 enum E { Val1 };
Douglas Gregor3ac73852009-11-09 16:04:45 +00007};
8
9struct Y {
10 float member;
11 void memfunc(int i = 17);
12};
13
14struct Z : X, Y {
15 double member;
16 operator int() const;
17};
Douglas Gregora5fb7c32010-08-16 23:05:20 +000018struct W { };
Douglas Gregor3ac73852009-11-09 16:04:45 +000019struct Z get_Z();
Douglas Gregora5fb7c32010-08-16 23:05:20 +000020namespace N { }
Douglas Gregor3ac73852009-11-09 16:04:45 +000021void test_Z() {
Douglas Gregorff4393c2009-11-09 21:35:27 +000022 // RUN: c-index-test -code-completion-at=%s:23:11 %s | FileCheck -check-prefix=CHECK-MEMBER %s
Douglas Gregor3ac73852009-11-09 16:04:45 +000023 get_Z().member = 17;
24}
25
26
27float& overloaded(int i, long second);
28double& overloaded(float f, int second);
29int& overloaded(Z z, int second);
30
31void test_overloaded() {
Douglas Gregorff4393c2009-11-09 21:35:27 +000032 // RUN: c-index-test -code-completion-at=%s:33:18 %s | FileCheck -check-prefix=CHECK-OVERLOAD %s
Douglas Gregor3ac73852009-11-09 16:04:45 +000033 overloaded(Z(), 0);
34}
35
Douglas Gregor9b30b262010-06-15 20:26:51 +000036Z::operator int() const {
37 return 0;
38}
39
Douglas Gregorff5ce6e2009-12-18 18:53:37 +000040// CHECK-MEMBER: FieldDecl:{ResultType double}{TypedText member}
Douglas Gregorff5ce6e2009-12-18 18:53:37 +000041// CHECK-MEMBER: FieldDecl:{ResultType int}{Text X::}{TypedText member}
42// CHECK-MEMBER: FieldDecl:{ResultType float}{Text Y::}{TypedText member}
Douglas Gregore8d7beb2010-09-03 23:30:36 +000043// CHECK-MEMBER: CXXMethod:{ResultType void}{Informative Y::}{TypedText memfunc}{LeftParen (}{Optional {Placeholder int i}}{RightParen )}
Douglas Gregor6f942b22010-09-21 16:06:22 +000044// CHECK-MEMBER: CXXConversion:{TypedText operator int}{LeftParen (}{RightParen )}{Informative const}
Chris Lattner0c42bb62010-09-05 00:17:29 +000045// CHECK-MEMBER: CXXMethod:{ResultType Z &}{TypedText operator=}{LeftParen (}{Placeholder const Z &}{RightParen )}
46// CHECK-MEMBER: CXXMethod:{ResultType X &}{Text X::}{TypedText operator=}{LeftParen (}{Placeholder const X &}{RightParen )}
47// CHECK-MEMBER: CXXMethod:{ResultType Y &}{Text Y::}{TypedText operator=}{LeftParen (}{Placeholder const Y &}{RightParen )}
John McCall7c2342d2010-03-10 11:27:22 +000048// CHECK-MEMBER: EnumConstantDecl:{ResultType X::E}{Informative E::}{TypedText Val1}
Douglas Gregor76282942009-12-11 17:31:05 +000049// CHECK-MEMBER: StructDecl:{TypedText X}{Text ::}
50// CHECK-MEMBER: StructDecl:{TypedText Y}{Text ::}
51// CHECK-MEMBER: StructDecl:{TypedText Z}{Text ::}
Douglas Gregore8d7beb2010-09-03 23:30:36 +000052// CHECK-MEMBER: CXXDestructor:{ResultType void}{Informative X::}{TypedText ~X}{LeftParen (}{RightParen )}
53// CHECK-MEMBER: CXXDestructor:{ResultType void}{Informative Y::}{TypedText ~Y}{LeftParen (}{RightParen )}
54// CHECK-MEMBER: CXXDestructor:{ResultType void}{TypedText ~Z}{LeftParen (}{RightParen )}
Douglas Gregor3da626b2011-07-07 16:03:39 +000055// CHECK-MEMBER: Completion contexts:
56// CHECK-MEMBER-NEXT: Dot member access
Douglas Gregore081a612011-07-21 01:05:26 +000057// CHECK-MEMBER-NEXT: Container Kind: StructDecl
58// CHECK-MEMBER-NEXT: Container is complete
59// CHECK-MEMBER-NEXT: Container USR: c:@S@Z
Douglas Gregor3ac73852009-11-09 16:04:45 +000060
John McCall7c2342d2010-03-10 11:27:22 +000061// CHECK-OVERLOAD: NotImplemented:{ResultType int &}{Text overloaded}{LeftParen (}{Text Z z}{Comma , }{CurrentParameter int second}{RightParen )}
Douglas Gregorff5ce6e2009-12-18 18:53:37 +000062// CHECK-OVERLOAD: NotImplemented:{ResultType float &}{Text overloaded}{LeftParen (}{Text int i}{Comma , }{CurrentParameter long second}{RightParen )}
63// CHECK-OVERLOAD: NotImplemented:{ResultType double &}{Text overloaded}{LeftParen (}{Text float f}{Comma , }{CurrentParameter int second}{RightParen )}
Douglas Gregor3da626b2011-07-07 16:03:39 +000064// CHECK-OVERLOAD: Completion contexts:
65// CHECK-OVERLOAD-NEXT: Any type
66// CHECK-OVERLOAD-NEXT: Any value
67// CHECK-OVERLOAD-NEXT: Enum tag
68// CHECK-OVERLOAD-NEXT: Union tag
69// CHECK-OVERLOAD-NEXT: Struct tag
70// CHECK-OVERLOAD-NEXT: Class name
71// CHECK-OVERLOAD-NEXT: Nested name specifier
72// CHECK-OVERLOAD-NEXT: Objective-C interface
Douglas Gregor9b30b262010-06-15 20:26:51 +000073
74// RUN: c-index-test -code-completion-at=%s:37:10 %s | FileCheck -check-prefix=CHECK-EXPR %s
Douglas Gregor08f43cd2010-09-20 23:11:55 +000075// CHECK-EXPR: NotImplemented:{TypedText int} (50)
76// CHECK-EXPR: NotImplemented:{TypedText long} (50)
Douglas Gregor8ec904c2010-10-19 00:03:23 +000077// CHECK-EXPR: FieldDecl:{ResultType double}{TypedText member} (17)
78// CHECK-EXPR: FieldDecl:{ResultType int}{Text X::}{TypedText member} (9)
79// CHECK-EXPR: FieldDecl:{ResultType float}{Text Y::}{TypedText member} (18)
80// CHECK-EXPR: CXXMethod:{ResultType void}{TypedText memfunc}{LeftParen (}{Optional {Placeholder int i}}{RightParen )} (37)
Douglas Gregore8d7beb2010-09-03 23:30:36 +000081// CHECK-EXPR: Namespace:{TypedText N}{Text ::} (75)
Douglas Gregor3da626b2011-07-07 16:03:39 +000082// CHECK-EXPR: Completion contexts:
83// CHECK-EXPR-NEXT: Any type
84// CHECK-EXPR-NEXT: Any value
85// CHECK-EXPR-NEXT: Enum tag
86// CHECK-EXPR-NEXT: Union tag
87// CHECK-EXPR-NEXT: Struct tag
88// CHECK-EXPR-NEXT: Class name
89// CHECK-EXPR-NEXT: Nested name specifier
90// CHECK-EXPR-NEXT: Objective-C interface