blob: 3517584e79a78fbe5368243019f77021dffcc9db [file] [log] [blame]
Dan Gohmanb49bd272012-02-16 00:57:37 +00001// 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 Takumib1612cb2012-02-16 08:12:12 +00005// FIXME: This test is -Asserts-intolerant.
6// REQUIRES: asserts
7
Dan Gohmanb49bd272012-02-16 00:57:37 +00008// 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
11void thrower(void);
12void not(void) __attribute__((nothrow));
13
14// CHECK: define void @test0(
Chad Rosier348ab1a2012-02-16 01:56:55 +000015// 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 Gohmanb49bd272012-02-16 00:57:37 +000017// NO-METADATA: define void @test0(
18// NO-METADATA-NOT: !clang.arc.no_objc_arc_exceptions
19// NO-METADATA: }
20void test0(void) {
21 thrower();
22 not();
23}
24
25// CHECK: define void @test1(
Chad Rosier348ab1a2012-02-16 01:56:55 +000026// 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 Gohmanb49bd272012-02-16 00:57:37 +000028// NO-METADATA: define void @test1(
29// NO-METADATA-NOT: !clang.arc.no_objc_arc_exceptions
30// NO-METADATA: }
31void test1(id x) {
32 id y = x;
33 thrower();
34 not();
35}
36
37void 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 Rosier348ab1a2012-02-16 01:56:55 +000041// CHECK: to label %invoke.cont unwind label %lpad, !clang.arc.no_objc_arc_exceptions !4
Dan Gohmanb49bd272012-02-16 00:57:37 +000042// NO-METADATA: define void @test2(
43// NO-METADATA-NOT: !clang.arc.no_objc_arc_exceptions
44// NO-METADATA: }
45void 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 Rosier348ab1a2012-02-16 01:56:55 +000054// CHECK: to label %invoke.cont unwind label %lpad, !clang.arc.no_objc_arc_exceptions !4
Dan Gohmanb49bd272012-02-16 00:57:37 +000055// NO-METADATA: define void @test3(
56// NO-METADATA-NOT: !clang.arc.no_objc_arc_exceptions
57// NO-METADATA: }
58void 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 Rosier348ab1a2012-02-16 01:56:55 +000069// CHECK: to label %invoke.cont unwind label %lpad, !clang.arc.no_objc_arc_exceptions !4
Dan Gohmanb49bd272012-02-16 00:57:37 +000070// NO-METADATA: define void @test4(
71// NO-METADATA-NOT: !clang.arc.no_objc_arc_exceptions
72// NO-METADATA: }
73void 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}