2012-02-16 08:57:37 +08:00
|
|
|
// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -emit-llvm -fobjc-arc -fblocks -fexceptions -fobjc-exceptions -O2 -disable-llvm-optzns -o - %s | FileCheck %s
|
2013-09-04 12:12:25 +08:00
|
|
|
// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -emit-llvm -fobjc-arc -fblocks -fexceptions -fobjc-exceptions -disable-llvm-optzns -o - %s | FileCheck -check-prefix=NO-METADATA %s
|
2012-02-16 08:57:37 +08:00
|
|
|
// 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
|
|
|
|
|
|
|
|
// The front-end should emit clang.arc.no_objc_arc_exceptions in -fobjc-arc-exceptions
|
|
|
|
// mode when optimization is enabled, and not otherwise.
|
|
|
|
|
|
|
|
void thrower(void);
|
|
|
|
void not(void) __attribute__((nothrow));
|
|
|
|
|
2013-08-15 14:47:53 +08:00
|
|
|
// CHECK-LABEL: define void @test0(
|
2013-02-23 05:12:51 +08:00
|
|
|
// CHECK: call void @thrower(), !clang.arc.no_objc_arc_exceptions !
|
2013-02-22 17:10:20 +08:00
|
|
|
// CHECK: call void @not() [[NUW:#[0-9]+]], !clang.arc.no_objc_arc_exceptions !
|
2013-08-15 14:47:53 +08:00
|
|
|
// NO-METADATA-LABEL: define void @test0(
|
2012-02-16 08:57:37 +08:00
|
|
|
// NO-METADATA-NOT: !clang.arc.no_objc_arc_exceptions
|
|
|
|
// NO-METADATA: }
|
|
|
|
void test0(void) {
|
|
|
|
thrower();
|
|
|
|
not();
|
|
|
|
}
|
|
|
|
|
2013-08-15 14:47:53 +08:00
|
|
|
// CHECK-LABEL: define void @test1(
|
2013-02-23 05:12:51 +08:00
|
|
|
// CHECK: call void @thrower(), !clang.arc.no_objc_arc_exceptions !
|
2013-02-22 17:10:20 +08:00
|
|
|
// CHECK: call void @not() [[NUW]], !clang.arc.no_objc_arc_exceptions !
|
2013-08-15 14:47:53 +08:00
|
|
|
// NO-METADATA-LABEL: define void @test1(
|
2012-02-16 08:57:37 +08:00
|
|
|
// NO-METADATA-NOT: !clang.arc.no_objc_arc_exceptions
|
|
|
|
// NO-METADATA: }
|
|
|
|
void test1(id x) {
|
|
|
|
id y = x;
|
|
|
|
thrower();
|
|
|
|
not();
|
|
|
|
}
|
|
|
|
|
|
|
|
void NSLog(id, ...);
|
|
|
|
|
2013-08-15 14:47:53 +08:00
|
|
|
// CHECK-LABEL: define void @test2(
|
2015-04-25 03:33:25 +08:00
|
|
|
// CHECK: invoke void (i8*, ...) @NSLog(i8* bitcast (%struct.NSConstantString* @_unnamed_cfstring_ to i8*), i32* %{{.*}})
|
2012-02-17 02:51:05 +08:00
|
|
|
// CHECK: to label %{{.*}} unwind label %{{.*}}, !clang.arc.no_objc_arc_exceptions !
|
2013-08-15 14:47:53 +08:00
|
|
|
// NO-METADATA-LABEL: define void @test2(
|
2012-02-16 08:57:37 +08:00
|
|
|
// NO-METADATA-NOT: !clang.arc.no_objc_arc_exceptions
|
|
|
|
// NO-METADATA: }
|
|
|
|
void test2(void) {
|
|
|
|
@autoreleasepool {
|
|
|
|
__attribute__((__blocks__(byref))) int x;
|
|
|
|
NSLog(@"Address of x outside of block: %p", &x);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-08-15 14:47:53 +08:00
|
|
|
// CHECK-LABEL: define void @test3(
|
2012-02-17 02:51:05 +08:00
|
|
|
// CHECK: invoke void %{{.*}}(i8* %{{.*}})
|
|
|
|
// CHECK: to label %{{.*}} unwind label %{{.*}}, !clang.arc.no_objc_arc_exceptions !
|
2013-08-15 14:47:53 +08:00
|
|
|
// NO-METADATA-LABEL: define void @test3(
|
2012-02-16 08:57:37 +08:00
|
|
|
// NO-METADATA-NOT: !clang.arc.no_objc_arc_exceptions
|
|
|
|
// NO-METADATA: }
|
|
|
|
void test3(void) {
|
|
|
|
@autoreleasepool {
|
|
|
|
__attribute__((__blocks__(byref))) int x;
|
|
|
|
^{
|
|
|
|
NSLog(@"Address of x in non-assigned block: %p", &x);
|
|
|
|
}();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-08-15 14:47:53 +08:00
|
|
|
// CHECK-LABEL: define void @test4(
|
2012-02-17 02:51:05 +08:00
|
|
|
// CHECK: invoke void %{{.*}}(i8* %{{.*}})
|
|
|
|
// CHECK: to label %{{.*}} unwind label %{{.*}}, !clang.arc.no_objc_arc_exceptions !
|
2013-08-15 14:47:53 +08:00
|
|
|
// NO-METADATA-LABEL: define void @test4(
|
2012-02-16 08:57:37 +08:00
|
|
|
// NO-METADATA-NOT: !clang.arc.no_objc_arc_exceptions
|
|
|
|
// NO-METADATA: }
|
|
|
|
void test4(void) {
|
|
|
|
@autoreleasepool {
|
|
|
|
__attribute__((__blocks__(byref))) int x;
|
|
|
|
void (^b)(void) = ^{
|
|
|
|
NSLog(@"Address of x in assigned block: %p", &x);
|
|
|
|
};
|
|
|
|
b();
|
|
|
|
}
|
|
|
|
}
|
2013-02-22 17:10:20 +08:00
|
|
|
|
2013-02-23 05:12:51 +08:00
|
|
|
// CHECK: attributes [[NUW]] = { nounwind }
|