18b14f8fdSDouglas Gregor // Code-completion through the C interface
2022d3c2fSDouglas Gregor #include "nonexistent_header.h"
38b14f8fdSDouglas Gregor struct X {
48b14f8fdSDouglas Gregor int member;
58caea94cSDouglas Gregor
68caea94cSDouglas Gregor enum E { Val1 };
78b14f8fdSDouglas Gregor };
88b14f8fdSDouglas Gregor
98b14f8fdSDouglas Gregor struct Y {
108b14f8fdSDouglas Gregor float member;
118b14f8fdSDouglas Gregor void memfunc(int i = 17);
128b14f8fdSDouglas Gregor };
138b14f8fdSDouglas Gregor
148b14f8fdSDouglas Gregor struct Z : X, Y {
158b14f8fdSDouglas Gregor double member;
168b14f8fdSDouglas Gregor operator int() const;
178b14f8fdSDouglas Gregor };
1859cab556SDouglas Gregor struct W { };
198b14f8fdSDouglas Gregor struct Z get_Z();
2059cab556SDouglas Gregor namespace N { }
test_Z()218b14f8fdSDouglas Gregor void test_Z() {
228caea94cSDouglas Gregor // RUN: c-index-test -code-completion-at=%s:23:11 %s | FileCheck -check-prefix=CHECK-MEMBER %s
238b14f8fdSDouglas Gregor get_Z().member = 17;
248b14f8fdSDouglas Gregor }
258b14f8fdSDouglas Gregor
268b14f8fdSDouglas Gregor
278b14f8fdSDouglas Gregor float& overloaded(int i, long second);
288b14f8fdSDouglas Gregor double& overloaded(float f, int second);
298b14f8fdSDouglas Gregor int& overloaded(Z z, int second);
308b14f8fdSDouglas Gregor
test_overloaded()318b14f8fdSDouglas Gregor void test_overloaded() {
328caea94cSDouglas Gregor // RUN: c-index-test -code-completion-at=%s:33:18 %s | FileCheck -check-prefix=CHECK-OVERLOAD %s
338b14f8fdSDouglas Gregor overloaded(Z(), 0);
348b14f8fdSDouglas Gregor }
358b14f8fdSDouglas Gregor
operator int() const369858ed5bSDouglas Gregor Z::operator int() const {
379858ed5bSDouglas Gregor return 0;
389858ed5bSDouglas Gregor }
399858ed5bSDouglas Gregor
40*51ee12a9SErik Verbruggen template <typename T>
41*51ee12a9SErik Verbruggen struct Foo { T member; };
42*51ee12a9SErik Verbruggen
43*51ee12a9SErik Verbruggen template<typename T> using Bar = Foo<T>;
44*51ee12a9SErik Verbruggen
test_template_alias()45*51ee12a9SErik Verbruggen void test_template_alias() {
46*51ee12a9SErik Verbruggen // RUN: env CINDEXTEST_COMPLETION_CACHING=1 c-index-test -code-completion-at=%s:47:1 %s | FileCheck -check-prefix=CHECK-TEMPLATE-ALIAS %s
47*51ee12a9SErik Verbruggen
48*51ee12a9SErik Verbruggen }
49*51ee12a9SErik Verbruggen
50b3fa919cSDouglas Gregor // CHECK-MEMBER: FieldDecl:{ResultType double}{TypedText member}
51b3fa919cSDouglas Gregor // CHECK-MEMBER: FieldDecl:{ResultType int}{Text X::}{TypedText member}
52b3fa919cSDouglas Gregor // CHECK-MEMBER: FieldDecl:{ResultType float}{Text Y::}{TypedText member}
5311338c59SErik Verbruggen // CHECK-MEMBER: CXXMethod:{ResultType void}{Informative Y::}{TypedText memfunc}{LeftParen (}{Optional {Placeholder int i = 17}}{RightParen )}
540212fd71SDouglas Gregor // CHECK-MEMBER: CXXConversion:{TypedText operator int}{LeftParen (}{RightParen )}{Informative const}
5524b89469SChris Lattner // CHECK-MEMBER: CXXMethod:{ResultType Z &}{TypedText operator=}{LeftParen (}{Placeholder const Z &}{RightParen )}
5624b89469SChris Lattner // CHECK-MEMBER: CXXMethod:{ResultType X &}{Text X::}{TypedText operator=}{LeftParen (}{Placeholder const X &}{RightParen )}
5724b89469SChris Lattner // CHECK-MEMBER: CXXMethod:{ResultType Y &}{Text Y::}{TypedText operator=}{LeftParen (}{Placeholder const Y &}{RightParen )}
5885f90559SJohn McCall // CHECK-MEMBER: EnumConstantDecl:{ResultType X::E}{Informative E::}{TypedText Val1}
5999fe2ad8SDouglas Gregor // CHECK-MEMBER: StructDecl:{TypedText X}{Text ::}
6099fe2ad8SDouglas Gregor // CHECK-MEMBER: StructDecl:{TypedText Y}{Text ::}
6199fe2ad8SDouglas Gregor // CHECK-MEMBER: StructDecl:{TypedText Z}{Text ::}
6209c0eb15SDouglas Gregor // CHECK-MEMBER: CXXDestructor:{ResultType void}{Informative X::}{TypedText ~X}{LeftParen (}{RightParen )}
6309c0eb15SDouglas Gregor // CHECK-MEMBER: CXXDestructor:{ResultType void}{Informative Y::}{TypedText ~Y}{LeftParen (}{RightParen )}
6409c0eb15SDouglas Gregor // CHECK-MEMBER: CXXDestructor:{ResultType void}{TypedText ~Z}{LeftParen (}{RightParen )}
652132584dSDouglas Gregor // CHECK-MEMBER: Completion contexts:
662132584dSDouglas Gregor // CHECK-MEMBER-NEXT: Dot member access
6763745d59SDouglas Gregor // CHECK-MEMBER-NEXT: Container Kind: StructDecl
6863745d59SDouglas Gregor // CHECK-MEMBER-NEXT: Container is complete
6963745d59SDouglas Gregor // CHECK-MEMBER-NEXT: Container USR: c:@S@Z
708b14f8fdSDouglas Gregor
710c010cddSFrancisco Lopes da Silva // CHECK-OVERLOAD: OverloadCandidate:{ResultType int &}{Text overloaded}{LeftParen (}{Placeholder Z z}{Comma , }{CurrentParameter int second}{RightParen )}
720c010cddSFrancisco Lopes da Silva // CHECK-OVERLOAD: OverloadCandidate:{ResultType float &}{Text overloaded}{LeftParen (}{Placeholder int i}{Comma , }{CurrentParameter long second}{RightParen )}
730c010cddSFrancisco Lopes da Silva // CHECK-OVERLOAD: OverloadCandidate:{ResultType double &}{Text overloaded}{LeftParen (}{Placeholder float f}{Comma , }{CurrentParameter int second}{RightParen )}
742132584dSDouglas Gregor // CHECK-OVERLOAD: Completion contexts:
752132584dSDouglas Gregor // CHECK-OVERLOAD-NEXT: Any type
762132584dSDouglas Gregor // CHECK-OVERLOAD-NEXT: Any value
772132584dSDouglas Gregor // CHECK-OVERLOAD-NEXT: Enum tag
782132584dSDouglas Gregor // CHECK-OVERLOAD-NEXT: Union tag
792132584dSDouglas Gregor // CHECK-OVERLOAD-NEXT: Struct tag
802132584dSDouglas Gregor // CHECK-OVERLOAD-NEXT: Class name
812132584dSDouglas Gregor // CHECK-OVERLOAD-NEXT: Nested name specifier
822132584dSDouglas Gregor // CHECK-OVERLOAD-NEXT: Objective-C interface
839858ed5bSDouglas Gregor
849858ed5bSDouglas Gregor // RUN: c-index-test -code-completion-at=%s:37:10 %s | FileCheck -check-prefix=CHECK-EXPR %s
855fb901deSDouglas Gregor // CHECK-EXPR: NotImplemented:{TypedText int} (50)
865fb901deSDouglas Gregor // CHECK-EXPR: NotImplemented:{TypedText long} (50)
870787b322SDouglas Gregor // CHECK-EXPR: FieldDecl:{ResultType double}{TypedText member} (17)
880787b322SDouglas Gregor // CHECK-EXPR: FieldDecl:{ResultType int}{Text X::}{TypedText member} (9)
890787b322SDouglas Gregor // CHECK-EXPR: FieldDecl:{ResultType float}{Text Y::}{TypedText member} (18)
9011338c59SErik Verbruggen // CHECK-EXPR: CXXMethod:{ResultType void}{TypedText memfunc}{LeftParen (}{Optional {Placeholder int i = 17}}{RightParen )} (37)
9109c0eb15SDouglas Gregor // CHECK-EXPR: Namespace:{TypedText N}{Text ::} (75)
922132584dSDouglas Gregor // CHECK-EXPR: Completion contexts:
932132584dSDouglas Gregor // CHECK-EXPR-NEXT: Any type
942132584dSDouglas Gregor // CHECK-EXPR-NEXT: Any value
952132584dSDouglas Gregor // CHECK-EXPR-NEXT: Enum tag
962132584dSDouglas Gregor // CHECK-EXPR-NEXT: Union tag
972132584dSDouglas Gregor // CHECK-EXPR-NEXT: Struct tag
982132584dSDouglas Gregor // CHECK-EXPR-NEXT: Class name
992132584dSDouglas Gregor // CHECK-EXPR-NEXT: Nested name specifier
1002132584dSDouglas Gregor // CHECK-EXPR-NEXT: Objective-C interface
101*51ee12a9SErik Verbruggen
102*51ee12a9SErik Verbruggen // CHECK-TEMPLATE-ALIAS: AliasTemplateDecl:{TypedText Bar}{LeftAngle <}{Placeholder typename T}{RightAngle >} (50)
103