Dan Gohman | b49bd27 | 2012-02-16 00:57:37 +0000 | [diff] [blame] | 1 | // RUN: %clang_cc1 -triple x86_64-apple-darwin10 -emit-llvm -fobjc-arc -fblocks -fexceptions -fobjc-exceptions -O2 -disable-llvm-optzns -o - %s | FileCheck %s |
| 2 | // RUN: %clang_cc1 -triple x86_64-apple-darwin10 -emit-llvm -fobjc-arc -fblocks -fexceptions -fobjc-exceptions -O0 -disable-llvm-optzns -o - %s | FileCheck -check-prefix=NO-METADATA %s |
| 3 | // RUN: %clang_cc1 -triple x86_64-apple-darwin10 -emit-llvm -fobjc-arc -fblocks -fexceptions -fobjc-exceptions -O2 -disable-llvm-optzns -o - %s -fobjc-arc-exceptions | FileCheck -check-prefix=NO-METADATA %s |
| 4 | |
NAKAMURA Takumi | b1612cb | 2012-02-16 08:12:12 +0000 | [diff] [blame] | 5 | // FIXME: This test is -Asserts-intolerant. |
| 6 | // REQUIRES: asserts |
| 7 | |
Dan Gohman | b49bd27 | 2012-02-16 00:57:37 +0000 | [diff] [blame] | 8 | // The front-end should emit clang.arc.no_objc_arc_exceptions in -fobjc-arc-exceptions |
| 9 | // mode when optimization is enabled, and not otherwise. |
| 10 | |
| 11 | void thrower(void); |
| 12 | void not(void) __attribute__((nothrow)); |
| 13 | |
| 14 | // CHECK: define void @test0( |
Chad Rosier | 348ab1a | 2012-02-16 01:56:55 +0000 | [diff] [blame] | 15 | // CHECK: call void @thrower(), !clang.arc.no_objc_arc_exceptions !4 |
| 16 | // CHECK: call void @not() nounwind, !clang.arc.no_objc_arc_exceptions !4 |
Dan Gohman | b49bd27 | 2012-02-16 00:57:37 +0000 | [diff] [blame] | 17 | // NO-METADATA: define void @test0( |
| 18 | // NO-METADATA-NOT: !clang.arc.no_objc_arc_exceptions |
| 19 | // NO-METADATA: } |
| 20 | void test0(void) { |
| 21 | thrower(); |
| 22 | not(); |
| 23 | } |
| 24 | |
| 25 | // CHECK: define void @test1( |
Chad Rosier | 348ab1a | 2012-02-16 01:56:55 +0000 | [diff] [blame] | 26 | // CHECK: call void @thrower(), !clang.arc.no_objc_arc_exceptions !4 |
| 27 | // CHECK: call void @not() nounwind, !clang.arc.no_objc_arc_exceptions !4 |
Dan Gohman | b49bd27 | 2012-02-16 00:57:37 +0000 | [diff] [blame] | 28 | // NO-METADATA: define void @test1( |
| 29 | // NO-METADATA-NOT: !clang.arc.no_objc_arc_exceptions |
| 30 | // NO-METADATA: } |
| 31 | void test1(id x) { |
| 32 | id y = x; |
| 33 | thrower(); |
| 34 | not(); |
| 35 | } |
| 36 | |
| 37 | void NSLog(id, ...); |
| 38 | |
| 39 | // CHECK: define void @test2( |
| 40 | // CHECK: invoke void (i8*, ...)* @NSLog(i8* bitcast (%struct.NSConstantString* @_unnamed_cfstring_ to i8*), i32* %x2) |
Chad Rosier | 348ab1a | 2012-02-16 01:56:55 +0000 | [diff] [blame] | 41 | // CHECK: to label %invoke.cont unwind label %lpad, !clang.arc.no_objc_arc_exceptions !4 |
Dan Gohman | b49bd27 | 2012-02-16 00:57:37 +0000 | [diff] [blame] | 42 | // NO-METADATA: define void @test2( |
| 43 | // NO-METADATA-NOT: !clang.arc.no_objc_arc_exceptions |
| 44 | // NO-METADATA: } |
| 45 | void test2(void) { |
| 46 | @autoreleasepool { |
| 47 | __attribute__((__blocks__(byref))) int x; |
| 48 | NSLog(@"Address of x outside of block: %p", &x); |
| 49 | } |
| 50 | } |
| 51 | |
| 52 | // CHECK: define void @test3( |
| 53 | // CHECK: invoke void %9(i8* %7) |
Chad Rosier | 348ab1a | 2012-02-16 01:56:55 +0000 | [diff] [blame] | 54 | // CHECK: to label %invoke.cont unwind label %lpad, !clang.arc.no_objc_arc_exceptions !4 |
Dan Gohman | b49bd27 | 2012-02-16 00:57:37 +0000 | [diff] [blame] | 55 | // NO-METADATA: define void @test3( |
| 56 | // NO-METADATA-NOT: !clang.arc.no_objc_arc_exceptions |
| 57 | // NO-METADATA: } |
| 58 | void test3(void) { |
| 59 | @autoreleasepool { |
| 60 | __attribute__((__blocks__(byref))) int x; |
| 61 | ^{ |
| 62 | NSLog(@"Address of x in non-assigned block: %p", &x); |
| 63 | }(); |
| 64 | } |
| 65 | } |
| 66 | |
| 67 | // CHECK: define void @test4( |
| 68 | // CHECK: invoke void %13(i8* %11) |
Chad Rosier | 348ab1a | 2012-02-16 01:56:55 +0000 | [diff] [blame] | 69 | // CHECK: to label %invoke.cont unwind label %lpad, !clang.arc.no_objc_arc_exceptions !4 |
Dan Gohman | b49bd27 | 2012-02-16 00:57:37 +0000 | [diff] [blame] | 70 | // NO-METADATA: define void @test4( |
| 71 | // NO-METADATA-NOT: !clang.arc.no_objc_arc_exceptions |
| 72 | // NO-METADATA: } |
| 73 | void test4(void) { |
| 74 | @autoreleasepool { |
| 75 | __attribute__((__blocks__(byref))) int x; |
| 76 | void (^b)(void) = ^{ |
| 77 | NSLog(@"Address of x in assigned block: %p", &x); |
| 78 | }; |
| 79 | b(); |
| 80 | } |
| 81 | } |