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