File: rewrite-modern-struct-ivar.mm

package info (click to toggle)
llvm-toolchain-7 1%3A7.0.1-8
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 733,456 kB
  • sloc: cpp: 3,776,651; ansic: 633,271; asm: 350,301; python: 142,716; objc: 107,612; sh: 22,626; lisp: 11,056; perl: 7,999; pascal: 6,742; ml: 5,537; awk: 3,536; makefile: 2,557; cs: 2,027; xml: 841; ruby: 156
file content (52 lines) | stat: -rw-r--r-- 1,048 bytes parent folder | download | duplicates (25)
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
// RUN: %clang_cc1 -E %s -o %t.mm
// RUN: %clang_cc1 -fblocks -rewrite-objc -fms-extensions %t.mm -o %t-rw.cpp 
// RUN: FileCheck --input-file=%t-rw.cpp %s
// RUN: %clang_cc1 -fsyntax-only -Werror -Wno-address-of-temporary -Wno-c++11-narrowing -std=c++11 -D"Class=void*" -D"id=void*" -D"SEL=void*" -U__declspec -D"__declspec(X)=" %t-rw.cpp

struct S {
    int i1;
    double d1;
    void (^block1)();
};

@interface I
{
  struct S struct_ivar;

  struct S *pstruct_ivar;
}
@end

@implementation I
- (struct S) dMeth{ return struct_ivar; }
@end

// CHECK: return (*(struct S *)((char *)self + OBJC_IVAR_$_I$struct_ivar));

// rdar://11323187
@interface Foo{
    @protected 
    struct {
        int x:1;
        int y:1;
    } bar;

    struct _S {
        int x:1;
        int y:1;
    } s;

}
@end
@implementation Foo
- (void)x {
  bar.x = 0;
  bar.y = 1;

  s.x = 0;
  s.y = 1;
}
@end

// CHECK: (*(decltype(((Foo_IMPL *)0U)->bar) *)((char *)self + OBJC_IVAR_$_Foo$bar)).x = 0;
// CHECK: (*(struct _S *)((char *)self + OBJC_IVAR_$_Foo$s)).x = 0;