diff options
Diffstat (limited to 'test/Rewriter')
| -rw-r--r-- | test/Rewriter/rewrite-anonymous-union.m | 30 | ||||
| -rw-r--r-- | test/Rewriter/rewrite-byref-vars.mm | 35 | ||||
| -rw-r--r-- | test/Rewriter/rewrite-eh.m | 20 | ||||
| -rw-r--r-- | test/Rewriter/rewrite-foreach-7.m | 7 | ||||
| -rw-r--r-- | test/Rewriter/rewrite-forward-class.m | 8 | ||||
| -rw-r--r-- | test/Rewriter/rewrite-function-decl.mm | 31 | ||||
| -rw-r--r-- | test/Rewriter/rewrite-ivar-use.m | 25 | ||||
| -rw-r--r-- | test/Rewriter/rewrite-trivial-constructor.mm | 21 | ||||
| -rw-r--r-- | test/Rewriter/rewrite-weak-attr.m | 13 | ||||
| -rw-r--r-- | test/Rewriter/weak_byref_objects.m | 15 |
10 files changed, 205 insertions, 0 deletions
diff --git a/test/Rewriter/rewrite-anonymous-union.m b/test/Rewriter/rewrite-anonymous-union.m new file mode 100644 index 0000000000000..579a06854fe63 --- /dev/null +++ b/test/Rewriter/rewrite-anonymous-union.m @@ -0,0 +1,30 @@ +// RUN: %clang_cc1 -rewrite-objc -o - %s +// rdar://6948022 + +typedef unsigned int uint32_t; + +typedef struct { + union { + uint32_t daysOfWeek; + uint32_t dayOfMonth; + }; + uint32_t nthOccurrence; +} OSPatternSpecificData; + +@interface NSNumber ++ (NSNumber *)numberWithLong:(long)value; +@end + +@interface OSRecurrence { + OSPatternSpecificData _pts; +} +- (void)_setTypeSpecificInfoOnRecord; +@end + +@implementation OSRecurrence +- (void)_setTypeSpecificInfoOnRecord +{ + [NSNumber numberWithLong:(_pts.dayOfMonth >= 31 ? -1 : _pts.dayOfMonth)]; +} +@end + diff --git a/test/Rewriter/rewrite-byref-vars.mm b/test/Rewriter/rewrite-byref-vars.mm new file mode 100644 index 0000000000000..581437b5a5df9 --- /dev/null +++ b/test/Rewriter/rewrite-byref-vars.mm @@ -0,0 +1,35 @@ +// RUN: %clang_cc1 -fms-extensions -rewrite-objc -x objective-c++ -fblocks -o - %s +// radar 7540194 + +extern "C" __declspec(dllexport) void BreakTheRewriter(int i) { + __block int aBlockVariable = 0; + void (^aBlock)(void) = ^ { + aBlockVariable = 42; + }; + aBlockVariable++; + if (i) { + __block int bbBlockVariable = 0; + void (^aBlock)(void) = ^ { + bbBlockVariable = 42; + }; + } +} + +__declspec(dllexport) extern "C" __declspec(dllexport) void XXXXBreakTheRewriter(void) { + + __block int aBlockVariable = 0; + void (^aBlock)(void) = ^ { + aBlockVariable = 42; + }; + aBlockVariable++; + void (^bBlocks)(void) = ^ { + aBlockVariable = 43; + }; + void (^c)(void) = ^ { + aBlockVariable = 44; + }; + +} + +// $CLANG -cc1 -fms-extensions -rewrite-objc -x objective-c++ -fblocks bug.mm +// g++ -c -D"__declspec(X)=" bug.cpp diff --git a/test/Rewriter/rewrite-eh.m b/test/Rewriter/rewrite-eh.m new file mode 100644 index 0000000000000..5bc80b55093ff --- /dev/null +++ b/test/Rewriter/rewrite-eh.m @@ -0,0 +1,20 @@ +// RUN: %clang_cc1 -rewrite-objc -o - %s +// rdar://7522880 + +@interface NSException +@end + +@interface Foo +@end + +@implementation Foo +- (void)bar { + @try { + } @catch (NSException *e) { + } + @catch (Foo *f) { + } + @catch (...) { + } +} +@end diff --git a/test/Rewriter/rewrite-foreach-7.m b/test/Rewriter/rewrite-foreach-7.m new file mode 100644 index 0000000000000..9fa6a1a9f01a3 --- /dev/null +++ b/test/Rewriter/rewrite-foreach-7.m @@ -0,0 +1,7 @@ +// RUN: %clang_cc1 -rewrite-objc %s -o - + +@class NSArray; +int main() { + NSArray *foo; + for (Class c in foo) { } +} diff --git a/test/Rewriter/rewrite-forward-class.m b/test/Rewriter/rewrite-forward-class.m new file mode 100644 index 0000000000000..5a50f53a480fe --- /dev/null +++ b/test/Rewriter/rewrite-forward-class.m @@ -0,0 +1,8 @@ +// RUN: %clang_cc1 -rewrite-objc -o - %s +// rdar://6969189 + +@class XX; +@class YY, ZZ, QQ; +@class ISyncClient, SMSession, ISyncManager, ISyncSession, SMDataclassInfo, SMClientInfo, + DMCConfiguration, DMCStatusEntry; + diff --git a/test/Rewriter/rewrite-function-decl.mm b/test/Rewriter/rewrite-function-decl.mm new file mode 100644 index 0000000000000..023e55db4bbb9 --- /dev/null +++ b/test/Rewriter/rewrite-function-decl.mm @@ -0,0 +1,31 @@ +// RUN: %clang_cc1 -fms-extensions -rewrite-objc -x objective-c++ -fblocks -o - %s + +extern "C" __declspec(dllexport) void BreakTheRewriter(void) { + __block int aBlockVariable = 0; + void (^aBlock)(void) = ^ { + aBlockVariable = 42; + }; + aBlockVariable++; + void (^bBlocks)(void) = ^ { + aBlockVariable = 43; + }; + void (^c)(void) = ^ { + aBlockVariable = 44; + }; + +} +__declspec(dllexport) extern "C" void AnotherBreakTheRewriter(int *p1, double d) { + + __block int bBlockVariable = 0; + void (^aBlock)(void) = ^ { + bBlockVariable = 42; + }; + bBlockVariable++; + void (^bBlocks)(void) = ^ { + bBlockVariable = 43; + }; + void (^c)(void) = ^ { + bBlockVariable = 44; + }; + +} diff --git a/test/Rewriter/rewrite-ivar-use.m b/test/Rewriter/rewrite-ivar-use.m new file mode 100644 index 0000000000000..82cff5b2d6335 --- /dev/null +++ b/test/Rewriter/rewrite-ivar-use.m @@ -0,0 +1,25 @@ +// RUN: %clang_cc1 -rewrite-objc -fms-extensions %s -o - +// radar 7490331 + +@interface Foo { + int a; + id b; +} +- (void)bar; +- (void)baz:(id)q; +@end + +@implementation Foo +// radar 7522803 +static void foo(id bar) { + int i = ((Foo *)bar)->a; +} + +- (void)bar { + a = 42; + [self baz:b]; +} +- (void)baz:(id)q { +} +@end + diff --git a/test/Rewriter/rewrite-trivial-constructor.mm b/test/Rewriter/rewrite-trivial-constructor.mm new file mode 100644 index 0000000000000..81c7d9b8a72ed --- /dev/null +++ b/test/Rewriter/rewrite-trivial-constructor.mm @@ -0,0 +1,21 @@ +// RUN: %clang_cc1 -fms-extensions -rewrite-objc -x objective-c++ -fblocks -o - %s +// radar 7537770 + +typedef struct { + int a; + int b; +} s; + +extern void CFBasicHashApply(int (^block)(s)) { + int used, cnt; + for (int idx = 0; 0 < used && idx < cnt; idx++) { + s bkt; + if (0 < bkt.a) { + if (!block(bkt)) { + return; + } + used--; + } + } +} + diff --git a/test/Rewriter/rewrite-weak-attr.m b/test/Rewriter/rewrite-weak-attr.m new file mode 100644 index 0000000000000..2e559ee3e3220 --- /dev/null +++ b/test/Rewriter/rewrite-weak-attr.m @@ -0,0 +1,13 @@ +// RUN: %clang_cc1 -triple i686-pc-win32 -fms-extensions -fblocks -Dnil=0 -rewrite-objc -o - %s +int main() { + __weak __block id foo = nil; + __block id foo2 = nil; + id foo3 = nil; + + void (^myblock)() = ^{ + foo = nil; + foo2 = nil; + [foo3 bar]; + id foo4 = foo3; + }; +} diff --git a/test/Rewriter/weak_byref_objects.m b/test/Rewriter/weak_byref_objects.m new file mode 100644 index 0000000000000..a0ebe88eaf16e --- /dev/null +++ b/test/Rewriter/weak_byref_objects.m @@ -0,0 +1,15 @@ +// RUN: %clang_cc1 -fblocks -triple i386-apple-darwin9 -fobjc-gc -rewrite-objc %s -o - + +#define nil 0 +int main() { + __weak __block id foo = nil; + __block id foo2 = nil; + id foo3 = nil; + + void (^myblock)() = ^{ + foo = nil; + foo2 = nil; + [foo3 bar]; + id foo4 = foo3; + }; +} |
