diff options
author | Mike Stump <mrs@apple.com> | 2009-11-20 01:57:39 +0000 |
---|---|---|
committer | Mike Stump <mrs@apple.com> | 2009-11-20 01:57:39 +0000 |
commit | 4d7a07bdaf625e61a94f41b72f79165869ca79d8 (patch) | |
tree | c187b5410bc9112f70084ce624f02b705729a7cb /clang/lib | |
parent | 6d9a942174a49b723eb184cef7ddb99166aeb7c9 (diff) | |
download | bcm5719-llvm-4d7a07bdaf625e61a94f41b72f79165869ca79d8.tar.gz bcm5719-llvm-4d7a07bdaf625e61a94f41b72f79165869ca79d8.zip |
Handle throw d, where d is a class type but only has a trivial copy
constructor. WIP.
llvm-svn: 89438
Diffstat (limited to 'clang/lib')
-rw-r--r-- | clang/lib/CodeGen/CGException.cpp | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/clang/lib/CodeGen/CGException.cpp b/clang/lib/CodeGen/CGException.cpp index 3abc40775a8..fafdf87aabf 100644 --- a/clang/lib/CodeGen/CGException.cpp +++ b/clang/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. |