171568a9eSLeonard Chan // Check the layout of the vtable for a child class that inherits a virtual 271568a9eSLeonard Chan // function but does not override it. 371568a9eSLeonard Chan 471568a9eSLeonard Chan // RUN: %clang_cc1 %s -triple=aarch64-unknown-fuchsia -O1 -S -o - -emit-llvm -fexperimental-relative-c++-abi-vtables | FileCheck %s 571568a9eSLeonard Chan 671568a9eSLeonard Chan class A { 771568a9eSLeonard Chan public: 871568a9eSLeonard Chan virtual void foo(); 971568a9eSLeonard Chan }; 1071568a9eSLeonard Chan 1171568a9eSLeonard Chan // The VTable for B should look similar to the vtable for A but the component for foo() should point to A::foo() and the component for bar() should point to B::bar(). 12*cf8ff75bSLeonard Chan // CHECK: @_ZTV1B.local = private unnamed_addr constant { [4 x i32] } { [4 x i32] [i32 0, i32 trunc (i64 sub (i64 ptrtoint ({ i8*, i8*, i8* }** @_ZTI1B.rtti_proxy to i64), i64 ptrtoint (i32* getelementptr inbounds ({ [4 x i32] }, { [4 x i32] }* @_ZTV1B.local, i32 0, i32 0, i32 2) to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint (void (%class.A*)* dso_local_equivalent @_ZN1A3fooEv to i64), i64 ptrtoint (i32* getelementptr inbounds ({ [4 x i32] }, { [4 x i32] }* @_ZTV1B.local, i32 0, i32 0, i32 2) to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint (void (%class.B*)* dso_local_equivalent @_ZN1B3barEv to i64), i64 ptrtoint (i32* getelementptr inbounds ({ [4 x i32] }, { [4 x i32] }* @_ZTV1B.local, i32 0, i32 0, i32 2) to i64)) to i32)] }, align 4 1371568a9eSLeonard Chan // CHECK: @_ZTV1B = unnamed_addr alias { [4 x i32] }, { [4 x i32] }* @_ZTV1B.local 1471568a9eSLeonard Chan 1571568a9eSLeonard Chan class B : public A { 1671568a9eSLeonard Chan public: 1771568a9eSLeonard Chan virtual void bar(); 1871568a9eSLeonard Chan }; 1971568a9eSLeonard Chan 2071568a9eSLeonard Chan void A::foo() {} 2171568a9eSLeonard Chan void B::bar() {} 2271568a9eSLeonard Chan 2371568a9eSLeonard Chan void A_foo(A *a) { 2471568a9eSLeonard Chan a->foo(); 2571568a9eSLeonard Chan } 2671568a9eSLeonard Chan 2771568a9eSLeonard Chan void B_foo(B *b) { 2871568a9eSLeonard Chan b->foo(); 2971568a9eSLeonard Chan } 30