1// RUN: %clang_cc1 -triple x86_64-apple-darwin -fobjc-runtime=macosx-fragile-10.8 -emit-llvm -fexceptions -fobjc-exceptions -o - %s | FileCheck %s -check-prefix=CHECK-WITH
2// RUN: %clang_cc1 -triple x86_64-apple-darwin -fobjc-runtime=macosx-fragile-10.7 -emit-llvm -fexceptions -fobjc-exceptions -o - %s | FileCheck %s -check-prefix=CHECK-WITHOUT
3
4void destroy(void**);
5
6// rdar://problem/9519113
7void test0(void) {
8  void test0_helper(void);
9  void *ptr __attribute__((cleanup(destroy)));
10  test0_helper();
11
12  // CHECK-WITH-LABEL:       define void @test0()
13  // CHECK-WITH-SAME:    personality i8* bitcast (i32 (...)* @__gcc_personality_v0 to i8*)
14  // CHECK-WITH:         [[PTR:%.*]] = alloca i8*,
15  // CHECK-WITH:         call void @destroy(i8** [[PTR]])
16  // CHECK-WITH-NEXT:    ret void
17  // CHECK-WITH:         invoke void @destroy(i8** [[PTR]])
18  // CHECK-WITH:         landingpad { i8*, i32 }
19  // CHECK-WITH-NEXT:      catch i8* null
20  // CHECK-WITH-NEXT:    call void @objc_terminate()
21
22  // CHECK-WITHOUT-LABEL:    define void @test0()
23  // CHECK-WITHOUT-SAME: personality i8* bitcast (i32 (...)* @__gcc_personality_v0 to i8*)
24  // CHECK-WITHOUT:      [[PTR:%.*]] = alloca i8*,
25  // CHECK-WITHOUT:      call void @destroy(i8** [[PTR]])
26  // CHECK-WITHOUT-NEXT: ret void
27  // CHECK-WITHOUT:      invoke void @destroy(i8** [[PTR]])
28  // CHECK-WITHOUT:      landingpad { i8*, i32 }
29  // CHECK-WITHOUT-NEXT:   catch i8* null
30  // CHECK-WITHOUT-NEXT: call void @abort()
31}
32