diff options
Diffstat (limited to 'clang/test/Rewriter')
26 files changed, 563 insertions, 0 deletions
diff --git a/clang/test/Rewriter/id-test-3.m b/clang/test/Rewriter/id-test-3.m new file mode 100644 index 00000000000..a340348de94 --- /dev/null +++ b/clang/test/Rewriter/id-test-3.m @@ -0,0 +1,14 @@ +// RUN: clang -rewrite-test %s | clang + +@protocol P +- (id<P>) Meth: (id<P>) Arg; +@end + +@interface INTF<P> +- (id<P>)IMeth; +@end + +@implementation INTF +- (id<P>)IMeth { return [(id<P>)self Meth: (id<P>)0]; } +- (id<P>) Meth : (id<P>) Arg {} +@end diff --git a/clang/test/Rewriter/ivar-encoding-1.m b/clang/test/Rewriter/ivar-encoding-1.m new file mode 100644 index 00000000000..6a45fc5bbbf --- /dev/null +++ b/clang/test/Rewriter/ivar-encoding-1.m @@ -0,0 +1,15 @@ +// RUN: clang -rewrite-test %s + +@interface Intf +{ + id ivar; + id ivar1[12]; + + id **ivar3; + + id (*ivar4) (id, id); +} +@end + +@implementation Intf +@end diff --git a/clang/test/Rewriter/ivar-encoding-2.m b/clang/test/Rewriter/ivar-encoding-2.m new file mode 100644 index 00000000000..424b30fb6f2 --- /dev/null +++ b/clang/test/Rewriter/ivar-encoding-2.m @@ -0,0 +1,12 @@ +// RUN: clang -rewrite-test %s + +@implementation Intf +{ + id ivar; + id ivar1[12]; + + id **ivar3; + + id (*ivar4) (id, id); +} +@end diff --git a/clang/test/Rewriter/metadata-test-1.m b/clang/test/Rewriter/metadata-test-1.m new file mode 100644 index 00000000000..134debf6f85 --- /dev/null +++ b/clang/test/Rewriter/metadata-test-1.m @@ -0,0 +1,12 @@ +// RUN: clang -rewrite-test %s + +@interface Intf +@end + +@implementation Intf(Category) +- (void) CatMeth {} +@end + +@implementation Another +- (void) CatMeth {} +@end diff --git a/clang/test/Rewriter/metadata-test-2.m b/clang/test/Rewriter/metadata-test-2.m new file mode 100644 index 00000000000..dbaf035fd8d --- /dev/null +++ b/clang/test/Rewriter/metadata-test-2.m @@ -0,0 +1,15 @@ +// RUN: clang -rewrite-test %s + +typedef struct _NSPoint { + float x; + float y; +} NSPoint; + +@interface Intf +- (void) MyMeth : (NSPoint) Arg1; +@end + +@implementation Intf +- (void) MyMeth : (NSPoint) Arg1{} +@end + diff --git a/clang/test/Rewriter/method-encoding-1.m b/clang/test/Rewriter/method-encoding-1.m new file mode 100644 index 00000000000..96d1bfafc7c --- /dev/null +++ b/clang/test/Rewriter/method-encoding-1.m @@ -0,0 +1,18 @@ +// RUN: clang -rewrite-test %s + +@protocol P1 +- (void) MyProtoMeth : (int **) arg1 : (void*) arg2; ++ (void) MyProtoMeth : (int **) arg1 : (void*) arg2; +@end + +@interface Intf <P1> +- (char *) MyMeth : (double) arg1 : (char *[12]) arg2; +- (id) address:(void *)location with:(unsigned **)arg2; +@end + +@implementation Intf +- (char *) MyMeth : (double) arg1 : (char *[12]) arg2{} +- (void) MyProtoMeth : (int **) arg1 : (void*) arg2 {} ++ (void) MyProtoMeth : (int **) arg1 : (void*) arg2 {} +- (id) address:(void *)location with:(unsigned **)arg2{} +@end diff --git a/clang/test/Rewriter/objc-encoding-bug-1.m b/clang/test/Rewriter/objc-encoding-bug-1.m new file mode 100644 index 00000000000..ecf7d813141 --- /dev/null +++ b/clang/test/Rewriter/objc-encoding-bug-1.m @@ -0,0 +1,19 @@ +// RUN: clang -rewrite-test %s | clang + +typedef struct NSMethodFrameArgInfo { + struct NSMethodFrameArgInfo *subInfo; + struct NSMethodFrameArgInfo *an; +} NSMethodFrameArgInfo; + +@interface NSMethodSignature +- (NSMethodFrameArgInfo *)_argInfo; +@end + +@implementation NSMethodSignature + +- (NSMethodFrameArgInfo *)_argInfo{ + return 0; +} + +@end + diff --git a/clang/test/Rewriter/objc-ivar-receiver-1.m b/clang/test/Rewriter/objc-ivar-receiver-1.m new file mode 100644 index 00000000000..c7df1787b04 --- /dev/null +++ b/clang/test/Rewriter/objc-ivar-receiver-1.m @@ -0,0 +1,23 @@ +// RUN: clang -rewrite-test %s | clang +// RUN: clang -rewrite-test %s | grep 'newInv->_container' + +@interface NSMutableArray +- (void)addObject:(id)addObject; +@end + +@interface NSInvocation { +@private + id _container; +} ++ (NSInvocation *)invocationWithMethodSignature; + +@end + +@implementation NSInvocation + ++ (NSInvocation *)invocationWithMethodSignature { + NSInvocation *newInv; + [newInv->_container addObject:0]; + return 0; +} +@end diff --git a/clang/test/Rewriter/objc-string-concat-1.m b/clang/test/Rewriter/objc-string-concat-1.m new file mode 100644 index 00000000000..63b8d1d1c33 --- /dev/null +++ b/clang/test/Rewriter/objc-string-concat-1.m @@ -0,0 +1,14 @@ +// RUN: clang -rewrite-test %s + +@class NSString; + +@interface NSConstantString; +@end + + + +NSConstantString *t0 = @"123"; +NSConstantString *t = @"123" @"4567"; // concat +NSConstantString *t1 = @"123" @"4567" /* COMMENT */ @"89"; // concat +NSConstantString *t2 = @"123" @/* COMMENT */ "4567"; // concat + diff --git a/clang/test/Rewriter/objc-super-test.m b/clang/test/Rewriter/objc-super-test.m new file mode 100644 index 00000000000..80f1dddc00c --- /dev/null +++ b/clang/test/Rewriter/objc-super-test.m @@ -0,0 +1,15 @@ +// RUN: clang -rewrite-test %s | clang + +@interface SUPER +- (int) MainMethod; +@end + +@interface MyDerived : SUPER +- (int) instanceMethod; +@end + +@implementation MyDerived +- (int) instanceMethod { + return [super MainMethod]; +} +@end diff --git a/clang/test/Rewriter/objc-synchronized-1.m b/clang/test/Rewriter/objc-synchronized-1.m new file mode 100644 index 00000000000..cb65fc48321 --- /dev/null +++ b/clang/test/Rewriter/objc-synchronized-1.m @@ -0,0 +1,16 @@ +// RUN: clang -rewrite-test %s | clang + +id SYNCH_EXPR(); +void SYNCH_BODY(); +void SYNCH_BEFORE(); +void SYNC_AFTER(); + +void foo(id sem) +{ + SYNCH_BEFORE(); + @synchronized (SYNCH_EXPR()) { + SYNCH_BODY(); + return; + } + SYNC_AFTER(); +} diff --git a/clang/test/Rewriter/protocol-rewrite-1.m b/clang/test/Rewriter/protocol-rewrite-1.m new file mode 100644 index 00000000000..e47a8f65047 --- /dev/null +++ b/clang/test/Rewriter/protocol-rewrite-1.m @@ -0,0 +1,48 @@ +// RUN: clang -rewrite-test %s | clang + +typedef struct MyWidget { + int a; +} MyWidget; + +MyWidget gWidget = { 17 }; + +@protocol MyProto +- (MyWidget *)widget; +@end + +@interface Foo +@end + +@interface Bar: Foo <MyProto> +@end + +@interface Container ++ (MyWidget *)elementForView:(Foo *)view; +@end + +@implementation Foo +@end + +@implementation Bar +- (MyWidget *)widget { + return &gWidget; +} +@end + +@implementation Container ++ (MyWidget *)elementForView:(Foo *)view +{ + MyWidget *widget = (void*)0; + if (@protocol(MyProto)) { + widget = [(id <MyProto>)view widget]; + } + return widget; +} +@end + +int main(void) { + id view; + MyWidget *w = [Container elementForView: view]; + + return 0; +} diff --git a/clang/test/Rewriter/rewrite-api-bug.m b/clang/test/Rewriter/rewrite-api-bug.m new file mode 100644 index 00000000000..b965c92971b --- /dev/null +++ b/clang/test/Rewriter/rewrite-api-bug.m @@ -0,0 +1,11 @@ +// RUN: clang -rewrite-test %s + +@interface MyDerived +- (void) instanceMethod; +@end + +@implementation MyDerived +- (void) instanceMethod { +} +@end + diff --git a/clang/test/Rewriter/rewrite-foreach-1.m b/clang/test/Rewriter/rewrite-foreach-1.m new file mode 100644 index 00000000000..5ee0264d326 --- /dev/null +++ b/clang/test/Rewriter/rewrite-foreach-1.m @@ -0,0 +1,37 @@ +// RUN: clang -rewrite-test %s | clang + +@protocol P @end + +@interface MyList +@end + +@implementation MyList +- (unsigned int)countByEnumeratingWithState: (struct __objcFastEnumerationState *)state objects: (id *)items count:(unsigned int)stackcount +{ + return 0; +} +@end + +@interface MyList (BasicTest) +- (void)compilerTestAgainst; +@end + +int LOOP(); +@implementation MyList (BasicTest) +- (void)compilerTestAgainst { + id el; + for (el in self) + { LOOP(); } + for (id el1 in self) + LOOP(); + + for (el in (self)) + if (el) + LOOP(); + + for (el in ((self))) + if (el) + LOOP(); +} +@end + diff --git a/clang/test/Rewriter/rewrite-foreach-2.m b/clang/test/Rewriter/rewrite-foreach-2.m new file mode 100644 index 00000000000..98fa926359c --- /dev/null +++ b/clang/test/Rewriter/rewrite-foreach-2.m @@ -0,0 +1,34 @@ +// RUN: clang -rewrite-test %s | clang + +@protocol P @end + +@interface MyList +@end + +@implementation MyList +- (unsigned int)countByEnumeratingWithState: (struct __objcFastEnumerationState *)state objects: (id *)items count:(unsigned int)stackcount +{ + return 0; +} +@end + +@interface MyList (BasicTest) +- (void)compilerTestAgainst; +@end + +int LOOP(); +int INNERLOOP(); +void END_LOOP(); +@implementation MyList (BasicTest) +- (void)compilerTestAgainst { + id el; + for (el in self) + { LOOP(); + for (id el1 in self) + INNER_LOOP(); + + END_LOOP(); + } +} +@end + diff --git a/clang/test/Rewriter/rewrite-foreach-3.m b/clang/test/Rewriter/rewrite-foreach-3.m new file mode 100644 index 00000000000..50ddb190a27 --- /dev/null +++ b/clang/test/Rewriter/rewrite-foreach-3.m @@ -0,0 +1,29 @@ +// RUN: clang -rewrite-test %s | clang + +@protocol P @end + +@interface MyList +@end + +@implementation MyList +- (unsigned int)countByEnumeratingWithState: (struct __objcFastEnumerationState *)state objects: (id *)items count:(unsigned int)stackcount +{ + return 0; +} +@end + +@interface MyList (BasicTest) +- (void)compilerTestAgainst; +@end + +int LOOP(); +@implementation MyList (BasicTest) +- (void)compilerTestAgainst { + MyList * el; + for (el in self) + { LOOP(); } + for (MyList * el1 in self) + LOOP(); +} +@end + diff --git a/clang/test/Rewriter/rewrite-foreach-4.m b/clang/test/Rewriter/rewrite-foreach-4.m new file mode 100644 index 00000000000..10b0a2d1410 --- /dev/null +++ b/clang/test/Rewriter/rewrite-foreach-4.m @@ -0,0 +1,32 @@ +// RUN: clang -rewrite-test %s | clang + +@interface MyList +- (id) allKeys; +@end + +@implementation MyList +- (unsigned int)countByEnumeratingWithState: (struct __objcFastEnumerationState *)state objects: (id *)items count:(unsigned int)stackcount +{ + return 0; +} +- (id) allKeys {} +@end + +@interface MyList (BasicTest) +- (void)compilerTestAgainst; +@end + +int LOOP(); +@implementation MyList (BasicTest) +- (void)compilerTestAgainst { + MyList * el; + for (el in [el allKeys]) { LOOP(); + } + + for (id el1 in[el allKeys]) { LOOP(); + } + for (el in([el allKeys])) { LOOP(); + } +} +@end + diff --git a/clang/test/Rewriter/rewrite-foreach-5.m b/clang/test/Rewriter/rewrite-foreach-5.m new file mode 100644 index 00000000000..c068c36c803 --- /dev/null +++ b/clang/test/Rewriter/rewrite-foreach-5.m @@ -0,0 +1,47 @@ +// RUN: clang -rewrite-test %s | clang + +@interface MyList +- (id) allKeys; +@end + +@implementation MyList +- (unsigned int)countByEnumeratingWithState: (struct __objcFastEnumerationState *)state objects: (id *)items count:(unsigned int)stackcount +{ + return 0; +} +- (id) allKeys {} +@end + +@interface MyList (BasicTest) +- (void)compilerTestAgainst; +@end + +int LOOP(); +@implementation MyList (BasicTest) +- (void)compilerTestAgainst { + MyList * el; + int i; + for (el in [el allKeys]) { + for (i = 0; i < 10; i++) + if (i == 5) + break; + + if (el == 0) + break; + if (el != self) + continue; + LOOP(); + } + + for (id el1 in[el allKeys]) { + LOOP(); + for (el in self) { + if (el) + continue; + } + if (el1) + break; + } +} +@end + diff --git a/clang/test/Rewriter/rewrite-foreach-6.m b/clang/test/Rewriter/rewrite-foreach-6.m new file mode 100644 index 00000000000..bae7e7a4739 --- /dev/null +++ b/clang/test/Rewriter/rewrite-foreach-6.m @@ -0,0 +1,13 @@ +// RUN: clang %s -rewrite-test +// rdar://5716356 +// FIXME: Should be able to pipe into clang, but code is not +// yet correct for other reasons: rdar://5716940 + +@class NSNotification; +@class NSMutableArray; + +void foo(NSMutableArray *notificationArray, id X) { + for (NSNotification *notification in notificationArray) + [X postNotification:notification]; +} + diff --git a/clang/test/Rewriter/rewrite-protocol-type-1.m b/clang/test/Rewriter/rewrite-protocol-type-1.m new file mode 100644 index 00000000000..93dfb2acf48 --- /dev/null +++ b/clang/test/Rewriter/rewrite-protocol-type-1.m @@ -0,0 +1,24 @@ +// RUN: clang -rewrite-test %s | clang + +@protocol MyProto1 +@end + +@protocol MyProto2 +@end + +@interface INTF @end + +INTF <MyProto1> *g1; + +INTF <MyProto1, MyProto2> *g2, *g3; + +INTF <MyProto1> * Func(INTF <MyProto1> *p2, INTF<MyProto1> *p3, INTF *p4, INTF<MyProto1> *p5) +{ + return p2; +} + +INTF <MyProto1, MyProto2> * Func1(INTF *p2, INTF<MyProto1, MyProto2> *p3, INTF *p4, INTF<MyProto1> *p5) +{ + return p3; +} + diff --git a/clang/test/Rewriter/rewrite-try-catch.m b/clang/test/Rewriter/rewrite-try-catch.m new file mode 100644 index 00000000000..b8ba45ee64f --- /dev/null +++ b/clang/test/Rewriter/rewrite-try-catch.m @@ -0,0 +1,18 @@ +// RUN: clang -rewrite-test %s | clang + +@interface foo @end +@interface GARF @end + +int main() +{ + +@try { + MYTRY(); +} + +@catch (foo* localException) { + MYCATCH(); + @throw; +} +} + diff --git a/clang/test/Rewriter/static-type-protocol-1.m b/clang/test/Rewriter/static-type-protocol-1.m new file mode 100644 index 00000000000..6a6ec40dbdd --- /dev/null +++ b/clang/test/Rewriter/static-type-protocol-1.m @@ -0,0 +1,27 @@ +// RUN: clang -rewrite-test %s + +@protocol Proto +- (void) ProtoDidget; +@end + +@protocol MyProto <Proto> +- (void) widget; +@end + +@interface Foo +- (void)StillMode; +@end + +@interface Container ++ (void)MyMeth; +@end + +@implementation Container ++ (void)MyMeth +{ + Foo *view; + [(Foo <MyProto> *)view StillMode]; + [(Foo <MyProto> *)view widget]; + [(Foo <MyProto> *)view ProtoDidget]; +} +@end diff --git a/clang/test/Rewriter/undecl-objc-h.m b/clang/test/Rewriter/undecl-objc-h.m new file mode 100644 index 00000000000..d5103d335c5 --- /dev/null +++ b/clang/test/Rewriter/undecl-objc-h.m @@ -0,0 +1,29 @@ +// RUN: clang -rewrite-test %s | clang + +typedef struct S { + int * pint; + int size; +}NSRec; + +@interface SUPER +- (NSRec) MainMethod : (NSRec) Arg1 : (NSRec) Arg2; +@end + +@interface MyDerived : SUPER +{ + NSRec d; +} +- (int) instanceMethod; +- (int) another : (int) arg; +- (NSRec) MainMethod : (NSRec) Arg1 : (NSRec) Arg2; +@end + +@implementation MyDerived +- (int) instanceMethod { + return [self another : [self MainMethod : d : d].size]; +} + +- (int) another : (int) arg { return arg; } +- (NSRec) MainMethod : (NSRec) Arg1 : (NSRec) Arg2 { return Arg2; } +@end + diff --git a/clang/test/Rewriter/undeclared-method-1.m b/clang/test/Rewriter/undeclared-method-1.m new file mode 100644 index 00000000000..156004f0c51 --- /dev/null +++ b/clang/test/Rewriter/undeclared-method-1.m @@ -0,0 +1,9 @@ +// RUN: clang -rewrite-test %s + +@interface Derived @end + +int main(void) { + Derived *v ; + [v free]; + return 0; +} diff --git a/clang/test/Rewriter/undef-field-reference-1.m b/clang/test/Rewriter/undef-field-reference-1.m new file mode 100644 index 00000000000..36096e57f6e --- /dev/null +++ b/clang/test/Rewriter/undef-field-reference-1.m @@ -0,0 +1,15 @@ +// RUN: clang -rewrite-test %s | clang + +@interface MyDerived +{ +@public + int IVAR; +} +@end + +MyDerived *pd; +int main() { + return pd->IVAR; +} + + diff --git a/clang/test/Rewriter/va-method.m b/clang/test/Rewriter/va-method.m new file mode 100644 index 00000000000..258286937ff --- /dev/null +++ b/clang/test/Rewriter/va-method.m @@ -0,0 +1,17 @@ +// RUN: clang -rewrite-test %s | clang + +#include <stdarg.h> + +@interface NSObject @end +@interface XX : NSObject @end + +@implementation XX +- (void)encodeValuesOfObjCTypes:(const char *)types, ... { + va_list ap; + va_start(ap, types); + while (*types) ; + va_end(ap); +} + +@end + |

