aboutsummaryrefslogtreecommitdiff
path: root/lib/CodeGen/CGException.cpp
diff options
context:
space:
mode:
authorMike Stump <mrs@apple.com>2009-11-20 01:57:39 +0000
committerMike Stump <mrs@apple.com>2009-11-20 01:57:39 +0000
commite36c9abd383267775a5079166e5e02119866c129 (patch)
treec485d789d7a4d375d02135940b1884f0b76f13b3 /lib/CodeGen/CGException.cpp
parent3b57dc0d78192d893f63d7b1ce67a1bc06a74b3e (diff)
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
Diffstat (limited to 'lib/CodeGen/CGException.cpp')
-rw-r--r--lib/CodeGen/CGException.cpp17
1 files changed, 9 insertions, 8 deletions
diff --git a/lib/CodeGen/CGException.cpp b/lib/CodeGen/CGException.cpp
index 3abc40775a..fafdf87aab 100644
--- a/lib/CodeGen/CGException.cpp
+++ b/lib/CodeGen/CGException.cpp
@@ -61,12 +61,6 @@ void CodeGenFunction::EmitCXXThrowExpr(const CXXThrowExpr *E) {
}
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 @@ void CodeGenFunction::EmitCXXThrowExpr(const CXXThrowExpr *E) {
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.