From: Reid Kleckner Date: Tue, 25 Mar 2014 18:33:27 +0000 (+0000) Subject: MS ABI: Mark direct virtual bases as visted when building vtable paths X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=dc9f92b80d55b0f411a51f768868d2ce64964501;p=clang MS ABI: Mark direct virtual bases as visted when building vtable paths Fixes PR19240. In retrospect, this is a fairly obvious bug. :) git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@204744 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/AST/VTableBuilder.cpp b/lib/AST/VTableBuilder.cpp index 12c5b8f687..eef91f7416 100644 --- a/lib/AST/VTableBuilder.cpp +++ b/lib/AST/VTableBuilder.cpp @@ -3210,6 +3210,8 @@ void MicrosoftVTableContext::computeVTablePaths(bool ForVBTables, // morally virtual bases. for (const auto &I : Base->vbases()) VBasesSeen.insert(I.getType()->getAsCXXRecordDecl()); + if (I.isVirtual()) + VBasesSeen.insert(Base); } // Sort the paths into buckets, and if any of them are ambiguous, extend all diff --git a/test/CodeGenCXX/microsoft-abi-vtables-virtual-inheritance.cpp b/test/CodeGenCXX/microsoft-abi-vtables-virtual-inheritance.cpp index 2788965d46..634f583e73 100644 --- a/test/CodeGenCXX/microsoft-abi-vtables-virtual-inheritance.cpp +++ b/test/CodeGenCXX/microsoft-abi-vtables-virtual-inheritance.cpp @@ -659,3 +659,26 @@ C c; // MANGLING-DAG: @"\01??_7C@pr17748@@6BA@1@@" // MANGLING-DAG: @"\01??_7C@pr17748@@6BB@1@@" } + +namespace pr19240 { +struct A { + virtual void c(); +}; + +struct B : virtual A { + virtual void c(); +}; + +struct C { }; + +struct D : virtual A, virtual C, B {}; + +D obj; + +// Each MDC only has one vftable. + +// MANGLING-DAG: @"\01??_7D@pr19240@@6B@" +// MANGLING-DAG: @"\01??_7A@pr19240@@6B@" +// MANGLING-DAG: @"\01??_7B@pr19240@@6B@" + +}