[cfe-commits] r89438 - /cfe/trunk/lib/CodeGen/CGException.cpp

Mike Stump mrs at apple.com
Thu Nov 19 17:57:39 PST 2009


Author: mrs
Date: Thu Nov 19 19:57:39 2009
New Revision: 89438

URL: http://llvm.org/viewvc/llvm-project?rev=89438&view=rev
Log:
Handle throw d, where d is a class type but only has a trivial copy
constructor.  WIP.

Modified:
    cfe/trunk/lib/CodeGen/CGException.cpp

Modified: cfe/trunk/lib/CodeGen/CGException.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGException.cpp?rev=89438&r1=89437&r2=89438&view=diff

==============================================================================
--- cfe/trunk/lib/CodeGen/CGException.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGException.cpp Thu Nov 19 19:57:39 2009
@@ -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.





More information about the cfe-commits mailing list