1*f4a2713aSLionel Sambuc// RUN: %clang_cc1 -triple x86_64-apple-darwin11 -emit-llvm -fobjc-arc -o - %s | FileCheck %s 2*f4a2713aSLionel Sambuc 3*f4a2713aSLionel Sambucid makeObject1() __attribute__((ns_returns_retained)); 4*f4a2713aSLionel Sambucid makeObject2() __attribute__((ns_returns_retained)); 5*f4a2713aSLionel Sambucvoid releaseObject(__attribute__((ns_consumed)) id); 6*f4a2713aSLionel Sambuc 7*f4a2713aSLionel Sambuc// CHECK-LABEL: define void @_Z10sanityTestv 8*f4a2713aSLionel Sambucvoid sanityTest() { 9*f4a2713aSLionel Sambuc // CHECK: [[X:%.*]] = alloca i8*, align 8 10*f4a2713aSLionel Sambuc // CHECK-NEXT: [[OBJ1:%.*]] = call i8* @_Z11makeObject1v() 11*f4a2713aSLionel Sambuc // CHECK-NEXT: store i8* [[OBJ1]], i8** [[X]], align 8 12*f4a2713aSLionel Sambuc id x = makeObject1(); 13*f4a2713aSLionel Sambuc 14*f4a2713aSLionel Sambuc // CHECK-NEXT: [[OBJ2:%.*]] = call i8* @_Z11makeObject2v() 15*f4a2713aSLionel Sambuc // CHECK-NEXT: call void @_Z13releaseObjectP11objc_object(i8* [[OBJ2]]) 16*f4a2713aSLionel Sambuc releaseObject(makeObject2()); 17*f4a2713aSLionel Sambuc 18*f4a2713aSLionel Sambuc // CHECK-NEXT: call void @objc_storeStrong(i8** [[X]], i8* null) 19*f4a2713aSLionel Sambuc // CHECK-NEXT: ret void 20*f4a2713aSLionel Sambuc} 21*f4a2713aSLionel Sambuc 22*f4a2713aSLionel Sambuc 23*f4a2713aSLionel Sambuctemplate <typename T> 24*f4a2713aSLionel SambucT makeObjectT1() __attribute__((ns_returns_retained)); 25*f4a2713aSLionel Sambuctemplate <typename T> 26*f4a2713aSLionel SambucT makeObjectT2() __attribute__((ns_returns_retained)); 27*f4a2713aSLionel Sambuc 28*f4a2713aSLionel Sambuctemplate <typename T> 29*f4a2713aSLionel Sambucvoid releaseObjectT(__attribute__((ns_consumed)) T); 30*f4a2713aSLionel Sambuc 31*f4a2713aSLionel Sambuc// CHECK-LABEL: define void @_Z12templateTestv 32*f4a2713aSLionel Sambucvoid templateTest() { 33*f4a2713aSLionel Sambuc // CHECK: [[X:%.*]] = alloca i8*, align 8 34*f4a2713aSLionel Sambuc // CHECK-NEXT: [[OBJ1:%.*]] = call i8* @_Z12makeObjectT1IU8__strongP11objc_objectET_v() 35*f4a2713aSLionel Sambuc // CHECK-NEXT: store i8* [[OBJ1]], i8** [[X]], align 8 36*f4a2713aSLionel Sambuc id x = makeObjectT1<id>(); 37*f4a2713aSLionel Sambuc 38*f4a2713aSLionel Sambuc // CHECK-NEXT: [[OBJ2:%.*]] = call i8* @_Z12makeObjectT2IU8__strongP11objc_objectET_v() 39*f4a2713aSLionel Sambuc // CHECK-NEXT: call void @_Z13releaseObjectP11objc_object(i8* [[OBJ2]]) 40*f4a2713aSLionel Sambuc releaseObject(makeObjectT2<id>()); 41*f4a2713aSLionel Sambuc 42*f4a2713aSLionel Sambuc // CHECK-NEXT: [[OBJ3:%.*]] = call i8* @_Z11makeObject1v() 43*f4a2713aSLionel Sambuc // CHECK-NEXT: call void @_Z14releaseObjectTIU8__strongP11objc_objectEvT_(i8* [[OBJ3]]) 44*f4a2713aSLionel Sambuc releaseObjectT(makeObject1()); 45*f4a2713aSLionel Sambuc 46*f4a2713aSLionel Sambuc // CHECK-NEXT: call void @objc_storeStrong(i8** [[X]], i8* null) 47*f4a2713aSLionel Sambuc // CHECK-NEXT: ret void 48*f4a2713aSLionel Sambuc} 49