1// RUN: rm -rf %t 2// RUN: split-file %s %t 3 4// Test that different values of `ObjCMethodDecl::isOverriding` in different modules 5// is not an error because it depends on the surrounding code and not on the method itself. 6// RUN: %clang_cc1 -fsyntax-only -verify -I%t/include -fmodules -fimplicit-module-maps -fmodules-cache-path=%t/modules.cache -fmodule-name=Override %t/test-overriding.m 7 8// Test that different values of `ObjCMethodDecl::isPropertyAccessor` in different modules 9// is not an error because it depends on the surrounding code and not on the method itself. 10// RUN: %clang_cc1 -fsyntax-only -verify -I%t/include -fmodules -fimplicit-module-maps -fmodules-cache-path=%t/modules.cache -fmodule-name=PropertyAccessor %t/test-property_accessor.m 11 12//--- include/Common.h 13@interface NSObject 14@end 15 16//--- include/Indirection.h 17#import <Override.h> 18#import <PropertyAccessor.h> 19 20//--- include/module.modulemap 21module Common { 22 header "Common.h" 23 export * 24} 25module Indirection { 26 header "Indirection.h" 27 export * 28} 29module Override { 30 header "Override.h" 31 export * 32} 33module PropertyAccessor { 34 header "PropertyAccessor.h" 35 export * 36} 37 38//--- include/Override.h 39#import <Common.h> 40@interface SubClass: NSObject 41- (void)potentialOverride; 42@end 43 44//--- Override_Internal.h 45#import <Common.h> 46@interface NSObject(InternalCategory) 47- (void)potentialOverride; 48@end 49 50//--- test-overriding.m 51//expected-no-diagnostics 52// Get non-modular version of `SubClass`, so that `-[SubClass potentialOverride]` 53// is an override of a method in `InternalCategory`. 54#import "Override_Internal.h" 55#import <Override.h> 56 57// Get modular version of `SubClass` where `-[SubClass potentialOverride]` is 58// not an override because module "Override" doesn't know about Override_Internal.h. 59#import <Indirection.h> 60 61void triggerOverrideCheck(SubClass *sc) { 62 [sc potentialOverride]; 63} 64 65//--- include/PropertyAccessor.h 66#import <Common.h> 67@interface PropertySubClass: NSObject 68- (int)potentialProperty; 69- (void)setPotentialProperty:(int)p; 70@end 71 72//--- PropertyAccessor_Internal.h 73#import <PropertyAccessor.h> 74@interface PropertySubClass() 75@property int potentialProperty; 76@end 77 78//--- test-property_accessor.m 79//expected-no-diagnostics 80// Get a version of `PropertySubClass` where `-[PropertySubClass potentialProperty]` 81// is a property accessor. 82#import "PropertyAccessor_Internal.h" 83 84// Get a version of `PropertySubClass` where `-[PropertySubClass potentialProperty]` 85// is not a property accessor because module "PropertyAccessor" doesn't know about PropertyAccessor_Internal.h. 86#import <Indirection.h> 87 88void triggerPropertyAccessorCheck(PropertySubClass *x) { 89 int tmp = [x potentialProperty]; 90 [x setPotentialProperty: tmp]; 91} 92