summaryrefslogtreecommitdiff
path: root/test/CodeGenObjC/objc2-write-barrier-2.m
blob: 6bc2f509083bcc8f76f4e9e07d279a6c94ba3171 (plain)
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
// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fobjc-runtime=macosx-fragile-10.5 -fobjc-gc -emit-llvm -o %t %s
// RUN: grep -F '@objc_assign_global' %t  | count 7
// RUN: grep -F '@objc_assign_ivar' %t  | count 5
// RUN: grep -F '@objc_assign_strongCast' %t  | count 8
// RUN: %clang_cc1 -x objective-c++ -triple x86_64-apple-darwin10 -fobjc-runtime=macosx-fragile-10.5 -fobjc-gc -emit-llvm -o %t %s
// RUN: grep -F '@objc_assign_global' %t  | count 7
// RUN: grep -F '@objc_assign_ivar' %t  | count 5
// RUN: grep -F '@objc_assign_strongCast' %t  | count 8

extern id **somefunc(void);
extern id *somefunc2(void);


// Globals

id W, *X, **Y;

void func(id a, id *b, id **c) {
   static id w, *x, **y;
   W = a;  
   w = a;
   X = b;
   x = b; 
   Y = c;
   y = c; 
}

// Instances

@interface something {
    id w, *x, **y;
}
@end

@implementation something
- (void)amethod {
    id badIdea = *somefunc2();
    w = badIdea;
    x = &badIdea;
    y = &x;
}
@end

typedef struct {
    int junk;
    id  alfred;
} AStruct;

void funct2(AStruct *aptr) {
    id **ppptr = somefunc();
    aptr->alfred = 0;
    **ppptr = aptr->alfred;
    *ppptr = somefunc2(); 
}

typedef const struct __CFString * CFStringRef;
@interface DSATextSearch {
__strong CFStringRef *_documentNames;
  struct {
    id *innerNames;
    struct {
      id *nestedDeeperNames; 
      struct I {
         id *is1;
         id is2[5];
      } arrI [3];
    } inner_most;
  } inner;

}
- filter;
@end
@implementation DSATextSearch
- filter {
  int filteredPos = 0;
  _documentNames[filteredPos] = 0; // storing into an element of array ivar. objc_assign_strongCast is needed.
  inner.innerNames[filteredPos] = 0;
  inner.inner_most.nestedDeeperNames[filteredPos] = 0;
  inner.inner_most.arrI[3].is1[5] = 0;
  inner.inner_most.arrI[3].is2[5] = 0;
}
@end