diff options
author | Reid Kleckner <reid@kleckner.net> | 2014-03-25 18:33:27 +0000 |
---|---|---|
committer | Reid Kleckner <reid@kleckner.net> | 2014-03-25 18:33:27 +0000 |
commit | d0fe317e0c94b4416c84ece3f87bbdad46407188 (patch) | |
tree | 4327127e86952575155b8aa645474af298479fdc | |
parent | 0c274feedf1ffdb8a674b8419d0015368d3d1f28 (diff) | |
download | bcm5719-llvm-d0fe317e0c94b4416c84ece3f87bbdad46407188.tar.gz bcm5719-llvm-d0fe317e0c94b4416c84ece3f87bbdad46407188.zip |
MS ABI: Mark direct virtual bases as visted when building vtable paths
Fixes PR19240. In retrospect, this is a fairly obvious bug. :)
llvm-svn: 204744
-rw-r--r-- | clang/lib/AST/VTableBuilder.cpp | 2 | ||||
-rw-r--r-- | clang/test/CodeGenCXX/microsoft-abi-vtables-virtual-inheritance.cpp | 23 |
2 files changed, 25 insertions, 0 deletions
diff --git a/clang/lib/AST/VTableBuilder.cpp b/clang/lib/AST/VTableBuilder.cpp index 12c5b8f6879..eef91f7416e 100644 --- a/clang/lib/AST/VTableBuilder.cpp +++ b/clang/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/clang/test/CodeGenCXX/microsoft-abi-vtables-virtual-inheritance.cpp b/clang/test/CodeGenCXX/microsoft-abi-vtables-virtual-inheritance.cpp index 2788965d46a..634f583e735 100644 --- a/clang/test/CodeGenCXX/microsoft-abi-vtables-virtual-inheritance.cpp +++ b/clang/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@" + +} |