xref: /llvm-project/clang/test/CodeGenCXX/zero-init-empty-virtual.cpp (revision bed16824ba48862c540837ea5fbc472003904a76)
1 // RUN: %clang_cc1 %s -emit-llvm -o - | FileCheck %s --check-prefixes=CHECK
2 
3 struct polymorphic_base {
4     virtual void func() {}
5     virtual ~polymorphic_base() {}
6 };
7 
8 struct Empty {};
9 struct derived_virtual : virtual Empty {};
10 struct derived : polymorphic_base {};
11 
12 // CHECK: %struct.Holder1 = type { %struct.polymorphic_base }
13 // CHECK: %struct.polymorphic_base = type { ptr }
14 // CHECK: %struct.Holder2 = type { %struct.derived_virtual }
15 // CHECK: %struct.derived_virtual = type { ptr }
16 // CHECK: %struct.Holder3 = type { %struct.derived }
17 // CHECK: %struct.derived = type { %struct.polymorphic_base }
18 
19 struct Holder1 {
20   polymorphic_base a{};
21 } g_holder1;
22 
23 // CHECK: @{{.*}} = {{.*}}global %struct.Holder1 { %struct.polymorphic_base { ptr {{.*}} } }
24 
25 struct Holder2 {
26   derived_virtual a{};
27 } g_holder2;
28 
29 // CHECK: @{{.*}} = {{.*}}global %struct.Holder2 zeroinitializer
30 
31 struct Holder3 {
32   derived a{};
33 } g_holder3;
34 
35 // CHECK: @{{.*}} = {{.*}}global { { ptr } } { { ptr } { ptr {{.*}} } }
36