File: ObjCPropertySynthesize.m

package info (click to toggle)
swiftlang 6.0.3-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 2,519,992 kB
  • sloc: cpp: 9,107,863; ansic: 2,040,022; asm: 1,135,751; python: 296,500; objc: 82,456; f90: 60,502; lisp: 34,951; pascal: 19,946; sh: 18,133; perl: 7,482; ml: 4,937; javascript: 4,117; makefile: 3,840; awk: 3,535; xml: 914; fortran: 619; cs: 573; ruby: 573
file content (112 lines) | stat: -rw-r--r-- 5,099 bytes parent folder | download
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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
// XFAIL: *
// TODO: Remove or cut it down to one symbol rename.

@interface SynthesizedIVars

@property int p1; // CHECK1: rename [[@LINE]]:15 -> [[@LINE]]:17
@property(readonly) int p2; // CHECK2PROP: rename [[@LINE]]:25 -> [[@LINE]]:27

@end

@implementation SynthesizedIVars

@synthesize p1 = _p1; // CHECK1: rename [[@LINE]]:13 -> [[@LINE]]:15
                      // CHECK1: rename "_foo" [[@LINE-1]]:18 -> [[@LINE-1]]:21

// The rename of ivar 'p2_' shouldn't initiate the rename of property 'p2'
// because it doesn't follow the default naming convention.
@synthesize p2 = p2_; // CHECK2PROP: rename [[@LINE]]:13 -> [[@LINE]]:15
                      // CHECK2IVAR: rename [[@LINE-1]]:18 -> [[@LINE-1]]:21

- (void)foo:(SynthesizedIVars *)other {
  _p1 =              // CHECK1: rename "_foo" [[@LINE]]:3 -> [[@LINE]]:6
        other->p2_;  // CHECK2IVAR: rename [[@LINE]]:16 -> [[@LINE]]:19
  other->p2_ =       // CHECK2IVAR: rename [[@LINE]]:10 -> [[@LINE]]:13
               _p1;  // CHECK1: rename "_foo" [[@LINE]]:16 -> [[@LINE]]:19
  self.p1 =          // CHECK1: rename [[@LINE]]:8 -> [[@LINE]]:10
           other.p2; // CHECK2PROP: rename [[@LINE]]:18 -> [[@LINE]]:20
}

@end

// RUN: clang-refactor-test rename-initiate -at=%s:3:15 -new-name=foo %s | FileCheck --check-prefix=CHECK1 %s
// RUN: clang-refactor-test rename-initiate -at=%s:10:13 -new-name=foo %s | FileCheck --check-prefix=CHECK1 %s
// RUN: clang-refactor-test rename-initiate -at=%s:10:18 -new-name=foo %s | FileCheck --check-prefix=CHECK1 %s
// RUN: clang-refactor-test rename-initiate -at=%s:19:3 -new-name=foo %s | FileCheck --check-prefix=CHECK1 %s
// RUN: clang-refactor-test rename-initiate -at=%s:22:16 -new-name=foo %s | FileCheck --check-prefix=CHECK1 %s
// RUN: clang-refactor-test rename-initiate -at=%s:23:8 -new-name=foo %s | FileCheck --check-prefix=CHECK1 %s

// RUN: clang-refactor-test rename-initiate -at=%s:4:25 -new-name=foo %s | FileCheck --check-prefix=CHECK2PROP %s
// RUN: clang-refactor-test rename-initiate -at=%s:15:13 -new-name=foo %s | FileCheck --check-prefix=CHECK2PROP %s
// RUN: clang-refactor-test rename-initiate -at=%s:24:18 -new-name=foo %s | FileCheck --check-prefix=CHECK2PROP %s

// RUN: clang-refactor-test rename-initiate -at=%s:15:18 -new-name=foo %s | FileCheck --check-prefix=CHECK2IVAR %s
// RUN: clang-refactor-test rename-initiate -at=%s:20:16 -new-name=foo %s | FileCheck --check-prefix=CHECK2IVAR %s
// RUN: clang-refactor-test rename-initiate -at=%s:21:10 -new-name=foo %s | FileCheck --check-prefix=CHECK2IVAR %s

@interface SynthesizedExplicitIVars {
  int _p3; // CHECK3: rename "_foo" [[@LINE]]:7 -> [[@LINE]]:10
}

@property int p3; // CHECK3: rename [[@LINE]]:15 -> [[@LINE]]:17
@property int p4; // CHECK4: rename [[@LINE]]:15 -> [[@LINE]]:17

@end

@implementation SynthesizedExplicitIVars {
  int _p4; // CHECK4: rename "_foo" [[@LINE]]:7 -> [[@LINE]]:10
}

@synthesize p3 = _p3; // CHECK3: rename [[@LINE]]:13 -> [[@LINE]]:15
                      // CHECK3: rename "_foo" [[@LINE-1]]:18 -> [[@LINE-1]]:21
@synthesize p4 = _p4; // CHECK4: rename [[@LINE]]:13 -> [[@LINE]]:15
                      // CHECK4: rename "_foo" [[@LINE-1]]:18 -> [[@LINE-1]]:21

@end

// RUN: clang-refactor-test rename-initiate -at=%s:45:7 -new-name=foo %s | FileCheck --check-prefix=CHECK3 %s
// RUN: clang-refactor-test rename-initiate -at=%s:48:15 -new-name=foo %s | FileCheck --check-prefix=CHECK3 %s
// RUN: clang-refactor-test rename-initiate -at=%s:57:13 -new-name=foo %s | FileCheck --check-prefix=CHECK3 %s
// RUN: clang-refactor-test rename-initiate -at=%s:57:18 -new-name=foo %s | FileCheck --check-prefix=CHECK3 %s

// RUN: clang-refactor-test rename-initiate -at=%s:49:15 -new-name=foo %s | FileCheck --check-prefix=CHECK4 %s
// RUN: clang-refactor-test rename-initiate -at=%s:54:7 -new-name=foo %s | FileCheck --check-prefix=CHECK4 %s
// RUN: clang-refactor-test rename-initiate -at=%s:59:13 -new-name=foo %s | FileCheck --check-prefix=CHECK4 %s
// RUN: clang-refactor-test rename-initiate -at=%s:59:18 -new-name=foo %s | FileCheck --check-prefix=CHECK4 %s

@interface SynthesizedWithoutIVarName

@property int p5; // CHECK5: rename [[@LINE]]:15 -> [[@LINE]]:17

@end

@implementation SynthesizedWithoutIVarName {
  int _p5; // CHECK5-NOT: rename "" [[@LINE]]
           // CHECK5-NOT: rename [[@LINE-1]]
  int p5;  // CHECK5: rename [[@LINE]]:7 -> [[@LINE]]:9
}

@synthesize p5; // CHECK5: rename [[@LINE]]:13 -> [[@LINE]]:15

@end

// RUN: clang-refactor-test rename-initiate -at=%s:76:15 -new-name=foo %s | FileCheck --check-prefix=CHECK5 %s
// RUN: clang-refactor-test rename-initiate -at=%s:83:7 -new-name=foo %s | FileCheck --check-prefix=CHECK5 %s
// RUN: clang-refactor-test rename-initiate -at=%s:86:13 -new-name=foo %s | FileCheck --check-prefix=CHECK5 %s

@interface A
@property int p6;
@end

@interface C : A
@end

@implementation C

@synthesize p6;
// CHECK6: Renaming 4 symbols
// CHECK6-NEXT: 'c:objc(cs)A(py)p6'

@end

// RUN: clang-refactor-test rename-initiate -at=%s:103:13 -new-name=foo -dump-symbols %s | FileCheck --check-prefix=CHECK6 %s