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 }; 188b14f8fdSDouglas Gregor 198b14f8fdSDouglas Gregor struct Z get_Z(); 208b14f8fdSDouglas Gregor 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 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 36*9858ed5bSDouglas Gregor Z::operator int() const { 37*9858ed5bSDouglas Gregor return 0; 38*9858ed5bSDouglas Gregor } 39*9858ed5bSDouglas Gregor 40b3fa919cSDouglas Gregor // CHECK-MEMBER: FieldDecl:{ResultType double}{TypedText member} 41b3fa919cSDouglas Gregor // CHECK-MEMBER: FieldDecl:{ResultType int}{Text X::}{TypedText member} 42b3fa919cSDouglas Gregor // CHECK-MEMBER: FieldDecl:{ResultType float}{Text Y::}{TypedText member} 4352ce62f0SDouglas Gregor // CHECK-MEMBER: FunctionDecl:{ResultType void}{Informative Y::}{TypedText memfunc}{LeftParen (}{Optional {Placeholder int i}}{RightParen )} 4452ce62f0SDouglas Gregor // CHECK-MEMBER: FunctionDecl:{ResultType int}{TypedText operator int}{LeftParen (}{RightParen )}{Informative const} 4585f90559SJohn McCall // CHECK-MEMBER: FunctionDecl:{ResultType Z &}{TypedText operator=}{LeftParen (}{Placeholder Z const &}{RightParen )} 4685f90559SJohn McCall // CHECK-MEMBER: FunctionDecl:{ResultType X &}{Text X::}{TypedText operator=}{LeftParen (}{Placeholder X const &}{RightParen )} 4785f90559SJohn McCall // CHECK-MEMBER: FunctionDecl:{ResultType Y &}{Text Y::}{TypedText operator=}{LeftParen (}{Placeholder Y const &}{RightParen )} 4885f90559SJohn McCall // CHECK-MEMBER: EnumConstantDecl:{ResultType X::E}{Informative E::}{TypedText Val1} 4999fe2ad8SDouglas Gregor // CHECK-MEMBER: StructDecl:{TypedText X}{Text ::} 5099fe2ad8SDouglas Gregor // CHECK-MEMBER: StructDecl:{TypedText Y}{Text ::} 5199fe2ad8SDouglas Gregor // CHECK-MEMBER: StructDecl:{TypedText Z}{Text ::} 5252ce62f0SDouglas Gregor // CHECK-MEMBER: FunctionDecl:{ResultType void}{Informative X::}{TypedText ~X}{LeftParen (}{RightParen )} 5352ce62f0SDouglas Gregor // CHECK-MEMBER: FunctionDecl:{ResultType void}{Informative Y::}{TypedText ~Y}{LeftParen (}{RightParen )} 5452ce62f0SDouglas Gregor // CHECK-MEMBER: FunctionDecl:{ResultType void}{TypedText ~Z}{LeftParen (}{RightParen )} 558b14f8fdSDouglas Gregor 5685f90559SJohn McCall // CHECK-OVERLOAD: NotImplemented:{ResultType int &}{Text overloaded}{LeftParen (}{Text Z z}{Comma , }{CurrentParameter int second}{RightParen )} 57b3fa919cSDouglas Gregor // CHECK-OVERLOAD: NotImplemented:{ResultType float &}{Text overloaded}{LeftParen (}{Text int i}{Comma , }{CurrentParameter long second}{RightParen )} 58b3fa919cSDouglas Gregor // CHECK-OVERLOAD: NotImplemented:{ResultType double &}{Text overloaded}{LeftParen (}{Text float f}{Comma , }{CurrentParameter int second}{RightParen )} 59*9858ed5bSDouglas Gregor 60*9858ed5bSDouglas Gregor // RUN: c-index-test -code-completion-at=%s:37:10 %s | FileCheck -check-prefix=CHECK-EXPR %s 61*9858ed5bSDouglas Gregor // CHECK-EXPR: NotImplemented:{TypedText int} (40) 62*9858ed5bSDouglas Gregor // CHECK-EXPR: NotImplemented:{TypedText long} (40) 63*9858ed5bSDouglas Gregor // CHECK-EXPR: FieldDecl:{ResultType double}{TypedText member} (10) 64*9858ed5bSDouglas Gregor // CHECK-EXPR: FieldDecl:{ResultType int}{Text X::}{TypedText member} (5) 65*9858ed5bSDouglas Gregor // CHECK-EXPR: FieldDecl:{ResultType float}{Text Y::}{TypedText member} (11) 66*9858ed5bSDouglas Gregor // CHECK-EXPR: FunctionDecl:{ResultType void}{TypedText memfunc}{LeftParen (}{Optional {Placeholder int i}}{RightParen )} (22) 67*9858ed5bSDouglas Gregor 68