39 lines · cpp
1// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -fno-rtti -fclangir -emit-cir %s -o %t.cir2// RUN: FileCheck --input-file=%t.cir %s3// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -fno-rtti -fclangir -emit-llvm -o %t-cir.ll %s4// RUN: FileCheck --check-prefix=LLVM --input-file=%t-cir.ll %s5// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -fno-rtti -emit-llvm -o %t.ll %s6// RUN: FileCheck --check-prefix=OGCG --input-file=%t.ll %s7 8// Note: This test is using -fno-rtti so that we can delay implemntation of that handling.9// When rtti handling for vtables is implemented, that option should be removed.10 11struct S {12 virtual void key();13 virtual void nonKey() {}14};15 16void S::key() {}17 18// CHECK-DAG: !rec_anon_struct = !cir.record<struct {!cir.array<!cir.ptr<!u8i> x 4>}>19 20// The definition of the key function should result in the vtable being emitted.21// CHECK: cir.global "private" external @_ZTV1S = #cir.vtable<{22// CHECK-SAME: #cir.const_array<[23// CHECK-SAME: #cir.ptr<null> : !cir.ptr<!u8i>,24// CHECK-SAME: #cir.ptr<null> : !cir.ptr<!u8i>,25// CHECK-SAME: #cir.global_view<@_ZN1S3keyEv> : !cir.ptr<!u8i>,26// CHECK-SAME: #cir.global_view<@_ZN1S6nonKeyEv> : !cir.ptr<!u8i>]>27// CHECK-SAME: : !cir.array<!cir.ptr<!u8i> x 4>}> : !rec_anon_struct28 29// LLVM: @_ZTV1S = global { [4 x ptr] } { [4 x ptr]30// LLVM-SAME: [ptr null, ptr null, ptr @_ZN1S3keyEv, ptr @_ZN1S6nonKeyEv] }31 32// OGCG: @_ZTV1S = unnamed_addr constant { [4 x ptr] } { [4 x ptr]33// OGCG-SAME: [ptr null, ptr null, ptr @_ZN1S3keyEv, ptr @_ZN1S6nonKeyEv] }34 35// CHECK: cir.func dso_local @_ZN1S3keyEv36 37// The reference from the vtable should result in nonKey being emitted.38// CHECK: cir.func comdat linkonce_odr @_ZN1S6nonKeyEv39