[PATCH] MS ABI: Properly call global delete when invoking virtual destructors

Reid Kleckner rnk at google.com
Mon Oct 27 18:24:01 PDT 2014


We also discussed how to deal with the ARM side brokenness when clang compiles this code:
  struct A { virtual ~A(); };
  struct B { virtual ~B(); };
  struct C : A, B { virtual ~C(); };
  C::~C() {}
The deleting destructor thunk for B lies about it's return value. The 'returned' attribute is also a lie.

================
Comment at: lib/CodeGen/CGCXXABI.h:94-96
@@ -93,3 +93,5 @@
   /// when called virtually, and code generation does not support the case.
   virtual bool HasThisReturn(GlobalDecl GD) const { return false; }
 
+  virtual bool hasMostDerivedReturn(GlobalDecl GD) const { return false; }
+
----------------
Can we write a wrapper for these that takes the this type and returns the return type of void, void*, or decltype(this)?

================
Comment at: lib/CodeGen/CGCall.cpp:241
@@ +240,3 @@
+                               ? ArgTypes.front()
+                               : TheCXXABI.hasMostDerivedReturn(GD)
+                                     ? CGM.getContext().VoidPtrTy
----------------
Does it make sense to check this for constructors, given that ctors can't really return the most derived types?

http://reviews.llvm.org/D5996






More information about the cfe-commits mailing list