Douglas Gregor | 3ac7385 | 2009-11-09 16:04:45 +0000 | [diff] [blame] | 1 | // Code-completion through the C interface |
Douglas Gregor | ac06a7c | 2009-11-09 16:06:30 +0000 | [diff] [blame] | 2 | #include "nonexistent_header.h" |
Douglas Gregor | 3ac7385 | 2009-11-09 16:04:45 +0000 | [diff] [blame] | 3 | struct X { |
| 4 | int member; |
Douglas Gregor | ff4393c | 2009-11-09 21:35:27 +0000 | [diff] [blame] | 5 | |
| 6 | enum E { Val1 }; |
Douglas Gregor | 3ac7385 | 2009-11-09 16:04:45 +0000 | [diff] [blame] | 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 | }; |
Douglas Gregor | a5fb7c3 | 2010-08-16 23:05:20 +0000 | [diff] [blame] | 18 | struct W { }; |
Douglas Gregor | 3ac7385 | 2009-11-09 16:04:45 +0000 | [diff] [blame] | 19 | struct Z get_Z(); |
Douglas Gregor | a5fb7c3 | 2010-08-16 23:05:20 +0000 | [diff] [blame] | 20 | namespace N { } |
Douglas Gregor | 3ac7385 | 2009-11-09 16:04:45 +0000 | [diff] [blame] | 21 | void test_Z() { |
Douglas Gregor | ff4393c | 2009-11-09 21:35:27 +0000 | [diff] [blame] | 22 | // RUN: c-index-test -code-completion-at=%s:23:11 %s | FileCheck -check-prefix=CHECK-MEMBER %s |
Douglas Gregor | 3ac7385 | 2009-11-09 16:04:45 +0000 | [diff] [blame] | 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 | |
| 31 | void test_overloaded() { |
Douglas Gregor | ff4393c | 2009-11-09 21:35:27 +0000 | [diff] [blame] | 32 | // RUN: c-index-test -code-completion-at=%s:33:18 %s | FileCheck -check-prefix=CHECK-OVERLOAD %s |
Douglas Gregor | 3ac7385 | 2009-11-09 16:04:45 +0000 | [diff] [blame] | 33 | overloaded(Z(), 0); |
| 34 | } |
| 35 | |
Douglas Gregor | 9b30b26 | 2010-06-15 20:26:51 +0000 | [diff] [blame] | 36 | Z::operator int() const { |
| 37 | return 0; |
| 38 | } |
| 39 | |
Douglas Gregor | ff5ce6e | 2009-12-18 18:53:37 +0000 | [diff] [blame] | 40 | // CHECK-MEMBER: FieldDecl:{ResultType double}{TypedText member} |
Douglas Gregor | ff5ce6e | 2009-12-18 18:53:37 +0000 | [diff] [blame] | 41 | // CHECK-MEMBER: FieldDecl:{ResultType int}{Text X::}{TypedText member} |
| 42 | // CHECK-MEMBER: FieldDecl:{ResultType float}{Text Y::}{TypedText member} |
Douglas Gregor | e8d7beb | 2010-09-03 23:30:36 +0000 | [diff] [blame] | 43 | // CHECK-MEMBER: CXXMethod:{ResultType void}{Informative Y::}{TypedText memfunc}{LeftParen (}{Optional {Placeholder int i}}{RightParen )} |
| 44 | // CHECK-MEMBER: CXXConversion:{ResultType int}{TypedText operator int}{LeftParen (}{RightParen )}{Informative const} |
Chris Lattner | 0c42bb6 | 2010-09-05 00:17:29 +0000 | [diff] [blame^] | 45 | // 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 McCall | 7c2342d | 2010-03-10 11:27:22 +0000 | [diff] [blame] | 48 | // CHECK-MEMBER: EnumConstantDecl:{ResultType X::E}{Informative E::}{TypedText Val1} |
Douglas Gregor | 7628294 | 2009-12-11 17:31:05 +0000 | [diff] [blame] | 49 | // CHECK-MEMBER: StructDecl:{TypedText X}{Text ::} |
| 50 | // CHECK-MEMBER: StructDecl:{TypedText Y}{Text ::} |
| 51 | // CHECK-MEMBER: StructDecl:{TypedText Z}{Text ::} |
Douglas Gregor | e8d7beb | 2010-09-03 23:30:36 +0000 | [diff] [blame] | 52 | // 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 Gregor | 3ac7385 | 2009-11-09 16:04:45 +0000 | [diff] [blame] | 55 | |
John McCall | 7c2342d | 2010-03-10 11:27:22 +0000 | [diff] [blame] | 56 | // CHECK-OVERLOAD: NotImplemented:{ResultType int &}{Text overloaded}{LeftParen (}{Text Z z}{Comma , }{CurrentParameter int second}{RightParen )} |
Douglas Gregor | ff5ce6e | 2009-12-18 18:53:37 +0000 | [diff] [blame] | 57 | // CHECK-OVERLOAD: NotImplemented:{ResultType float &}{Text overloaded}{LeftParen (}{Text int i}{Comma , }{CurrentParameter long second}{RightParen )} |
| 58 | // CHECK-OVERLOAD: NotImplemented:{ResultType double &}{Text overloaded}{LeftParen (}{Text float f}{Comma , }{CurrentParameter int second}{RightParen )} |
Douglas Gregor | 9b30b26 | 2010-06-15 20:26:51 +0000 | [diff] [blame] | 59 | |
| 60 | // RUN: c-index-test -code-completion-at=%s:37:10 %s | FileCheck -check-prefix=CHECK-EXPR %s |
Douglas Gregor | d43dd83 | 2010-08-24 23:40:45 +0000 | [diff] [blame] | 61 | // CHECK-EXPR: NotImplemented:{TypedText int} (65) |
| 62 | // CHECK-EXPR: NotImplemented:{TypedText long} (65) |
Douglas Gregor | c7ed372 | 2010-08-25 22:15:42 +0000 | [diff] [blame] | 63 | // CHECK-EXPR: FieldDecl:{ResultType double}{TypedText member} (10) |
Douglas Gregor | 9214819 | 2010-08-26 00:30:24 +0000 | [diff] [blame] | 64 | // CHECK-EXPR: FieldDecl:{ResultType int}{Text X::}{TypedText member} (5) |
Douglas Gregor | 9b30b26 | 2010-06-15 20:26:51 +0000 | [diff] [blame] | 65 | // CHECK-EXPR: FieldDecl:{ResultType float}{Text Y::}{TypedText member} (11) |
Douglas Gregor | e8d7beb | 2010-09-03 23:30:36 +0000 | [diff] [blame] | 66 | // CHECK-EXPR: CXXMethod:{ResultType void}{TypedText memfunc}{LeftParen (}{Optional {Placeholder int i}}{RightParen )} (22) |
| 67 | // CHECK-EXPR: Namespace:{TypedText N}{Text ::} (75) |