59 lines · cpp
1// RUN: %clang_cc1 -triple x86_64-linux-gnu -emit-llvm -o - %s -std=c++2a | FileCheck %s --implicit-check-not=cxx_global_var_init --implicit-check-not=cxa_atexit2 3// RUN: %clang_cc1 -triple x86_64-linux-gnu -emit-pch -o %t.pch %s -std=c++2a4// RUN: %clang_cc1 -triple x86_64-linux-gnu -include-pch %t.pch -x c++ /dev/null -emit-llvm -o - -std=c++2a | FileCheck %s --implicit-check-not=cxx_global_var_init --implicit-check-not=cxa_atexit5 6// CHECK: @a ={{.*}} global i32 123,7int a = (delete new int, 123);8 9struct B {10 constexpr B() {}11 constexpr ~B() { n *= 5; }12 int n = 123;13};14// CHECK: @b ={{.*}} constant {{.*}} i32 12315extern constexpr B b = B();16 17// CHECK: @_ZL1c = internal constant {{.*}} i32 12318const B c;19int use_c() { return c.n; }20 21struct D {22 int n;23 constexpr ~D() {}24};25D d;26// CHECK: @d ={{.*}} global {{.*}} zeroinitializer27 28D d_arr[3];29// CHECK: @d_arr ={{.*}} global {{.*}} zeroinitializer30 31thread_local D d_tl;32// CHECK: @d_tl ={{.*}} thread_local global {{.*}} zeroinitializer33 34// CHECK-NOT: @llvm.global_ctors35 36// CHECK-LABEL: define {{.*}} @_Z1fv(37void f() {38 // CHECK-NOT: call39 // CHECK: call {{.*}}memcpy40 // CHECK-NOT: call41 // CHECK: call {{.*}}memset42 // CHECK-NOT: call43 // CHECK: }44 constexpr B b;45 D d = D();46}47 48// CHECK-LABEL: define {{.*}} @_Z1gv(49void g() {50 // CHECK-NOT: call51 // CHECK-NOT: cxa_guard52 // CHECK-NOT: _ZGV53 // CHECK: }54 static constexpr B b1;55 static const B b2;56 static D d;57 thread_local D d_tl;58}59