273 lines · plain
1/* Note: the RUN lines are near the end of the file, since line/column2 matter for this test. */3#define IBAction void4@protocol P15- (id)abc;6- (id)initWithInt:(int)x;7- (id)initWithTwoInts:(inout int)x second:(int)y;8- (int)getInt;9- (id)getSelf;10@end11@protocol P1;12@protocol P2<P1>13+ (id)alloc;14@end15 16@interface A <P1>17- (id)init;18- (int)getValue;19@end20 21@interface B : A<P2>22- (id)initWithInt:(int)x;23- (int)getSecondValue;24- (id)getSelf;25- (int)setValue:(int)x;26@end27 28@interface B (FooBar)29- (id)categoryFunction:(int)x;30@end31 32@implementation B33- (int)getSecondValue { return 0; }34- (id)init { return self; }35- (id)getSelf { return self; }36- (void)setValue:(int)x { }37- (id)initWithTwoInts:(int)x second:(int)y { return self; }38+ (id)alloc { return 0; }39@end40 41@implementation B (FooBar)42- (id)categoryFunction:(int)x { return self; }43@end44 45@interface C46- (int)first:(int)x second:(float)y third:(double)z;47- (id)first:(int)xx second2:(float)y2 third:(double)z;48- (void*)first:(int)xxx second3:(float)y3 third:(double)z;49@end50 51@interface D52- (int)first:(int)x second2:(float)y third:(double)z;53@end54 55@implementation D56- (int)first:(int)x second2:(float)y third:(double)z { }57@end58 59@interface Passing60- (oneway void)method:(in id)x;61@end62 63@interface Gaps64- (void)method:(int)x :(int)y;65@end66 67@implementation Gaps68- (void)method:(int)x :(int)y {}69@end70 71@implementation Passing72- (oneway void)method:(in id x) {}73@end74 75typedef A MyObject;76typedef A *MyObjectRef;77 78@interface I179-(Class<P1>)meth;80-(MyObject <P1> *)meth2;81-(MyObjectRef)meth3;82@end83 84@implementation I185-(void)foo {}86@end87 88@interface I289-(nonnull I2 *)produceI2:(nullable I2 *)i2;90-(int *__nullable *__nullable)something:(void(^__nullable)(int *__nullable))b;91@property (nullable, strong) id prop;92@property (nullable, strong) void(^propWB)(int *_Nullable);93@end94 95@implementation I296-(void)foo {}97@end98 99#pragma clang assume_nonnull begin100@interface I3101-(I3 *)produceI3:(I3 *)i3;102-(instancetype)getI3;103@end104#pragma clang assume_nonnull end105 106@implementation I3107-(void)foo {}108@end109 110// RUN: c-index-test -code-completion-at=%s:17:3 %s | FileCheck -check-prefix=CHECK-CC1 %s111// CHECK-CC1: ObjCInstanceMethodDecl:{LeftParen (}{Text id}{RightParen )}{TypedText abc} (40)112// CHECK-CC1: ObjCInstanceMethodDecl:{LeftParen (}{Text int}{RightParen )}{TypedText getInt} (40)113// CHECK-CC1: ObjCInstanceMethodDecl:{LeftParen (}{Text id}{RightParen )}{TypedText getSelf} (40)114// CHECK-CC1: ObjCInstanceMethodDecl:{LeftParen (}{Text id}{RightParen )}{TypedText initWithInt:}{LeftParen (}{Text int}{RightParen )}{Text x} (40)115// CHECK-CC1: ObjCInstanceMethodDecl:{LeftParen (}{Text id}{RightParen )}{TypedText initWithTwoInts:}{LeftParen (}{Text inout }{Text int}{RightParen )}{Text x}{HorizontalSpace }{TypedText second:}{LeftParen (}{Text int}{RightParen )}{Text y} (40)116// RUN: c-index-test -code-completion-at=%s:17:7 %s | FileCheck -check-prefix=CHECK-CC2 %s117// CHECK-CC2: ObjCInstanceMethodDecl:{TypedText abc}118// CHECK-CC2-NEXT: ObjCInstanceMethodDecl:{TypedText getSelf}119// CHECK-CC2: ObjCInstanceMethodDecl:{TypedText initWithInt:}{LeftParen (}{Text int}{RightParen )}{Text x}120// CHECK-CC2: ObjCInstanceMethodDecl:{TypedText initWithTwoInts:}{LeftParen (}{Text inout }{Text int}{RightParen )}{Text x}{HorizontalSpace }{TypedText second:}{LeftParen (}{Text int}{RightParen )}{Text y}121// RUN: c-index-test -code-completion-at=%s:24:7 %s | FileCheck -check-prefix=CHECK-CC3 %s122// CHECK-CC3: ObjCInstanceMethodDecl:{TypedText abc}123// CHECK-CC3-NEXT: ObjCInstanceMethodDecl:{TypedText getSelf}124// CHECK-CC3: ObjCInstanceMethodDecl:{TypedText init}125// CHECK-CC3: ObjCInstanceMethodDecl:{TypedText initWithInt:}{LeftParen (}{Text int}{RightParen )}{Text x}126// CHECK-CC3: ObjCInstanceMethodDecl:{TypedText initWithTwoInts:}{LeftParen (}{Text inout }{Text int}{RightParen )}{Text x}{HorizontalSpace }{TypedText second:}{LeftParen (}{Text int}{RightParen )}{Text y}127// RUN: env CINDEXTEST_CODE_COMPLETE_PATTERNS=1 c-index-test -code-completion-at=%s:33:3 %s | FileCheck -check-prefix=CHECK-CC4 %s128// CHECK-CC4: ObjCInstanceMethodDecl:{LeftParen (}{Text id}{RightParen )}{TypedText abc}{HorizontalSpace }{LeftBrace {}{VerticalSpace }{Text return}{HorizontalSpace }{Placeholder expression}{SemiColon ;}{VerticalSpace }{RightBrace }} (42)129// CHECK-CC4: ObjCInstanceMethodDecl:{LeftParen (}{Text int}{RightParen )}{TypedText getInt}{HorizontalSpace }{LeftBrace {}{VerticalSpace130// CHECK-CC4: ObjCInstanceMethodDecl:{LeftParen (}{Text int}{RightParen )}{TypedText getSecondValue}{HorizontalSpace }{LeftBrace {}{VerticalSpace131// CHECK-CC4: ObjCInstanceMethodDecl:{LeftParen (}{Text id}{RightParen )}{TypedText getSelf}{HorizontalSpace }{LeftBrace {}{VerticalSpace }{Text return}{HorizontalSpace }{Placeholder expression}{SemiColon ;}{VerticalSpace }{RightBrace }} (40)132// CHECK-CC4: ObjCInstanceMethodDecl:{LeftParen (}{Text id}{RightParen )}{TypedText initWithInt:}{LeftParen (}{Text int}{RightParen )}{Text x}{HorizontalSpace }{LeftBrace {}{VerticalSpace133// CHECK-CC4: ObjCInstanceMethodDecl:{LeftParen (}{Text id}{RightParen )}{TypedText initWithTwoInts:}{LeftParen (}{Text inout }{Text int}{RightParen )}{Text x}{HorizontalSpace }{TypedText second:}{LeftParen (}{Text int}{RightParen )}{Text y}{HorizontalSpace }{LeftBrace {}{VerticalSpace134// CHECK-CC4: ObjCInstanceMethodDecl:{LeftParen (}{Text int}{RightParen )}{TypedText setValue:}{LeftParen (}{Text int}{RightParen )}{Text x}{HorizontalSpace }{LeftBrace {}{VerticalSpace135// RUN: env CINDEXTEST_CODE_COMPLETE_PATTERNS=1 c-index-test -code-completion-at=%s:33:8 %s | FileCheck -check-prefix=CHECK-CC5 %s136// CHECK-CC5: ObjCInstanceMethodDecl:{TypedText getInt}{HorizontalSpace }{LeftBrace {}{VerticalSpace }{Text return}{HorizontalSpace }{Placeholder expression}{SemiColon ;}{VerticalSpace }{RightBrace }} (42)137// CHECK-CC5: ObjCInstanceMethodDecl:{TypedText getSecondValue}{HorizontalSpace }{LeftBrace {}{VerticalSpace }{Text return}{HorizontalSpace }{Placeholder expression}{SemiColon ;}{VerticalSpace }{RightBrace }} (40)138// CHECK-CC5-NOT: {TypedText getSelf}{HorizontalSpace }{LeftBrace {}{VerticalSpace139// CHECK-CC5: ObjCInstanceMethodDecl:{TypedText setValue:}{LeftParen (}{Text int}{RightParen )}{Text x}{HorizontalSpace }{LeftBrace {}{VerticalSpace140// RUN: env CINDEXTEST_CODE_COMPLETE_PATTERNS=1 c-index-test -code-completion-at=%s:37:7 %s | FileCheck -check-prefix=CHECK-CC6 %s141// CHECK-CC6: ObjCInstanceMethodDecl:{TypedText abc}{HorizontalSpace }{LeftBrace {}{VerticalSpace142// CHECK-CC6: ObjCInstanceMethodDecl:{TypedText getSelf}{HorizontalSpace }{LeftBrace {}{VerticalSpace }{Text return}{HorizontalSpace }{Placeholder expression}{SemiColon ;}{VerticalSpace }{RightBrace }} (40)143// CHECK-CC6: ObjCInstanceMethodDecl:{TypedText initWithInt:}{LeftParen (}{Text int}{RightParen )}{Text x}{HorizontalSpace }{LeftBrace {}{VerticalSpace144// CHECK-CC6: ObjCInstanceMethodDecl:{TypedText initWithTwoInts:}{LeftParen (}{Text inout }{Text int}{RightParen )}{Text x}{HorizontalSpace }{TypedText second:}{LeftParen (}{Text int}{RightParen )}{Text y}{HorizontalSpace }{LeftBrace {}{VerticalSpace145// RUN: env CINDEXTEST_CODE_COMPLETE_PATTERNS=1 c-index-test -code-completion-at=%s:42:3 %s | FileCheck -check-prefix=CHECK-CC7 %s146// CHECK-CC7: ObjCInstanceMethodDecl:{LeftParen (}{Text id}{RightParen )}{TypedText abc}{HorizontalSpace }{LeftBrace {}{VerticalSpace }{Text return}{HorizontalSpace }{Placeholder expression}{SemiColon ;}{VerticalSpace }{RightBrace }} (42)147// CHECK-CC7: ObjCInstanceMethodDecl:{LeftParen (}{Text id}{RightParen )}{TypedText categoryFunction:}{LeftParen (}{Text int}{RightParen )}{Text x}{HorizontalSpace }{LeftBrace {}{VerticalSpace148// CHECK-CC7: ObjCInstanceMethodDecl:{LeftParen (}{Text id}{RightParen )}{TypedText getSelf}{HorizontalSpace }{LeftBrace {}{VerticalSpace }{Text return}{HorizontalSpace }{Placeholder expression}{SemiColon ;}{VerticalSpace }{RightBrace }} (42)149// RUN: env CINDEXTEST_CODE_COMPLETE_PATTERNS=1 c-index-test -code-completion-at=%s:52:21 %s | FileCheck -check-prefix=CHECK-CC8 %s150// CHECK-CC8: ObjCInstanceMethodDecl:{ResultType id}{Informative first:}{TypedText second2:}{Text (float)y2}{HorizontalSpace }{TypedText third:}{Text (double)z} (35)151// CHECK-CC8: ObjCInstanceMethodDecl:{ResultType void *}{Informative first:}{TypedText second3:}{Text (float)y3}{HorizontalSpace }{TypedText third:}{Text (double)z} (35)152// CHECK-CC8: ObjCInstanceMethodDecl:{ResultType int}{Informative first:}{TypedText second:}{Text (float)y}{HorizontalSpace }{TypedText third:}{Text (double)z} (8)153// RUN: env CINDEXTEST_CODE_COMPLETE_PATTERNS=1 c-index-test -code-completion-at=%s:52:19 %s | FileCheck -check-prefix=CHECK-CC9 %s154// CHECK-CC9: NotImplemented:{TypedText x} (40)155// CHECK-CC9: NotImplemented:{TypedText xx} (40)156// CHECK-CC9: NotImplemented:{TypedText xxx} (40)157// RUN: env CINDEXTEST_CODE_COMPLETE_PATTERNS=1 c-index-test -code-completion-at=%s:52:36 %s | FileCheck -check-prefix=CHECK-CCA %s158// CHECK-CCA: NotImplemented:{TypedText y2} (40)159// RUN: c-index-test -code-completion-at=%s:56:3 %s | FileCheck -check-prefix=CHECK-CCB %s160// CHECK-CCB: ObjCInstanceMethodDecl:{LeftParen (}{Text int}{RightParen )}{TypedText first:}{LeftParen (}{Text int}{RightParen )}{Text x}{HorizontalSpace }{TypedText second2:}{LeftParen (}{Text float}{RightParen )}{Text y}{HorizontalSpace }{TypedText third:}{LeftParen (}{Text double}{RightParen )}{Text z} (40)161// RUN: c-index-test -code-completion-at=%s:56:8 %s | FileCheck -check-prefix=CHECK-CCC %s162// CHECK-CCC: ObjCInstanceMethodDecl:{TypedText first:}{LeftParen (}{Text int}{RightParen )}{Text x}{HorizontalSpace }{TypedText second2:}{LeftParen (}{Text float}{RightParen )}{Text y}{HorizontalSpace }{TypedText third:}{LeftParen (}{Text double}{RightParen )}{Text z} (40)163// RUN: c-index-test -code-completion-at=%s:56:21 %s | FileCheck -check-prefix=CHECK-CCD %s164// CHECK-CCD: ObjCInstanceMethodDecl:{ResultType id}{Informative first:}{TypedText second2:}{Text (float)y2}{HorizontalSpace }{TypedText third:}{Text (double)z} (35)165// CHECK-CCD: ObjCInstanceMethodDecl:{ResultType int}{Informative first:}{TypedText second2:}{Text (float)y}{HorizontalSpace }{TypedText third:}{Text (double)z} (8)166// CHECK-CCD: ObjCInstanceMethodDecl:{ResultType void *}{Informative first:}{TypedText second3:}{Text (float)y3}{HorizontalSpace }{TypedText third:}{Text (double)z} (35)167// CHECK-CCD: ObjCInstanceMethodDecl:{ResultType int}{Informative first:}{TypedText second:}{Text (float)y}{HorizontalSpace }{TypedText third:}{Text (double)z} (8)168// RUN: c-index-test -code-completion-at=%s:56:38 %s | FileCheck -check-prefix=CHECK-CCE %s169// CHECK-CCE: ObjCInstanceMethodDecl:{ResultType id}{Informative first:}{Informative second2:}{TypedText third:}{Text (double)z} (35)170// CHECK-CCE: ObjCInstanceMethodDecl:{ResultType int}{Informative first:}{Informative second2:}{TypedText third:}{Text (double)z} (8)171// RUN: c-index-test -code-completion-at=%s:60:4 %s | FileCheck -check-prefix=CHECK-CCF %s172// CHECK-CCF: ObjCInterfaceDecl:{TypedText A} (50)173// CHECK-CCF: ObjCInterfaceDecl:{TypedText B} (50)174// CHECK-CCF: NotImplemented:{TypedText bycopy} (40)175// CHECK-CCF: NotImplemented:{TypedText byref} (40)176// CHECK-CCF: NotImplemented:{TypedText in} (40)177// CHECK-CCF: NotImplemented:{TypedText inout} (40)178// CHECK-CCF: NotImplemented:{TypedText nonnull} (40)179// CHECK-CCF: NotImplemented:{TypedText nullable} (40)180// CHECK-CCF: NotImplemented:{TypedText oneway} (40)181// CHECK-CCF: NotImplemented:{TypedText out} (40)182// CHECK-CCF: NotImplemented:{TypedText unsigned} (50)183// CHECK-CCF: NotImplemented:{TypedText void} (50)184// CHECK-CCF: NotImplemented:{TypedText volatile} (50)185// RUN: c-index-test -code-completion-at=%s:60:11 %s | FileCheck -check-prefix=CHECK-CCG %s186// CHECK-CCG: ObjCInterfaceDecl:{TypedText A} (50)187// CHECK-CCG: ObjCInterfaceDecl:{TypedText B} (50)188// CHECK-CCG-NOT: NotImplemented:{TypedText bycopy} (40)189// CHECK-CCG-NOT: NotImplemented:{TypedText byref} (40)190// CHECK-CCG: NotImplemented:{TypedText in} (40)191// CHECK-CCG: NotImplemented:{TypedText inout} (40)192// CHECK-CCG-NOT: NotImplemented:{TypedText oneway} (40)193// CHECK-CCG: NotImplemented:{TypedText out} (40)194// CHECK-CCG: NotImplemented:{TypedText unsigned} (50)195// CHECK-CCG: NotImplemented:{TypedText void} (50)196// CHECK-CCG: NotImplemented:{TypedText volatile} (50)197// RUN: c-index-test -code-completion-at=%s:60:24 %s | FileCheck -check-prefix=CHECK-CCF %s198// RUN: c-index-test -code-completion-at=%s:60:27 %s | FileCheck -check-prefix=CHECK-CCH %s199// CHECK-CCH: ObjCInterfaceDecl:{TypedText A} (50)200// CHECK-CCH: ObjCInterfaceDecl:{TypedText B} (50)201// CHECK-CCH: NotImplemented:{TypedText bycopy} (40)202// CHECK-CCH: NotImplemented:{TypedText byref} (40)203// CHECK-CCH-NOT: NotImplemented:{TypedText in} (40)204// CHECK-CCH: NotImplemented:{TypedText inout} (40)205// CHECK-CCH: NotImplemented:{TypedText oneway} (40)206// CHECK-CCH: NotImplemented:{TypedText out} (40)207// CHECK-CCH: NotImplemented:{TypedText unsigned} (50)208// CHECK-CCH: NotImplemented:{TypedText void} (50)209// CHECK-CCH: NotImplemented:{TypedText volatile} (50)210 211// IBAction completion212// RUN: c-index-test -code-completion-at=%s:5:4 %s | FileCheck -check-prefix=CHECK-IBACTION %s213// CHECK-IBACTION: NotImplemented:{TypedText IBAction}{RightParen )}{Placeholder selector}{Colon :}{LeftParen (}{Text id}{RightParen )}{Text sender} (40)214 215// RUN: c-index-test -code-completion-at=%s:68:9 %s | FileCheck -check-prefix=CHECK-8939352 %s216// CHECK-8939352: ObjCInstanceMethodDecl:{TypedText method:}{LeftParen (}{Text int}{RightParen )}{Text x}{HorizontalSpace }{TypedText :}{LeftParen (}{Text int}{RightParen )}{Text y} (40)217 218 219// RUN: c-index-test -code-completion-at=%s:72:2 %s | FileCheck -check-prefix=CHECK-ONEWAY %s220// CHECK-ONEWAY: ObjCInstanceMethodDecl:{LeftParen (}{Text oneway }{Text void}{RightParen )}{TypedText method:}{LeftParen (}{Text in }{Text id}{RightParen )}{Text x} (40)221 222// RUN: c-index-test -code-completion-at=%s:85:2 %s | FileCheck -check-prefix=CHECK-CLASSTY %s223// CHECK-CLASSTY: ObjCInstanceMethodDecl:{LeftParen (}{Text Class<P1>}{RightParen )}{TypedText meth}224// CHECK-CLASSTY: ObjCInstanceMethodDecl:{LeftParen (}{Text MyObject<P1> *}{RightParen )}{TypedText meth2}225// CHECK-CLASSTY: ObjCInstanceMethodDecl:{LeftParen (}{Text MyObjectRef}{RightParen )}{TypedText meth3}226 227// RUN: c-index-test -code-completion-at=%s:96:2 %s -target x86_64-apple-macosx10.7 | FileCheck -check-prefix=CHECK-NULLABILITY %s228// CHECK-NULLABILITY: ObjCInstanceMethodDecl:{LeftParen (}{Text I2 *}{RightParen )}{TypedText produceI2:}{LeftParen (}{Text I2 *}{RightParen )}{Text i2} (40)229// CHECK-NULLABILITY: ObjCInstanceMethodDecl:{LeftParen (}{Text id}{RightParen )}{TypedText prop}230// CHECK-NULLABILITY: ObjCInstanceMethodDecl:{LeftParen (}{Text void (^)(int * _Nullable)}{RightParen )}{TypedText propWB}231// CHECK-NULLABILITY: ObjCInstanceMethodDecl:{LeftParen (}{Text void}{RightParen )}{TypedText setProp:}{LeftParen (}{Text id}{RightParen )}{Text prop}232// CHECK-NULLABILITY: ObjCInstanceMethodDecl:{LeftParen (}{Text void}{RightParen )}{TypedText setPropWB:}{LeftParen (}{Text void (^)(int * _Nullable)}{RightParen )}{Text propWB}233// CHECK-NULLABILITY: ObjCInstanceMethodDecl:{LeftParen (}{Text int * _Nullable *}{RightParen )}{TypedText something:}{LeftParen (}{Text void (^)(int * _Nullable)}{RightParen )}{Text b}234 235// RUN: c-index-test -code-completion-at=%s:107:2 %s -target x86_64-apple-macosx10.7 | FileCheck -check-prefix=CHECK-NULLABILITY2 %s236// CHECK-NULLABILITY2: ObjCInstanceMethodDecl:{LeftParen (}{Text instancetype}{RightParen )}{TypedText getI3} (40)237// CHECK-NULLABILITY2: ObjCInstanceMethodDecl:{LeftParen (}{Text I3 *}{RightParen )}{TypedText produceI3:}{LeftParen (}{Text I3 *}{RightParen )}{Text i3} (40)238 239@interface CompleteWithoutLeadingPrefix240 241- (void)aMethod;242+ (int)aClassMethod:(int)x;243@property int p;244 245@end246 247@implementation CompleteWithoutLeadingPrefix248 249 250 251@end252 253// RUN: c-index-test -code-completion-at=%s:250:1 %s | FileCheck -check-prefix=CHECK-COMP-NO-PREFIX %s254// CHECK-COMP-NO-PREFIX: NotImplemented:{TypedText @end} (40)255// CHECK-COMP-NO-PREFIX: ObjCClassMethodDecl:{Text +}{HorizontalSpace }{LeftParen (}{Text int}{RightParen )}{TypedText aClassMethod:}{LeftParen (}{Text int}{RightParen )}{Text x} (40)256// CHECK-COMP-NO-PREFIX: ObjCInstanceMethodDecl:{Text -}{HorizontalSpace }{LeftParen (}{Text void}{RightParen )}{TypedText aMethod} (40)257// CHECK-COMP-NO-PREFIX: ObjCInterfaceDecl:{TypedText I1}258// CHECK-COMP-NO-PREFIX: ObjCInstanceMethodDecl:{Text -}{HorizontalSpace }{LeftParen (}{Text int}{RightParen )}{TypedText p} (40)259// CHECK-COMP-NO-PREFIX: ObjCInstanceMethodDecl:{Text -}{HorizontalSpace }{LeftParen (}{Text void}{RightParen )}{TypedText setP:}{LeftParen (}{Text int}{RightParen )}{Text p} (40)260 261@interface NoNameSelectors262- (void):(int)a;263- (void):(int)a :(int)b;264@end265 266@implementation NoNameSelectors267 268@end269 270// RUN: c-index-test -code-completion-at=%s:268:1 %s | FileCheck -check-prefix=CHECK-NNS %s271// CHECK-NNS: ObjCInstanceMethodDecl:{Text -}{HorizontalSpace }{LeftParen (}{Text void}{RightParen )}{TypedText :}{LeftParen (}{Text int}{RightParen )}{Text a}272// CHECK-NNS: ObjCInstanceMethodDecl:{Text -}{HorizontalSpace }{LeftParen (}{Text void}{RightParen )}{TypedText :}{LeftParen (}{Text int}{RightParen )}{Text a}{HorizontalSpace }{TypedText :}{LeftParen (}{Text int}{RightParen )}{Text b}273