[cfe-commits] r95457 - /cfe/trunk/lib/CodeGen/CGClass.cpp

John McCall rjmccall at apple.com
Fri Feb 5 16:25:16 PST 2010


Author: rjmccall
Date: Fri Feb  5 18:25:16 2010
New Revision: 95457

URL: http://llvm.org/viewvc/llvm-project?rev=95457&view=rev
Log:
Rearrange some checks to avoid call to isCopyConstructor() and clarify path
taken for non-trivial constructors.


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

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

==============================================================================
--- cfe/trunk/lib/CodeGen/CGClass.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGClass.cpp Fri Feb  5 18:25:16 2010
@@ -1227,20 +1227,22 @@
                                         llvm::Value *This,
                                         CallExpr::const_arg_iterator ArgBeg,
                                         CallExpr::const_arg_iterator ArgEnd) {
-  if (D->isCopyConstructor()) {
-    const CXXRecordDecl *ClassDecl = cast<CXXRecordDecl>(D->getDeclContext());
-    if (ClassDecl->hasTrivialCopyConstructor()) {
-      assert(!ClassDecl->hasUserDeclaredCopyConstructor() &&
-             "EmitCXXConstructorCall - user declared copy constructor");
-      const Expr *E = (*ArgBeg);
-      QualType Ty = E->getType();
-      llvm::Value *Src = EmitLValue(E).getAddress();
-      EmitAggregateCopy(This, Src, Ty);
+  if (D->isTrivial()) {
+    if (ArgBeg == ArgEnd) {
+      // Trivial default constructor, no codegen required.
+      assert(D->isDefaultConstructor() &&
+             "trivial 0-arg ctor not a default ctor");
       return;
     }
-  } else if (D->isTrivial()) {
-    // FIXME: Track down why we're trying to generate calls to the trivial
-    // default constructor!
+
+    assert(ArgBeg + 1 == ArgEnd && "unexpected argcount for trivial ctor");
+    assert(D->isCopyConstructor() && "trivial 1-arg ctor not a copy ctor");
+
+    const CXXRecordDecl *ClassDecl = cast<CXXRecordDecl>(D->getDeclContext());
+    const Expr *E = (*ArgBeg);
+    QualType Ty = E->getType();
+    llvm::Value *Src = EmitLValue(E).getAddress();
+    EmitAggregateCopy(This, Src, Ty);
     return;
   }
 





More information about the cfe-commits mailing list