xref: /llvm-project/clang/test/Modules/merge-objc-interface-visibility.m (revision 7793e676514bc102e97a993e90257e8628069a8b)
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 -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 -DHIDDEN_FIRST=0 \
6// RUN:            -fmodules -fimplicit-module-maps -fmodules-cache-path=%t/modules.cache
7// UNSUPPORTED: target={{.*}}-zos{{.*}}, target={{.*}}-aix{{.*}}
8
9// Test a case when Objective-C interface 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
16framework module Foundation {
17  header "Foundation.h"
18  export *
19}
20
21//--- Frameworks/Regular.framework/Headers/Regular.h
22#import <Foundation/Foundation.h>
23@interface Regular : NSObject
24@end
25
26//--- Frameworks/Regular.framework/Modules/module.modulemap
27framework module Regular {
28  header "Regular.h"
29  export *
30}
31
32//--- Frameworks/RegularHider.framework/Headers/Visible.h
33// Empty, file required to create a module.
34
35//--- Frameworks/RegularHider.framework/Headers/Hidden.h
36#import <Foundation/Foundation.h>
37@interface Regular : NSObject
38@end
39
40//--- Frameworks/RegularHider.framework/Modules/module.modulemap
41framework module RegularHider {
42  header "Visible.h"
43  export *
44
45  explicit module Hidden {
46    header "Hidden.h"
47    export *
48  }
49}
50
51//--- test.m
52
53#if HIDDEN_FIRST
54#import <RegularHider/Visible.h>
55#import <Regular/Regular.h>
56#else
57#import <Regular/Regular.h>
58#import <RegularHider/Visible.h>
59#endif
60
61@interface SubClass : Regular
62@end
63