r197836 - Compare canonical return types when generating MS C++ ABI vtable thunks

Reid Kleckner reid at kleckner.net
Fri Dec 20 13:44:05 PST 2013


Author: rnk
Date: Fri Dec 20 15:44:05 2013
New Revision: 197836

URL: http://llvm.org/viewvc/llvm-project?rev=197836&view=rev
Log:
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.

Modified:
    cfe/trunk/lib/AST/VTableBuilder.cpp
    cfe/trunk/test/CodeGenCXX/microsoft-abi-vtables-single-inheritance.cpp

Modified: cfe/trunk/lib/AST/VTableBuilder.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/VTableBuilder.cpp?rev=197836&r1=197835&r2=197836&view=diff
==============================================================================
--- cfe/trunk/lib/AST/VTableBuilder.cpp (original)
+++ cfe/trunk/lib/AST/VTableBuilder.cpp Fri Dec 20 15:44:05 2013
@@ -2888,7 +2888,8 @@ void VFTableBuilder::AddMethods(BaseSubo
         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,

Modified: cfe/trunk/test/CodeGenCXX/microsoft-abi-vtables-single-inheritance.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/microsoft-abi-vtables-single-inheritance.cpp?rev=197836&r1=197835&r2=197836&view=diff
==============================================================================
--- cfe/trunk/test/CodeGenCXX/microsoft-abi-vtables-single-inheritance.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/microsoft-abi-vtables-single-inheritance.cpp Fri Dec 20 15:44:05 2013
@@ -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()





More information about the cfe-commits mailing list