xref: /llvm-project/clang/test/CodeGenCXX/zero-init-empty-virtual.cpp (revision bed16824ba48862c540837ea5fbc472003904a76)
14497ec29SMichael Buch // RUN: %clang_cc1 %s -emit-llvm -o - | FileCheck %s --check-prefixes=CHECK
24497ec29SMichael Buch 
34497ec29SMichael Buch struct polymorphic_base {
44497ec29SMichael Buch     virtual void func() {}
54497ec29SMichael Buch     virtual ~polymorphic_base() {}
64497ec29SMichael Buch };
74497ec29SMichael Buch 
84497ec29SMichael Buch struct Empty {};
94497ec29SMichael Buch struct derived_virtual : virtual Empty {};
104497ec29SMichael Buch struct derived : polymorphic_base {};
114497ec29SMichael Buch 
124497ec29SMichael Buch // CHECK: %struct.Holder1 = type { %struct.polymorphic_base }
134497ec29SMichael Buch // CHECK: %struct.polymorphic_base = type { ptr }
144497ec29SMichael Buch // CHECK: %struct.Holder2 = type { %struct.derived_virtual }
154497ec29SMichael Buch // CHECK: %struct.derived_virtual = type { ptr }
164497ec29SMichael Buch // CHECK: %struct.Holder3 = type { %struct.derived }
174497ec29SMichael Buch // CHECK: %struct.derived = type { %struct.polymorphic_base }
184497ec29SMichael Buch 
194497ec29SMichael Buch struct Holder1 {
204497ec29SMichael Buch   polymorphic_base a{};
214497ec29SMichael Buch } g_holder1;
224497ec29SMichael Buch 
234497ec29SMichael Buch // CHECK: @{{.*}} = {{.*}}global %struct.Holder1 { %struct.polymorphic_base { ptr {{.*}} } }
244497ec29SMichael Buch 
254497ec29SMichael Buch struct Holder2 {
264497ec29SMichael Buch   derived_virtual a{};
274497ec29SMichael Buch } g_holder2;
284497ec29SMichael Buch 
29*bed16824SMichael Buch // CHECK: @{{.*}} = {{.*}}global %struct.Holder2 zeroinitializer
304497ec29SMichael Buch 
314497ec29SMichael Buch struct Holder3 {
324497ec29SMichael Buch   derived a{};
334497ec29SMichael Buch } g_holder3;
344497ec29SMichael Buch 
354497ec29SMichael Buch // CHECK: @{{.*}} = {{.*}}global { { ptr } } { { ptr } { ptr {{.*}} } }
36