summaryrefslogtreecommitdiffstats
path: root/test/Rewriter
diff options
context:
space:
mode:
Diffstat (limited to 'test/Rewriter')
-rw-r--r--test/Rewriter/block-test.c38
-rw-r--r--test/Rewriter/crash.m25
-rw-r--r--test/Rewriter/finally.m27
-rw-r--r--test/Rewriter/id-test-3.m14
-rw-r--r--test/Rewriter/ivar-encoding-1.m15
-rw-r--r--test/Rewriter/ivar-encoding-2.m12
-rw-r--r--test/Rewriter/metadata-test-1.m12
-rw-r--r--test/Rewriter/metadata-test-2.m15
-rw-r--r--test/Rewriter/method-encoding-1.m18
-rw-r--r--test/Rewriter/objc-encoding-bug-1.m19
-rw-r--r--test/Rewriter/objc-ivar-receiver-1.m24
-rw-r--r--test/Rewriter/objc-string-concat-1.m14
-rw-r--r--test/Rewriter/objc-super-test.m18
-rw-r--r--test/Rewriter/objc-synchronized-1.m20
-rw-r--r--test/Rewriter/properties.m54
-rw-r--r--test/Rewriter/protocol-rewrite-1.m48
-rw-r--r--test/Rewriter/rewrite-api-bug.m11
-rw-r--r--test/Rewriter/rewrite-foreach-1.m37
-rw-r--r--test/Rewriter/rewrite-foreach-2.m34
-rw-r--r--test/Rewriter/rewrite-foreach-3.m29
-rw-r--r--test/Rewriter/rewrite-foreach-4.m32
-rw-r--r--test/Rewriter/rewrite-foreach-5.m47
-rw-r--r--test/Rewriter/rewrite-foreach-6.m13
-rw-r--r--test/Rewriter/rewrite-nest.m27
-rw-r--r--test/Rewriter/rewrite-protocol-type-1.m24
-rw-r--r--test/Rewriter/rewrite-try-catch.m27
-rw-r--r--test/Rewriter/static-type-protocol-1.m27
-rw-r--r--test/Rewriter/undecl-objc-h.m29
-rw-r--r--test/Rewriter/undeclared-method-1.m9
-rw-r--r--test/Rewriter/undef-field-reference-1.m15
-rw-r--r--test/Rewriter/va-method.m17
31 files changed, 751 insertions, 0 deletions
diff --git a/test/Rewriter/block-test.c b/test/Rewriter/block-test.c
new file mode 100644
index 0000000..9b24e63
--- /dev/null
+++ b/test/Rewriter/block-test.c
@@ -0,0 +1,38 @@
+// RUN: clang-cc -rewrite-blocks %s -fblocks -o -
+
+static int (^block)(const void *, const void *) = (int (^)(const void *, const void *))0;
+static int (*func)(int (^block)(void *, void *)) = (int (*)(int (^block)(void *, void *)))0;
+
+typedef int (^block_T)(const void *, const void *);
+typedef int (*func_T)(int (^block)(void *, void *));
+
+void foo(const void *a, const void *b, void *c) {
+ int (^block)(const void *, const void *) = (int (^)(const void *, const void *))c;
+ int (*func)(int (^block)(void *, void *)) = (int (*)(int (^block)(void *, void *)))c;
+}
+
+typedef void (^test_block_t)();
+
+int main(int argc, char **argv) {
+ int a;
+
+ void (^test_block_v)();
+ void (^test_block_v2)(int, float);
+
+ void (^test_block_v3)(void (^barg)(int));
+
+ a = 77;
+ test_block_v = ^(){ int local=1; printf("a=%d\n",a+local); };
+ test_block_v();
+ a++;
+ test_block_v();
+
+ __block int b;
+
+ b = 88;
+ test_block_v2 = ^(int x, float f){ printf("b=%d\n",b); };
+ test_block_v2(1,2.0);
+ b++;
+ test_block_v2(3,4.0);
+ return 7;
+}
diff --git a/test/Rewriter/crash.m b/test/Rewriter/crash.m
new file mode 100644
index 0000000..d4aba58
--- /dev/null
+++ b/test/Rewriter/crash.m
@@ -0,0 +1,25 @@
+// RUN: clang-cc -rewrite-objc -o - %s
+// rdar://5950938
+@interface NSArray {}
++ (id)arrayWithObjects:(id)firstObj, ...;
+@end
+
+@interface NSConstantString {}
+@end
+
+int main() {
+ id foo = [NSArray arrayWithObjects:@"1", @"2", @"3", @"4", @"5", @"6", @"7", @"8", @"9", @"10", @"11", @"12", 0];
+ return 0;
+}
+
+// rdar://6291588
+@protocol A
+@end
+
+@interface Foo
+@end
+
+void func() {
+ id <A> obj = (id <A>)[Foo bar];
+}
+
diff --git a/test/Rewriter/finally.m b/test/Rewriter/finally.m
new file mode 100644
index 0000000..bdc5a34
--- /dev/null
+++ b/test/Rewriter/finally.m
@@ -0,0 +1,27 @@
+// RUN: clang-cc -rewrite-objc -verify %s -o -
+
+int main() {
+ @try {
+ printf("executing try"); // expected-warning{{implicitly declaring C library function 'printf' with type 'int (char const *, ...)'}} \
+ // expected-note{{please include the header <stdio.h> or explicitly provide a declaration for 'printf'}}
+ return(0); // expected-warning{{rewriter doesn't support user-specified control flow semantics for @try/@finally (code may not execute properly)}}
+ } @finally {
+ printf("executing finally");
+ }
+ while (1) {
+ @try {
+ printf("executing try");
+ break; // expected-warning{{rewriter doesn't support user-specified control flow semantics for @try/@finally (code may not execute properly)}}
+ } @finally {
+ printf("executing finally");
+ }
+ printf("executing after finally block");
+ }
+ @try {
+ printf("executing try");
+ } @finally {
+ printf("executing finally");
+ }
+ return 0;
+}
+
diff --git a/test/Rewriter/id-test-3.m b/test/Rewriter/id-test-3.m
new file mode 100644
index 0000000..ad1e76d
--- /dev/null
+++ b/test/Rewriter/id-test-3.m
@@ -0,0 +1,14 @@
+// RUN: clang-cc -rewrite-objc %s -o=-
+
+@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/test/Rewriter/ivar-encoding-1.m b/test/Rewriter/ivar-encoding-1.m
new file mode 100644
index 0000000..7591461
--- /dev/null
+++ b/test/Rewriter/ivar-encoding-1.m
@@ -0,0 +1,15 @@
+// RUN: clang-cc -rewrite-objc %s -o=-
+
+@interface Intf
+{
+ id ivar;
+ id ivar1[12];
+
+ id **ivar3;
+
+ id (*ivar4) (id, id);
+}
+@end
+
+@implementation Intf
+@end
diff --git a/test/Rewriter/ivar-encoding-2.m b/test/Rewriter/ivar-encoding-2.m
new file mode 100644
index 0000000..86cc9b6
--- /dev/null
+++ b/test/Rewriter/ivar-encoding-2.m
@@ -0,0 +1,12 @@
+// RUN: clang-cc -rewrite-objc %s -o=-
+
+@implementation Intf
+{
+ id ivar;
+ id ivar1[12];
+
+ id **ivar3;
+
+ id (*ivar4) (id, id);
+}
+@end
diff --git a/test/Rewriter/metadata-test-1.m b/test/Rewriter/metadata-test-1.m
new file mode 100644
index 0000000..40eded1
--- /dev/null
+++ b/test/Rewriter/metadata-test-1.m
@@ -0,0 +1,12 @@
+// RUN: clang-cc -rewrite-objc %s -o=-
+
+@interface Intf
+@end
+
+@implementation Intf(Category)
+- (void) CatMeth {}
+@end
+
+@implementation Another
+- (void) CatMeth {}
+@end
diff --git a/test/Rewriter/metadata-test-2.m b/test/Rewriter/metadata-test-2.m
new file mode 100644
index 0000000..ab838f1
--- /dev/null
+++ b/test/Rewriter/metadata-test-2.m
@@ -0,0 +1,15 @@
+// RUN: clang-cc -rewrite-objc %s -o=-
+
+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/test/Rewriter/method-encoding-1.m b/test/Rewriter/method-encoding-1.m
new file mode 100644
index 0000000..25dccbf
--- /dev/null
+++ b/test/Rewriter/method-encoding-1.m
@@ -0,0 +1,18 @@
+// RUN: clang-cc -rewrite-objc %s -o=-
+
+@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/test/Rewriter/objc-encoding-bug-1.m b/test/Rewriter/objc-encoding-bug-1.m
new file mode 100644
index 0000000..684a0d2
--- /dev/null
+++ b/test/Rewriter/objc-encoding-bug-1.m
@@ -0,0 +1,19 @@
+// RUN: clang-cc -rewrite-objc %s -o=-
+
+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/test/Rewriter/objc-ivar-receiver-1.m b/test/Rewriter/objc-ivar-receiver-1.m
new file mode 100644
index 0000000..c7ad05a
--- /dev/null
+++ b/test/Rewriter/objc-ivar-receiver-1.m
@@ -0,0 +1,24 @@
+// RUN: clang-cc -rewrite-objc %s -o - &&
+// RUN: clang-cc -rewrite-objc %s -o - | grep 'newInv->_container'
+
+@interface NSMutableArray
+- (void)addObject:(id)addObject;
+@end
+
+@interface NSInvocation {
+@private
+ id _container;
+}
++ (NSInvocation *)invocationWithMethodSignature;
+
+@end
+
+@implementation NSInvocation
+
++ (NSInvocation *)invocationWithMethodSignature {
+ NSInvocation *newInv;
+ id obj = newInv->_container;
+ [newInv->_container addObject:0];
+ return 0;
+}
+@end
diff --git a/test/Rewriter/objc-string-concat-1.m b/test/Rewriter/objc-string-concat-1.m
new file mode 100644
index 0000000..e8f8a88
--- /dev/null
+++ b/test/Rewriter/objc-string-concat-1.m
@@ -0,0 +1,14 @@
+// RUN: clang-cc -rewrite-objc %s -o=-
+
+@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/test/Rewriter/objc-super-test.m b/test/Rewriter/objc-super-test.m
new file mode 100644
index 0000000..500933d
--- /dev/null
+++ b/test/Rewriter/objc-super-test.m
@@ -0,0 +1,18 @@
+// RUN: clang-cc -rewrite-objc %s -o - | grep objc_msgSendSuper | grep MainMethod
+
+typedef struct objc_selector *SEL;
+typedef struct objc_object *id;
+
+@interface SUPER
+- (int) MainMethod;
+@end
+
+@interface MyDerived : SUPER
+- (int) instanceMethod;
+@end
+
+@implementation MyDerived
+- (int) instanceMethod {
+ return [super MainMethod];
+}
+@end
diff --git a/test/Rewriter/objc-synchronized-1.m b/test/Rewriter/objc-synchronized-1.m
new file mode 100644
index 0000000..e3c4116
--- /dev/null
+++ b/test/Rewriter/objc-synchronized-1.m
@@ -0,0 +1,20 @@
+// RUN: clang-cc -rewrite-objc %s -o=-
+
+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();
+ @synchronized ([sem self]) {
+ SYNCH_BODY();
+ return;
+ }
+}
diff --git a/test/Rewriter/properties.m b/test/Rewriter/properties.m
new file mode 100644
index 0000000..ac8ee9f
--- /dev/null
+++ b/test/Rewriter/properties.m
@@ -0,0 +1,54 @@
+// RUN: clang-cc -rewrite-objc %s -o -
+
+@interface Foo {
+ int i;
+ int rrrr;
+ Foo *o;
+}
+@property int i;
+@property(readonly) int rrrr;
+@property int d;
+@property(retain) Foo *o;
+
+- (void)foo;
+@end
+
+@implementation Foo
+@synthesize i;
+@synthesize rrrr;
+@synthesize o;
+
+@dynamic d;
+
+- (void)foo {
+ i = 99;
+}
+
+- (int)bar {
+ return i;
+}
+@end
+
+@interface Bar {
+}
+@end
+
+@implementation Bar
+
+static int func(int i);
+
+- (void)baz {
+ Foo *obj1, *obj2;
+ int i;
+ if (obj1.i == obj2.rrrr)
+ obj1.i = 33;
+ obj1.i = func(obj2.rrrr);
+ obj1.i = obj2.rrrr;
+ obj1.i = (obj2.rrrr);
+ [obj1 setI:[obj2 rrrr]];
+ obj1.i = [obj2 rrrr];
+ obj1.i = 3 + [obj2 rrrr];
+ i = obj1.o.i;
+ obj1.o.i = 77;
+}
+@end
diff --git a/test/Rewriter/protocol-rewrite-1.m b/test/Rewriter/protocol-rewrite-1.m
new file mode 100644
index 0000000..263a97d
--- /dev/null
+++ b/test/Rewriter/protocol-rewrite-1.m
@@ -0,0 +1,48 @@
+// RUN: clang-cc -rewrite-objc %s -o=-
+
+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/test/Rewriter/rewrite-api-bug.m b/test/Rewriter/rewrite-api-bug.m
new file mode 100644
index 0000000..ba0511b
--- /dev/null
+++ b/test/Rewriter/rewrite-api-bug.m
@@ -0,0 +1,11 @@
+// RUN: clang-cc -rewrite-objc %s -o=-
+
+@interface MyDerived
+- (void) instanceMethod;
+@end
+
+@implementation MyDerived
+- (void) instanceMethod {
+}
+@end
+
diff --git a/test/Rewriter/rewrite-foreach-1.m b/test/Rewriter/rewrite-foreach-1.m
new file mode 100644
index 0000000..eef33f8
--- /dev/null
+++ b/test/Rewriter/rewrite-foreach-1.m
@@ -0,0 +1,37 @@
+// RUN: clang-cc -rewrite-objc %s -o=-
+
+@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/test/Rewriter/rewrite-foreach-2.m b/test/Rewriter/rewrite-foreach-2.m
new file mode 100644
index 0000000..12f0e83
--- /dev/null
+++ b/test/Rewriter/rewrite-foreach-2.m
@@ -0,0 +1,34 @@
+// RUN: clang-cc -rewrite-objc %s -o=-
+
+@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/test/Rewriter/rewrite-foreach-3.m b/test/Rewriter/rewrite-foreach-3.m
new file mode 100644
index 0000000..3aa0d95
--- /dev/null
+++ b/test/Rewriter/rewrite-foreach-3.m
@@ -0,0 +1,29 @@
+// RUN: clang-cc -rewrite-objc %s -o=-
+
+@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/test/Rewriter/rewrite-foreach-4.m b/test/Rewriter/rewrite-foreach-4.m
new file mode 100644
index 0000000..774f9a0
--- /dev/null
+++ b/test/Rewriter/rewrite-foreach-4.m
@@ -0,0 +1,32 @@
+// RUN: clang-cc -rewrite-objc %s -o=-
+
+@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/test/Rewriter/rewrite-foreach-5.m b/test/Rewriter/rewrite-foreach-5.m
new file mode 100644
index 0000000..d0d1244
--- /dev/null
+++ b/test/Rewriter/rewrite-foreach-5.m
@@ -0,0 +1,47 @@
+// RUN: clang-cc -rewrite-objc %s -o=-
+
+@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/test/Rewriter/rewrite-foreach-6.m b/test/Rewriter/rewrite-foreach-6.m
new file mode 100644
index 0000000..c6043bb
--- /dev/null
+++ b/test/Rewriter/rewrite-foreach-6.m
@@ -0,0 +1,13 @@
+// RUN: clang-cc %s -rewrite-objc -o=-
+// 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/test/Rewriter/rewrite-nest.m b/test/Rewriter/rewrite-nest.m
new file mode 100644
index 0000000..7a1690a
--- /dev/null
+++ b/test/Rewriter/rewrite-nest.m
@@ -0,0 +1,27 @@
+// RUN: clang-cc -rewrite-objc %s -o=-
+
+@interface NSMapTable @end
+@interface NSEnumerator @end
+
+typedef unsigned int NSUInteger;
+
+@interface NSConcreteMapTable : NSMapTable {
+@public
+ NSUInteger capacity;
+}
+@end
+
+@interface NSConcreteMapTableValueEnumerator : NSEnumerator {
+ NSConcreteMapTable *mapTable;
+}
+@end
+
+@implementation NSConcreteMapTableValueEnumerator
+
+- nextObject {
+ while (mapTable->capacity) {
+ }
+ return 0;
+}
+@end
+
diff --git a/test/Rewriter/rewrite-protocol-type-1.m b/test/Rewriter/rewrite-protocol-type-1.m
new file mode 100644
index 0000000..48dc029
--- /dev/null
+++ b/test/Rewriter/rewrite-protocol-type-1.m
@@ -0,0 +1,24 @@
+// RUN: clang-cc -rewrite-objc %s -o=-
+
+@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/test/Rewriter/rewrite-try-catch.m b/test/Rewriter/rewrite-try-catch.m
new file mode 100644
index 0000000..8c6d08f
--- /dev/null
+++ b/test/Rewriter/rewrite-try-catch.m
@@ -0,0 +1,27 @@
+// RUN: clang-cc -rewrite-objc %s -o=-
+
+@interface Foo @end
+@interface GARF @end
+
+void foo() {
+ @try { TRY(); }
+ @catch (...) { SPLATCH(); @throw; }
+}
+
+int main()
+{
+
+ @try {
+ MYTRY();
+ }
+
+ @catch (Foo* localException) {
+ MYCATCH();
+ @throw;
+ }
+
+ // no catch clause
+ @try { }
+ @finally { }
+}
+
diff --git a/test/Rewriter/static-type-protocol-1.m b/test/Rewriter/static-type-protocol-1.m
new file mode 100644
index 0000000..0985a9d
--- /dev/null
+++ b/test/Rewriter/static-type-protocol-1.m
@@ -0,0 +1,27 @@
+// RUN: clang-cc -rewrite-objc %s -o=-
+
+@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/test/Rewriter/undecl-objc-h.m b/test/Rewriter/undecl-objc-h.m
new file mode 100644
index 0000000..b097651
--- /dev/null
+++ b/test/Rewriter/undecl-objc-h.m
@@ -0,0 +1,29 @@
+// RUN: clang-cc -rewrite-objc %s -o=-
+
+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/test/Rewriter/undeclared-method-1.m b/test/Rewriter/undeclared-method-1.m
new file mode 100644
index 0000000..795fd61
--- /dev/null
+++ b/test/Rewriter/undeclared-method-1.m
@@ -0,0 +1,9 @@
+// RUN: clang-cc -rewrite-objc %s -o=-
+
+@interface Derived @end
+
+int main(void) {
+ Derived *v ;
+ [v free];
+ return 0;
+}
diff --git a/test/Rewriter/undef-field-reference-1.m b/test/Rewriter/undef-field-reference-1.m
new file mode 100644
index 0000000..43bc2ad
--- /dev/null
+++ b/test/Rewriter/undef-field-reference-1.m
@@ -0,0 +1,15 @@
+// RUN: clang-cc -rewrite-objc %s -o=-
+
+@interface MyDerived
+{
+@public
+ int IVAR;
+}
+@end
+
+MyDerived *pd;
+int main() {
+ return pd->IVAR;
+}
+
+
diff --git a/test/Rewriter/va-method.m b/test/Rewriter/va-method.m
new file mode 100644
index 0000000..3bee599
--- /dev/null
+++ b/test/Rewriter/va-method.m
@@ -0,0 +1,17 @@
+// RUN: clang-cc -rewrite-objc %s -o=-
+
+#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
+
OpenPOWER on IntegriCloud