From d2d1cc5156bd13b78d66e11f4b51fcc7dc4b52af Mon Sep 17 00:00:00 2001 From: Reid Kleckner Date: Fri, 20 Dec 2013 21:44:05 +0000 Subject: [PATCH] Compare canonical return types when generating MS C++ ABI vtable thunks This was part of the cause for PR17655. We were generating thunks when we shouldn't have. I suspect that if we tweak the test case for PR17655 to actually require thunks, we can reproduce the same crash. llvm-svn: 197836 --- clang/lib/AST/VTableBuilder.cpp | 3 ++- .../microsoft-abi-vtables-single-inheritance.cpp | 11 +++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/clang/lib/AST/VTableBuilder.cpp b/clang/lib/AST/VTableBuilder.cpp index 5f7ae0f3ff4a..63ac6f2c4a06 100644 --- a/clang/lib/AST/VTableBuilder.cpp +++ b/clang/lib/AST/VTableBuilder.cpp @@ -2888,7 +2888,8 @@ void VFTableBuilder::AddMethods(BaseSubobject Base, unsigned BaseDepth, AddThunk(MD, VTableThunks[OverriddenMethodInfo.VFTableIndex]); } - if (MD->getResultType() == OverriddenMD->getResultType()) { + if (Context.hasSameType(MD->getResultType(), + OverriddenMD->getResultType())) { // No return adjustment needed - just replace the overridden method info // with the current info. MethodInfo MI(OverriddenMethodInfo.VBTableIndex, diff --git a/clang/test/CodeGenCXX/microsoft-abi-vtables-single-inheritance.cpp b/clang/test/CodeGenCXX/microsoft-abi-vtables-single-inheritance.cpp index 6fe12b0ef07b..3d5cadc718bb 100644 --- a/clang/test/CodeGenCXX/microsoft-abi-vtables-single-inheritance.cpp +++ b/clang/test/CodeGenCXX/microsoft-abi-vtables-single-inheritance.cpp @@ -14,6 +14,7 @@ // RUN: FileCheck --check-prefix=CHECK-L %s < %t // RUN: FileCheck --check-prefix=CHECK-M %s < %t // RUN: FileCheck --check-prefix=CHECK-N %s < %t +// RUN: FileCheck --check-prefix=CHECK-O %s < %t struct A { // CHECK-A: VFTable for 'A' (3 entries) @@ -250,3 +251,13 @@ struct N { }; N n; + +typedef int int_type; +struct O { virtual int f(); }; +struct P : O { virtual int_type f(); }; +P p; +// CHECK-O: VFTable for 'O' in 'P' (1 entries) +// CHECK-O-NEXT: 0 | int_type P::f() + +// CHECK-O: VFTable for 'O' (1 entries) +// CHECK-O-NEXT: 0 | int O::f()