File: compare-objc-nonisolated-methods.m

package info (click to toggle)
llvm-toolchain-17 1%3A17.0.6-22
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,799,624 kB
  • sloc: cpp: 6,428,607; ansic: 1,383,196; asm: 793,408; python: 223,504; objc: 75,364; f90: 60,502; lisp: 33,869; pascal: 15,282; sh: 9,684; perl: 7,453; ml: 4,937; awk: 3,523; makefile: 2,889; javascript: 2,149; xml: 888; fortran: 619; cs: 573
file content (91 lines) | stat: -rw-r--r-- 2,716 bytes parent folder | download | duplicates (10)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
// RUN: rm -rf %t
// RUN: split-file %s %t

// Test that different values of `ObjCMethodDecl::isOverriding` in different modules
// is not an error because it depends on the surrounding code and not on the method itself.
// 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

// Test that different values of `ObjCMethodDecl::isPropertyAccessor` in different modules
// is not an error because it depends on the surrounding code and not on the method itself.
// 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

//--- include/Common.h
@interface NSObject
@end

//--- include/Indirection.h
#import <Override.h>
#import <PropertyAccessor.h>

//--- include/module.modulemap
module Common {
  header "Common.h"
  export *
}
module Indirection {
  header "Indirection.h"
  export *
}
module Override {
  header "Override.h"
  export *
}
module PropertyAccessor {
  header "PropertyAccessor.h"
  export *
}

//--- include/Override.h
#import <Common.h>
@interface SubClass: NSObject
- (void)potentialOverride;
@end

//--- Override_Internal.h
#import <Common.h>
@interface NSObject(InternalCategory)
- (void)potentialOverride;
@end

//--- test-overriding.m
//expected-no-diagnostics
// Get non-modular version of `SubClass`, so that `-[SubClass potentialOverride]`
// is an override of a method in `InternalCategory`.
#import "Override_Internal.h"
#import <Override.h>

// Get modular version of `SubClass` where `-[SubClass potentialOverride]` is
// not an override because module "Override" doesn't know about Override_Internal.h.
#import <Indirection.h>

void triggerOverrideCheck(SubClass *sc) {
  [sc potentialOverride];
}

//--- include/PropertyAccessor.h
#import <Common.h>
@interface PropertySubClass: NSObject
- (int)potentialProperty;
- (void)setPotentialProperty:(int)p;
@end

//--- PropertyAccessor_Internal.h
#import <PropertyAccessor.h>
@interface PropertySubClass()
@property int potentialProperty;
@end

//--- test-property_accessor.m
//expected-no-diagnostics
// Get a version of `PropertySubClass` where `-[PropertySubClass potentialProperty]`
// is a property accessor.
#import "PropertyAccessor_Internal.h"

// Get a version of `PropertySubClass` where `-[PropertySubClass potentialProperty]`
// is not a property accessor because module "PropertyAccessor" doesn't know about PropertyAccessor_Internal.h.
#import <Indirection.h>

void triggerPropertyAccessorCheck(PropertySubClass *x) {
  int tmp = [x potentialProperty];
  [x setPotentialProperty: tmp];
}