xref: /llvm-project/clang/test/FixIt/auto-isa-fixit.m (revision 0f1c1be1968076d6f96f8a7bcc4a15cf195ecd97)
1// RUN: cp %s %t
2// RUN: %clang_cc1 -x objective-c -fixit %t
3// RUN: %clang_cc1 -x objective-c -Werror %t
4
5void object_setClass(id, id);
6Class object_getClass(id);
7
8id rhs(void);
9
10Class pr6302(id x123) {
11  x123->isa  = 0;
12  x123->isa = rhs();
13  x123->isa = (id)(x123->isa);
14  x123->isa = (id)x123->isa;
15  x123->isa = (x123->isa);
16  x123->isa = (id)(x123->isa);
17  return x123->isa;
18}
19
20
21@interface BaseClass {
22@public
23    Class isa; // expected-note 3 {{instance variable is declared here}}
24}
25@end
26
27@interface OtherClass {
28@public
29    id    firstIvar;
30    Class isa; // note, not first ivar;
31}
32@end
33
34@interface Subclass : BaseClass @end
35
36@interface SiblingClass : BaseClass @end
37
38@interface Root @end
39
40@interface hasIsa : Root {
41@public
42  Class isa; // note, isa is not in root class
43}
44@end
45
46@implementation Subclass
47-(void)method {
48    hasIsa *u;
49    id v;
50    BaseClass *w;
51    Subclass *x;
52    SiblingClass *y;
53    OtherClass *z;
54    (void)v->isa;
55    (void)w->isa;
56    (void)x->isa;
57    (void)y->isa;
58    (void)z->isa;
59    (void)u->isa;
60    y->isa = 0;
61    y->isa = w->isa;
62    x->isa = rhs();
63}
64@end
65
66