[PATCH] Fix crashes when creating global instances of polymorphic classes without fields
Timur Iskhodzhanov
timurrrr at google.com
Tue Oct 1 05:32:04 PDT 2013
Hi rnk, rsmith,
Reid, Richard,
Can you please review this tiny patch?
Currently the test crashes clang if used with non-default flags.
-
Timur
http://llvm-reviews.chandlerc.com/D1795
Files:
lib/CodeGen/CGDeclCXX.cpp
test/CodeGenCXX/destructor-exception-spec.cpp
Index: lib/CodeGen/CGDeclCXX.cpp
===================================================================
--- lib/CodeGen/CGDeclCXX.cpp
+++ lib/CodeGen/CGDeclCXX.cpp
@@ -96,7 +96,8 @@
CXXDestructorDecl *dtor = record->getDestructor();
function = CGM.GetAddrOfCXXDestructor(dtor, Dtor_Complete);
- argument = addr;
+ argument = llvm::ConstantExpr::getBitCast(
+ addr, CGF.getTypes().ConvertType(type)->getPointerTo());
// Otherwise, the standard logic requires a helper function.
} else {
Index: test/CodeGenCXX/destructor-exception-spec.cpp
===================================================================
--- test/CodeGenCXX/destructor-exception-spec.cpp
+++ test/CodeGenCXX/destructor-exception-spec.cpp
@@ -1,4 +1,6 @@
// RUN: %clang_cc1 -emit-llvm-only %s -std=c++11
+// RUN: %clang_cc1 -emit-llvm-only -fno-use-cxa-atexit %s -std=c++11
+// RUN: %clang_cc1 -cxx-abi microsoft -fno-rtti -emit-llvm-only %s -std=c++11
// PR13479: don't crash with -fno-exceptions.
namespace {
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D1795.1.patch
Type: text/x-patch
Size: 1014 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20131001/49c928f1/attachment.bin>
More information about the cfe-commits
mailing list