107 lines · plain
1// UNSUPPORTED: target={{.*}}-zos{{.*}}, target={{.*}}-aix{{.*}}2// RUN: rm -rf %t3// RUN: split-file %s %t4// RUN: %clang_cc1 -emit-llvm -o %t/test.bc -F%t/Frameworks %t/test.m \5// RUN: -fmodules -fimplicit-module-maps -fmodules-cache-path=%t/modules.cache6// RUN: %clang_cc1 -emit-llvm -o %t/test.bc -F%t/Frameworks %t/test-functions.m \7// RUN: -fmodules -fimplicit-module-maps -fmodules-cache-path=%t/modules.cache8 9// Test a case when Objective-C interface ivars are present in two different modules.10 11//--- Frameworks/Foundation.framework/Headers/Foundation.h12@interface NSObject13@end14 15//--- Frameworks/Foundation.framework/Modules/module.modulemap16framework module Foundation {17 header "Foundation.h"18 export *19}20 21//--- Frameworks/ObjCInterface.framework/Headers/ObjCInterface.h22#import <Foundation/Foundation.h>23@interface ObjCInterface : NSObject {24@public25 id _item;26}27@end28 29@interface WithBitFields : NSObject {30@public31 int x: 3;32 int y: 4;33}34@end35 36//--- Frameworks/ObjCInterface.framework/Modules/module.modulemap37framework module ObjCInterface {38 header "ObjCInterface.h"39 export *40}41 42//--- Frameworks/ObjCInterfaceCopy.framework/Headers/ObjCInterfaceCopy.h43#import <Foundation/Foundation.h>44@interface ObjCInterface : NSObject {45@public46 id _item;47}48@end49 50@interface WithBitFields : NSObject {51@public52 int x: 3;53 int y: 4;54}55@end56 57// Inlined function present only in Copy.framework to make sure it uses decls from Copy module.58__attribute__((always_inline)) void inlinedIVarAccessor(ObjCInterface *obj, WithBitFields *bitFields) {59 obj->_item = 0;60 bitFields->x = 0;61}62 63//--- Frameworks/ObjCInterfaceCopy.framework/Modules/module.modulemap64framework module ObjCInterfaceCopy {65 header "ObjCInterfaceCopy.h"66 export *67}68 69//--- test.m70#import <ObjCInterface/ObjCInterface.h>71#import <ObjCInterfaceCopy/ObjCInterfaceCopy.h>72 73@implementation ObjCInterface74- (void)test:(id)item {75 _item = item;76}77@end78 79@implementation WithBitFields80- (void)reset {81 x = 0;82 y = 0;83}84@end85 86//--- test-functions.m87#import <ObjCInterface/ObjCInterface.h>88 89void testAccessIVar(ObjCInterface *obj, id item) {90 obj->_item = item;91}92void testAccessBitField(WithBitFields *obj) {93 obj->x = 0;94}95 96#import <ObjCInterfaceCopy/ObjCInterfaceCopy.h>97 98void testAccessIVarLater(ObjCInterface *obj, id item) {99 obj->_item = item;100}101void testAccessBitFieldLater(WithBitFields *obj) {102 obj->y = 0;103}104void testInlinedFunction(ObjCInterface *obj, WithBitFields *bitFields) {105 inlinedIVarAccessor(obj, bitFields);106}107