llvm-project/clang/test/APINotes/swift-return-ownership.m
fahadnayyar 43e663d0fd
[APINotes] [NFC] Add tests for SWIFT_RETURNS_(UN)RETAINED for ObjC APIs (#122167)
Adding test case to verify that SwiftReturnOwnership works correctly for
ObjC functions and methods as well.

rdar://142504115
2025-01-09 09:42:24 -08:00

12 lines
791 B
Objective-C

// RUN: rm -rf %t && mkdir -p %t
// RUN: %clang_cc1 -fmodules -fblocks -fimplicit-module-maps -fmodules-cache-path=%t/ModulesCache -fdisable-module-hash -fapinotes-modules -fsyntax-only -I %S/Inputs/Headers %s
// RUN: %clang_cc1 -ast-print %t/ModulesCache/SwiftReturnOwnershipForObjC.pcm | FileCheck %s
#import <SwiftReturnOwnershipForObjC.h>
// CHECK: @interface MethodTest
// CHECK: - (struct RefCountedType *)getUnowned __attribute__((swift_attr("returns_unretained")));
// CHECK: - (struct RefCountedType *)getOwned __attribute__((swift_attr("returns_retained")));
// CHECK: @end
// CHECK: __attribute__((swift_attr("returns_unretained"))) struct RefCountedType *getObjCUnowned(void);
// CHECK: __attribute__((swift_attr("returns_retained"))) struct RefCountedType *getObjCOwned(void);