| 1 |
// UNSUPPORTED: target={{.*}}-aix{{.*}}, target={{.*}}-zos{{.*}} |
| 2 |
// RUN: rm -rf %t |
| 3 |
// RUN: split-file %s %t |
| 4 |
// RUN: %clang_cc1 -emit-llvm -o %t/test.bc -F%t/Frameworks %t/test.m -Werror=objc-method-access -DHIDDEN_FIRST=1 \ |
| 5 |
// RUN: -fmodules -fimplicit-module-maps -fmodules-cache-path=%t/modules.cache |
| 6 |
// RUN: %clang_cc1 -emit-llvm -o %t/test.bc -F%t/Frameworks %t/test.m -Werror=objc-method-access -DHIDDEN_FIRST=0 \ |
| 7 |
// RUN: -fmodules -fimplicit-module-maps -fmodules-cache-path=%t/modules.cache |
| 8 |
|
| 9 |
// Test a case when Objective-C protocol is imported both as hidden and as visible. |
| 10 |
|
| 11 |
//--- Frameworks/Foundation.framework/Headers/Foundation.h |
| 12 |
@interface NSObject |
| 13 |
@end |
| 14 |
|
| 15 |
//--- Frameworks/Foundation.framework/Modules/module.modulemap |
| 16 |
framework module Foundation { |
| 17 |
header "Foundation.h" |
| 18 |
export * |
| 19 |
} |
| 20 |
|
| 21 |
//--- Frameworks/Common.framework/Headers/Common.h |
| 22 |
#import <Foundation/Foundation.h> |
| 23 |
@protocol Testing; |
| 24 |
@interface Common : NSObject |
| 25 |
- (id<Testing>)getProtocolObj; |
| 26 |
@end |
| 27 |
|
| 28 |
//--- Frameworks/Common.framework/Modules/module.modulemap |
| 29 |
framework module Common { |
| 30 |
header "Common.h" |
| 31 |
export * |
| 32 |
} |
| 33 |
|
| 34 |
//--- Frameworks/Regular.framework/Headers/Regular.h |
| 35 |
@protocol Testing |
| 36 |
- (void)protocolMethod; |
| 37 |
@end |
| 38 |
|
| 39 |
//--- Frameworks/Regular.framework/Modules/module.modulemap |
| 40 |
framework module Regular { |
| 41 |
header "Regular.h" |
| 42 |
export * |
| 43 |
} |
| 44 |
|
| 45 |
//--- Frameworks/RegularHider.framework/Headers/Visible.h |
| 46 |
// Empty, file required to create a module. |
| 47 |
|
| 48 |
//--- Frameworks/RegularHider.framework/Headers/Hidden.h |
| 49 |
@protocol Testing |
| 50 |
- (void)protocolMethod; |
| 51 |
@end |
| 52 |
|
| 53 |
//--- Frameworks/RegularHider.framework/Modules/module.modulemap |
| 54 |
framework module RegularHider { |
| 55 |
header "Visible.h" |
| 56 |
export * |
| 57 |
|
| 58 |
explicit module Hidden { |
| 59 |
header "Hidden.h" |
| 60 |
export * |
| 61 |
} |
| 62 |
} |
| 63 |
|
| 64 |
//--- test.m |
| 65 |
#import <Common/Common.h> |
| 66 |
|
| 67 |
#if HIDDEN_FIRST |
| 68 |
#import <RegularHider/Visible.h> |
| 69 |
#import <Regular/Regular.h> |
| 70 |
#else |
| 71 |
#import <Regular/Regular.h> |
| 72 |
#import <RegularHider/Visible.h> |
| 73 |
#endif |
| 74 |
|
| 75 |
void test(Common *obj) { |
| 76 |
[[obj getProtocolObj] protocolMethod]; |
| 77 |
} |