1 // RUN: %clang_cc1 -triple x86_64-linux -emit-llvm -o - %s | FileCheck %s 2 // RUN: %clang_cc1 -triple x86_64-linux -emit-llvm -o - %s -fexperimental-new-constant-interpreter | FileCheck %s 3 4 #ifdef __SIZEOF_INT128__ 5 // CHECK: @PR11705 = global i128 0 6 __int128_t PR11705 = (__int128_t)&PR11705; 7 #endif 8 9 int arr[2]; 10 // CHECK: @pastEnd = constant ptr getelementptr (i8, ptr @arr, i64 8) 11 int &pastEnd = arr[2]; 12 13 // CHECK: @F = constant ptr @arr, align 8 14 int &F = arr[0]; 15 16 struct S { 17 int a; 18 float c[3]; 19 }; 20 21 // CHECK: @s = global %struct.S zeroinitializer, align 4 22 S s; 23 // CHECK: @sp = constant ptr getelementptr (i8, ptr @s, i64 16), align 8 24 float &sp = s.c[3]; 25 26 27 namespace BaseClassOffsets { 28 struct A { int a; }; 29 struct B { int b; }; 30 struct C : A, B { int c; }; 31 32 extern C c; 33 // CHECK: @_ZN16BaseClassOffsets1aE = global ptr @_ZN16BaseClassOffsets1cE, align 8 34 A* a = &c; 35 // CHECK: @_ZN16BaseClassOffsets1bE = global ptr getelementptr (i8, ptr @_ZN16BaseClassOffsets1cE, i64 4), align 8 36 B* b = &c; 37 } 38 39 namespace ExprBase { 40 struct A { int n; }; 41 struct B { int n; }; 42 struct C : A, B {}; 43 44 extern const int &&t = ((B&&)C{}).n; 45 // CHECK: @_ZGRN8ExprBase1tE_ = internal global {{.*}} zeroinitializer, 46 // CHECK: @_ZN8ExprBase1tE = constant ptr {{.*}} @_ZGRN8ExprBase1tE_, {{.*}} 8 47 } 48 49 namespace reinterpretcast { 50 const unsigned int n = 1234; 51 extern const int &s = reinterpret_cast<const int&>(n); 52 // CHECK: @_ZN15reinterpretcastL1nE = internal constant i32 1234, align 4 53 // CHECK: @_ZN15reinterpretcast1sE = constant ptr @_ZN15reinterpretcastL1nE, align 8 54 55 void *f1(unsigned long l) { 56 return reinterpret_cast<void *>(l); 57 } 58 // CHECK: define {{.*}} ptr @_ZN15reinterpretcast2f1Em 59 // CHECK: inttoptr 60 } 61 62 namespace Bitfield { 63 struct S { int a : 5; ~S(); }; 64 // CHECK: alloca 65 // CHECK: call {{.*}}memset 66 // CHECK: store i32 {{.*}}, ptr @_ZGRN8Bitfield1rE_ 67 // CHECK: call void @_ZN8Bitfield1SD1 68 // CHECK: store ptr @_ZGRN8Bitfield1rE_, ptr @_ZN8Bitfield1rE, align 8 69 int &&r = S().a; 70 } 71 72 namespace Null { 73 decltype(nullptr) null(); 74 // CHECK: call {{.*}} @_ZN4Null4nullEv( 75 int *p = null(); 76 struct S {}; 77 // CHECK: call {{.*}} @_ZN4Null4nullEv( 78 int S::*q = null(); 79 } 80 81 struct A { 82 A(); 83 ~A(); 84 enum E { Foo }; 85 }; 86 87 A *g(); 88 89 void f(A *a) { 90 A::E e1 = a->Foo; 91 92 // CHECK: call noundef ptr @_Z1gv() 93 A::E e2 = g()->Foo; 94 // CHECK: call void @_ZN1AC1Ev( 95 // CHECK: call void @_ZN1AD1Ev( 96 A::E e3 = A().Foo; 97 } 98