diff options
| author | David Majnemer <david.majnemer@gmail.com> | 2015-04-30 17:15:48 +0000 |
|---|---|---|
| committer | David Majnemer <david.majnemer@gmail.com> | 2015-04-30 17:15:48 +0000 |
| commit | d950f15ee527009d702853f2d60fe6b4d5344977 (patch) | |
| tree | 3dfd43373b235857de5514f2d1262c1599ca5905 /clang/test | |
| parent | 6190aee9b2207caaca5356df6122bef796bb4579 (diff) | |
| download | bcm5719-llvm-d950f15ee527009d702853f2d60fe6b4d5344977.tar.gz bcm5719-llvm-d950f15ee527009d702853f2d60fe6b4d5344977.zip | |
[MS ABI] Correctly make paths through covariant virtual bases
There can be multiple virtual bases which are on the path to a vfptr
when one vbase virtually inherits from another. We should prefer the
most derived virtual base which covariantly overrides a method in the
vfptr class; if we do not lengthen the path this way, we will end up
with too few vftable entries.
This fixes PR21073.
llvm-svn: 236239
Diffstat (limited to 'clang/test')
| -rw-r--r-- | clang/test/CodeGenCXX/microsoft-abi-vtables-return-thunks.cpp | 27 | ||||
| -rw-r--r-- | clang/test/CodeGenCXX/microsoft-abi-vtables-virtual-inheritance.cpp | 2 |
2 files changed, 28 insertions, 1 deletions
diff --git a/clang/test/CodeGenCXX/microsoft-abi-vtables-return-thunks.cpp b/clang/test/CodeGenCXX/microsoft-abi-vtables-return-thunks.cpp index 072cb956035..36c6434d549 100644 --- a/clang/test/CodeGenCXX/microsoft-abi-vtables-return-thunks.cpp +++ b/clang/test/CodeGenCXX/microsoft-abi-vtables-return-thunks.cpp @@ -128,3 +128,30 @@ C::C() {} // GLOBALS: @"\01?f@B@pr20479@@QAEPAUA@2@XZ" // GLOBALS: @"\01?f@B@pr20479@@UAEPAU12@XZ" } + +namespace pr21073 { +struct A { + virtual A *f(); +}; + +struct B : virtual A { + virtual B *f(); +}; + +struct C : virtual A, virtual B { +// VFTABLES-LABEL: VFTable for 'pr21073::A' in 'pr21073::B' in 'pr21073::C' (2 entries). +// VFTABLES-NEXT: 0 | pr21073::B *pr21073::B::f() +// VFTABLES-NEXT: [return adjustment (to type 'struct pr21073::A *'): vbase #1, 0 non-virtual] +// VFTABLES-NEXT: [this adjustment: 8 non-virtual] +// VFTABLES-NEXT: 1 | pr21073::B *pr21073::B::f() +// VFTABLES-NEXT: [return adjustment (to type 'struct pr21073::B *'): 0 non-virtual] +// VFTABLES-NEXT: [this adjustment: 8 non-virtual] + C(); +}; + +C::C() {} + +// GLOBALS-LABEL: @"\01??_7C@pr21073@@6B@" = linkonce_odr unnamed_addr constant [2 x i8*] +// GLOBALS: @"\01?f@B@pr21073@@WPPPPPPPI@AEPAUA@2@XZ" +// GLOBALS: @"\01?f@B@pr21073@@WPPPPPPPI@AEPAU12@XZ" +} diff --git a/clang/test/CodeGenCXX/microsoft-abi-vtables-virtual-inheritance.cpp b/clang/test/CodeGenCXX/microsoft-abi-vtables-virtual-inheritance.cpp index 83f8114bae9..d600ebbf4c2 100644 --- a/clang/test/CodeGenCXX/microsoft-abi-vtables-virtual-inheritance.cpp +++ b/clang/test/CodeGenCXX/microsoft-abi-vtables-virtual-inheritance.cpp @@ -423,7 +423,7 @@ void use(T *obj) { obj->f(); } namespace Test10 { struct X : virtual C, virtual A { - // CHECK-LABEL: VFTable for 'A' in 'C' in 'Test10::X' (2 entries). + // CHECK-LABEL: VFTable for 'A' in 'Test10::X' (2 entries). // CHECK-NEXT: 0 | void Test10::X::f() // CHECK-NEXT: 1 | void A::z() |

