• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -emit-llvm -fobjc-arc -fobjc-runtime=macosx-10.7 -fexceptions -fobjc-exceptions -o - %s | FileCheck %s
2// RUN: %clang_cc1 -triple x86_64-apple-darwin11 -emit-llvm -fobjc-runtime=macosx-10.7 -fexceptions -fobjc-exceptions -o - %s | FileCheck %s
3// rdar://8881826
4// rdar://9412038
5
6@interface I
7{
8  id ivar;
9}
10- (id) Meth;
11+ (id) MyAlloc;;
12@end
13
14@implementation I
15- (id) Meth {
16   @autoreleasepool {
17      id p = [I MyAlloc];
18      if (!p)
19        return ivar;
20   }
21  return 0;
22}
23+ (id) MyAlloc {
24    return 0;
25}
26@end
27
28// CHECK: call i8* @objc_autoreleasePoolPush
29// CHECK: [[T:%.*]] = load i8*, i8** [[A:%.*]]
30// CHECK: call void @objc_autoreleasePoolPop
31
32// rdar://13660038
33int tryTo(int (*f)(void)) {
34  @try {
35    @autoreleasepool {
36      return f();
37    }
38  } @catch (...) {
39    return 0;
40  }
41}
42// CHECK-LABEL:    define i32 @tryTo(i32 ()*
43// CHECK:      [[RET:%.*]] = alloca i32,
44// CHECK:      [[T0:%.*]] = call i8* @objc_autoreleasePoolPush()
45// CHECK-NEXT: [[T1:%.*]] = load i32 ()*, i32 ()** {{%.*}},
46// CHECK-NEXT: [[T2:%.*]] = invoke i32 [[T1]]()
47// CHECK:      store i32 [[T2]], i32* [[RET]]
48// CHECK:      invoke void @objc_autoreleasePoolPop(i8* [[T0]])
49// CHECK:      landingpad { i8*, i32 }
50// CHECK-NEXT:   catch i8* null
51// CHECK:      call i8* @objc_begin_catch
52// CHECK-NEXT: store i32 0, i32* [[RET]]
53// CHECK:      call void @objc_end_catch()
54