| 1 |
// Multiple inheritance case: |
| 2 |
// For CBaseOne, CBaseTwo and CDerived we check: |
| 3 |
// - Generation of their vtables (including attributes). |
| 4 |
// - Generation of their '_vtable$' data members: |
| 5 |
// * Correct scope and attributes |
| 6 |
|
| 7 |
namespace NSP_1 { |
| 8 |
struct CBaseOne { |
| 9 |
int B1 = 1; |
| 10 |
virtual int one() { return 1; } |
| 11 |
virtual int two() { return 2; } |
| 12 |
virtual int three() { return 3; } |
| 13 |
}; |
| 14 |
} |
| 15 |
|
| 16 |
namespace NSP_2 { |
| 17 |
struct CBaseTwo { |
| 18 |
int B2 = 1; |
| 19 |
virtual int four() { return 4; } |
| 20 |
virtual int five() { return 5; } |
| 21 |
virtual int six() { return 6; } |
| 22 |
}; |
| 23 |
} |
| 24 |
|
| 25 |
struct CDerived : NSP_1::CBaseOne, NSP_2::CBaseTwo { |
| 26 |
int D = 1; |
| 27 |
int two() override { return 22; }; |
| 28 |
int six() override { return 66; } |
| 29 |
}; |
| 30 |
|
| 31 |
int main() { |
| 32 |
NSP_1::CBaseOne BaseOne; |
| 33 |
NSP_2::CBaseTwo BaseTwo; |
| 34 |
CDerived Derived; |
| 35 |
|
| 36 |
return 0; |
| 37 |
} |
| 38 |
|
| 39 |
// RUN: %clang_cc1 -triple x86_64-linux -emit-llvm -debug-info-kind=limited -dwarf-version=5 -O0 -disable-llvm-passes %s -o - | FileCheck %s |
| 40 |
// RUN: %clang_cc1 -triple x86_64-linux -emit-llvm -debug-info-kind=limited -dwarf-version=5 -O1 -disable-llvm-passes %s -o - | FileCheck %s |
| 41 |
// RUN: %clang_cc1 -triple x86_64-mingw -emit-llvm -debug-info-kind=limited -dwarf-version=5 -O0 -disable-llvm-passes %s -o - | FileCheck %s |
| 42 |
// RUN: %clang_cc1 -triple x86_64-mingw -emit-llvm -debug-info-kind=limited -dwarf-version=5 -O1 -disable-llvm-passes %s -o - | FileCheck %s |
| 43 |
|
| 44 |
// CHECK: $_ZTVN5NSP_18CBaseOneE = comdat any |
| 45 |
// CHECK: $_ZTVN5NSP_28CBaseTwoE = comdat any |
| 46 |
// CHECK: $_ZTV8CDerived = comdat any |
| 47 |
|
| 48 |
// CHECK: @_ZTVN5NSP_18CBaseOneE = linkonce_odr {{.*}}unnamed_addr constant {{.*}}, comdat, align 8, !dbg [[BASE_ONE_VTABLE_VAR:![0-9]*]] |
| 49 |
// CHECK: @_ZTVN5NSP_28CBaseTwoE = linkonce_odr {{.*}}unnamed_addr constant {{.*}}, comdat, align 8, !dbg [[BASE_TWO_VTABLE_VAR:![0-9]*]] |
| 50 |
// CHECK: @_ZTV8CDerived = linkonce_odr {{.*}}unnamed_addr constant {{.*}}, comdat, align 8, !dbg [[DERIVED_VTABLE_VAR:![0-9]*]] |
| 51 |
|
| 52 |
// CHECK: [[BASE_ONE_VTABLE_VAR]] = !DIGlobalVariableExpression(var: [[BASE_ONE_VTABLE:![0-9]*]], expr: !DIExpression()) |
| 53 |
// CHECK-NEXT: [[BASE_ONE_VTABLE]] = distinct !DIGlobalVariable(name: "_vtable$", linkageName: "_ZTVN5NSP_18CBaseOneE" |
| 54 |
|
| 55 |
// CHECK: [[BASE_TWO_VTABLE_VAR]] = !DIGlobalVariableExpression(var: [[BASE_TWO_VTABLE:![0-9]*]], expr: !DIExpression()) |
| 56 |
// CHECK-NEXT: [[BASE_TWO_VTABLE]] = distinct !DIGlobalVariable(name: "_vtable$", linkageName: "_ZTVN5NSP_28CBaseTwoE" |
| 57 |
|
| 58 |
// CHECK: [[TYPE:![0-9]*]] = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: null, size: 64) |
| 59 |
|
| 60 |
// CHECK: !DIDerivedType(tag: DW_TAG_variable, name: "_vtable$", scope: [[BASE_TWO:![0-9]*]], file: {{.*}}, baseType: [[TYPE]], flags: DIFlagPrivate | DIFlagArtificial | DIFlagStaticMember) |
| 61 |
|
| 62 |
// check: [[BASE_TWO]] = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "CBaseTwo" |
| 63 |
|
| 64 |
// CHECK: [[DERIVED_VTABLE_VAR]] = !DIGlobalVariableExpression(var: [[DERIVED_VTABLE:![0-9]*]], expr: !DIExpression()) |
| 65 |
// CHECK: [[DERIVED_VTABLE]] = distinct !DIGlobalVariable(name: "_vtable$", linkageName: "_ZTV8CDerived" |
| 66 |
|
| 67 |
// CHECK: !DIDerivedType(tag: DW_TAG_variable, name: "_vtable$", scope: [[DERIVED:![0-9]*]], file: {{.*}}, baseType: [[TYPE]], flags: DIFlagPrivate | DIFlagArtificial | DIFlagStaticMember) |
| 68 |
|
| 69 |
// CHECK: [[DERIVED]] = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "CDerived" |
| 70 |
|
| 71 |
// CHECK: [[BASE_ONE:![0-9]*]] = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "CBaseOne" |
| 72 |
|
| 73 |
// CHECK: !DIDerivedType(tag: DW_TAG_variable, name: "_vtable$", scope: [[BASE_ONE]], file: {{.*}}, baseType: [[TYPE]], flags: DIFlagPrivate | DIFlagArtificial | DIFlagStaticMember) |