1 // Code-completion through the C interface
2 #include "nonexistent_header.h"
3 struct X {
4 int member;
5
6 enum E { Val1 };
7 };
8
9 struct Y {
10 float member;
11 void memfunc(int i = 17);
12 };
13
14 struct Z : X, Y {
15 double member;
16 operator int() const;
17 };
18 struct W { };
19 struct Z get_Z();
20 namespace N { }
test_Z()21 void test_Z() {
22 // RUN: c-index-test -code-completion-at=%s:23:11 %s | FileCheck -check-prefix=CHECK-MEMBER %s
23 get_Z().member = 17;
24 }
25
26
27 float& overloaded(int i, long second);
28 double& overloaded(float f, int second);
29 int& overloaded(Z z, int second);
30
test_overloaded()31 void test_overloaded() {
32 // RUN: c-index-test -code-completion-at=%s:33:18 %s | FileCheck -check-prefix=CHECK-OVERLOAD %s
33 overloaded(Z(), 0);
34 }
35
operator int() const36 Z::operator int() const {
37 return 0;
38 }
39
40 template <typename T>
41 struct Foo { T member; };
42
43 template<typename T> using Bar = Foo<T>;
44
test_template_alias()45 void test_template_alias() {
46 // RUN: env CINDEXTEST_COMPLETION_CACHING=1 c-index-test -code-completion-at=%s:47:1 %s | FileCheck -check-prefix=CHECK-TEMPLATE-ALIAS %s
47
48 }
49
50 // CHECK-MEMBER: FieldDecl:{ResultType double}{TypedText member}
51 // CHECK-MEMBER: FieldDecl:{ResultType int}{Text X::}{TypedText member}
52 // CHECK-MEMBER: FieldDecl:{ResultType float}{Text Y::}{TypedText member}
53 // CHECK-MEMBER: CXXMethod:{ResultType void}{Informative Y::}{TypedText memfunc}{LeftParen (}{Optional {Placeholder int i = 17}}{RightParen )}
54 // CHECK-MEMBER: CXXConversion:{TypedText operator int}{LeftParen (}{RightParen )}{Informative const}
55 // CHECK-MEMBER: CXXMethod:{ResultType Z &}{TypedText operator=}{LeftParen (}{Placeholder const Z &}{RightParen )}
56 // CHECK-MEMBER: CXXMethod:{ResultType X &}{Text X::}{TypedText operator=}{LeftParen (}{Placeholder const X &}{RightParen )}
57 // CHECK-MEMBER: CXXMethod:{ResultType Y &}{Text Y::}{TypedText operator=}{LeftParen (}{Placeholder const Y &}{RightParen )}
58 // CHECK-MEMBER: EnumConstantDecl:{ResultType X::E}{Informative E::}{TypedText Val1}
59 // CHECK-MEMBER: StructDecl:{TypedText X}{Text ::}
60 // CHECK-MEMBER: StructDecl:{TypedText Y}{Text ::}
61 // CHECK-MEMBER: StructDecl:{TypedText Z}{Text ::}
62 // CHECK-MEMBER: CXXDestructor:{ResultType void}{Informative X::}{TypedText ~X}{LeftParen (}{RightParen )}
63 // CHECK-MEMBER: CXXDestructor:{ResultType void}{Informative Y::}{TypedText ~Y}{LeftParen (}{RightParen )}
64 // CHECK-MEMBER: CXXDestructor:{ResultType void}{TypedText ~Z}{LeftParen (}{RightParen )}
65 // CHECK-MEMBER: Completion contexts:
66 // CHECK-MEMBER-NEXT: Dot member access
67 // CHECK-MEMBER-NEXT: Container Kind: StructDecl
68 // CHECK-MEMBER-NEXT: Container is complete
69 // CHECK-MEMBER-NEXT: Container USR: c:@S@Z
70
71 // CHECK-OVERLOAD: OverloadCandidate:{ResultType int &}{Text overloaded}{LeftParen (}{Placeholder Z z}{Comma , }{CurrentParameter int second}{RightParen )}
72 // CHECK-OVERLOAD: OverloadCandidate:{ResultType float &}{Text overloaded}{LeftParen (}{Placeholder int i}{Comma , }{CurrentParameter long second}{RightParen )}
73 // CHECK-OVERLOAD: OverloadCandidate:{ResultType double &}{Text overloaded}{LeftParen (}{Placeholder float f}{Comma , }{CurrentParameter int second}{RightParen )}
74 // CHECK-OVERLOAD: Completion contexts:
75 // CHECK-OVERLOAD-NEXT: Any type
76 // CHECK-OVERLOAD-NEXT: Any value
77 // CHECK-OVERLOAD-NEXT: Enum tag
78 // CHECK-OVERLOAD-NEXT: Union tag
79 // CHECK-OVERLOAD-NEXT: Struct tag
80 // CHECK-OVERLOAD-NEXT: Class name
81 // CHECK-OVERLOAD-NEXT: Nested name specifier
82 // CHECK-OVERLOAD-NEXT: Objective-C interface
83
84 // RUN: c-index-test -code-completion-at=%s:37:10 %s | FileCheck -check-prefix=CHECK-EXPR %s
85 // CHECK-EXPR: NotImplemented:{TypedText int} (50)
86 // CHECK-EXPR: NotImplemented:{TypedText long} (50)
87 // CHECK-EXPR: FieldDecl:{ResultType double}{TypedText member} (17)
88 // CHECK-EXPR: FieldDecl:{ResultType int}{Text X::}{TypedText member} (9)
89 // CHECK-EXPR: FieldDecl:{ResultType float}{Text Y::}{TypedText member} (18)
90 // CHECK-EXPR: CXXMethod:{ResultType void}{TypedText memfunc}{LeftParen (}{Optional {Placeholder int i = 17}}{RightParen )} (37)
91 // CHECK-EXPR: Namespace:{TypedText N}{Text ::} (75)
92 // CHECK-EXPR: Completion contexts:
93 // CHECK-EXPR-NEXT: Any type
94 // CHECK-EXPR-NEXT: Any value
95 // CHECK-EXPR-NEXT: Enum tag
96 // CHECK-EXPR-NEXT: Union tag
97 // CHECK-EXPR-NEXT: Struct tag
98 // CHECK-EXPR-NEXT: Class name
99 // CHECK-EXPR-NEXT: Nested name specifier
100 // CHECK-EXPR-NEXT: Objective-C interface
101
102 // CHECK-TEMPLATE-ALIAS: AliasTemplateDecl:{TypedText Bar}{LeftAngle <}{Placeholder typename T}{RightAngle >} (50)
103