llvm-project/clang/test/SemaObjC/disable-direct-method.m
Erik Pilkington b660abc80d [ObjC] Add a command line flag that disables recognition of objc_direct for testability
Programmers would like to be able to test direct methods by calling them from a
different linkage unit or mocking them, both of which are impossible. This
patch adds a flag that effectively disables the attribute, which will fix this
when enabled in testable builds. rdar://71190891

Differential revision: https://reviews.llvm.org/D95845
2021-04-06 11:17:01 -04:00

33 lines
596 B
Objective-C

// RUN: %clang_cc1 -verify -fobjc-disable-direct-methods-for-testing %s
// expected-no-diagnostics
#define DIRECT __attribute__((objc_direct))
#define DIRECT_MEMBERS __attribute__((objc_direct_members))
__attribute__((objc_root_class))
@interface X
-(void)direct_method DIRECT;
@end
@implementation X
-(void)direct_method DIRECT {}
@end
__attribute__((objc_root_class))
DIRECT_MEMBERS
@interface Y
-(void)direct_method2;
@end
@implementation Y
-(void)direct_method2 {}
@end
__attribute__((objc_root_class))
@interface Z
@property (direct) int direct_property;
@end
@implementation Z @end