brintos

brintos / llvm-project-archived public Read only

0
0
Text · 4.2 KiB · 827b51b Raw
189 lines · cpp
1// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -emit-llvm -o - %s | FileCheck %s2 3namespace rdar8818236 {4struct S {5  char c2;6  union {7    char c;8    int i;9  };10};11 12// CHECK: @_ZN11rdar88182363fooE ={{.*}} global i64 413char S::*foo  = &S::c;14}15 16struct A {17  union {18    int a;19    void* b;20  };21  22  A() : a(0) { }23};24 25A a;26 27namespace PR7021 {28  struct X29  {30    union { long l; };31  };32 33  // CHECK-LABEL: define{{.*}} void @_ZN6PR70211fENS_1XES0_34  void f(X x, X z) {35    X x1;36 37    // CHECK: store i64 1, ptr38    x1.l = 1;39 40    // CHECK: call void @llvm.memcpy.p0.p0.i6441    X x2(x1);42 43    X x3;44    // CHECK: call void @llvm.memcpy.p0.p0.i6445    x3 = x1;46 47    // CHECK: ret void48  }49}50 51namespace test2 {52  struct A {53    struct {54      union {55        int b;56      };57    };58 59    A();60  };61 62  A::A() : b(10) { }63  // CHECK-LABEL: define{{.*}} void @_ZN5test21AC2Ev(64  // CHECK-NOT: }65  // CHECK: store i32 1066  // CHECK: }67}68 69namespace PR10512 {70  struct A {71    A();72    A(int);73    A(long);74 75    struct {76      struct {int x;};77      struct {int y;};78    };79  };80 81  // CHECK-LABEL: define{{.*}} void @_ZN7PR105121AC2Ev82  // CHECK: [[THISADDR:%[a-zA-Z0-9.]+]] = alloca ptr83  // CHECK-NEXT: store ptr [[THIS:%[a-zA-Z0-9.]+]], ptr [[THISADDR]]84  // CHECK-NEXT: [[THIS1:%[a-zA-Z0-9.]+]] = load ptr, ptr [[THISADDR]]85  // CHECK-NEXT: ret void86  A::A() {}87 88  // CHECK-LABEL: define{{.*}} void @_ZN7PR105121AC2Ei89  // CHECK: [[THISADDR:%[a-zA-Z0-9.]+]] = alloca ptr90  // CHECK-NEXT: [[XADDR:%[a-zA-Z0-9.]+]] = alloca i3291  // CHECK-NEXT: store ptr [[THIS:%[a-zA-Z0-9.]+]], ptr [[THISADDR]]92  // CHECK-NEXT: store i32 [[X:%[a-zA-Z0-9.]+]], ptr [[XADDR]]93  // CHECK-NEXT: [[THIS1:%[a-zA-Z0-9.]+]] = load ptr, ptr [[THISADDR]]94  // CHECK-NEXT: {{getelementptr inbounds.*i32 0, i32 0}}95  // CHECK-NEXT: {{getelementptr inbounds.*i32 0, i32 0}}96  // CHECK-NEXT: {{getelementptr inbounds.*i32 0, i32 0}}97  // CHECK-NEXT: [[TMP:%[a-zA-Z0-9.]+]] = load i32, ptr [[XADDR]]98  // CHECK-NEXT: store i32 [[TMP]]99  // CHECK-NEXT: ret void100  A::A(int x) : x(x) { }101 102  // CHECK-LABEL: define{{.*}} void @_ZN7PR105121AC2El103  // CHECK: [[THISADDR:%[a-zA-Z0-9.]+]] = alloca ptr104  // CHECK-NEXT: [[XADDR:%[a-zA-Z0-9.]+]] = alloca i64105  // CHECK-NEXT: store ptr [[THIS:%[a-zA-Z0-9.]+]], ptr [[THISADDR]]106  // CHECK-NEXT: store i64 [[X:%[a-zA-Z0-9.]+]], ptr [[XADDR]]107  // CHECK-NEXT: [[THIS1:%[a-zA-Z0-9.]+]] = load ptr, ptr [[THISADDR]]108  // CHECK-NEXT: {{getelementptr inbounds.*i32 0, i32 0}}109  // CHECK-NEXT: {{getelementptr inbounds.*i32 0, i32 1}}110  // CHECK-NEXT: {{getelementptr inbounds.*i32 0, i32 0}}111  // CHECK-NEXT: [[TMP:%[a-zA-Z0-9.]+]] = load i64, ptr [[XADDR]]112  // CHECK-NEXT: [[CONV:%[a-zA-Z0-9.]+]] = trunc i64 [[TMP]] to i32113  // CHECK-NEXT: store i32 [[CONV]]114  // CHECK-NEXT: ret void115  A::A(long y) : y(y) { }116}117 118namespace test3 {119  struct A {120    union {121      mutable char fibers[100];122      struct {123        void (*callback)(void*);124        void *callback_value;125      };126    };127 128    A();129  };130 131  A::A() : callback(0), callback_value(0) {}132  // CHECK-LABEL: define{{.*}} void @_ZN5test31AC2Ev(133  // CHECK: [[THIS:%.*]] = load134  // CHECK-NEXT: [[UNION:%.*]] = getelementptr inbounds {{.*}} [[THIS]], i32 0, i32 0135  // CHECK-NEXT: [[CALLBACK:%.*]] = getelementptr inbounds {{.*}} [[UNION]], i32 0, i32 0136  // CHECK: store 137  // CHECK-NEXT: [[UNION:%.*]] = getelementptr inbounds {{.*}} [[THIS]], i32 0, i32 0138  // CHECK-NEXT: [[CVALUE:%.*]] = getelementptr inbounds {{.*}} [[UNION]], i32 0, i32 1139  // CHECK-NEXT: store ptr null, ptr [[CVALUE]]140}141 142struct S {143  // CHECK: store i32 42144  // CHECK: store i32 55145  S() : x(42), y(55) {}146  union {147    struct {148      int x;149      union { int y; };150    };151  };152} s;153 154 155//PR8760 156template <typename T> struct Foo {157  Foo() : ptr(__nullptr) {}158  union {159    T *ptr;160  };161};162Foo<int> f;163 164namespace PR9683 {165  struct QueueEntry {166    union {167      struct {168        void* mPtr;169        union {170          unsigned mSubmissionTag;171        };172      };173      unsigned mValue;174    };175    QueueEntry() {}176  };177  QueueEntry QE;178}179 180namespace PR13154 {181  struct IndirectReferenceField {182      struct {183          float &x;184      };185      IndirectReferenceField(float &x);186  };187  IndirectReferenceField::IndirectReferenceField(float &xx) : x(xx) {}188}189