Handle throw d, where d is a class type but only has a trivial copy
constructor. WIP.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@89438 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/CodeGen/CGException.cpp b/lib/CodeGen/CGException.cpp
index 3abc407..fafdf87 100644
--- a/lib/CodeGen/CGException.cpp
+++ b/lib/CodeGen/CGException.cpp
@@ -61,12 +61,6 @@
}
QualType ThrowType = E->getSubExpr()->getType();
- // FIXME: We only handle non-class types for now.
- if (ThrowType->isRecordType()) {
- ErrorUnsupported(E, "throw expression");
- return;
- }
-
// FIXME: Handle cleanup.
if (!CleanupEntries.empty()){
ErrorUnsupported(E, "throw expression");
@@ -90,8 +84,15 @@
Builder.CreateStore(Value, Builder.CreateBitCast(ExceptionPtr, ValuePtrTy));
} else {
- // FIXME: Handle complex and aggregate expressions.
- ErrorUnsupported(E, "throw expression");
+ // See EmitCXXConstructorCall.
+ const llvm::Type *Ty = ConvertType(ThrowType)->getPointerTo(0);
+ const CXXRecordDecl *RD;
+ RD = cast<CXXRecordDecl>(ThrowType->getAs<RecordType>()->getDecl());
+ if (RD->hasTrivialCopyConstructor()) {
+ EmitAggExpr(E->getSubExpr(), Builder.CreateBitCast(ExceptionPtr, Ty),
+ false);
+ } else
+ ErrorUnsupported(E, "throw expression with copy ctor");
}
// Now throw the exception.