1// RUN: %clang_cc1 -fsanitize=nullability-return -emit-llvm %s -o - -triple x86_64-apple-macosx10.10.0 | FileCheck %s
2
3// CHECK: [[ATTR_LOC:@[0-9]+]] = {{.*}} global { {{.*}} i32 15, i32 38
4
5// CHECK-LABEL: define{{.*}} i8* @_Z3foov()
6// CHECK: [[CALL:%.*]] = call i8* @_Z6helperv()
7// CHECK: icmp ne i8* [[CALL]]
8// CHECK: call void @__ubsan_handle_nullability_return_v1_abort({{.*}}[[ATTR_LOC]]
9
10struct S {
11  using PtrTy = id;
12};
13
14#pragma clang assume_nonnull begin
15__attribute__((ns_returns_retained)) S::PtrTy foo(void) {
16  extern S::PtrTy helper(void);
17  return helper();
18}
19#pragma clang assume_nonnull end
20