On Feb 8, 2013, at 12:21 AM, Lang Hames <[email protected]> wrote:
> Thanks very much for all the help guys. I've attached an updated patch 
> incorporating your feedback. It also fixes a bug -  I had been memcpying 
> members with defaulted but non-trivial assignment operators.

+    // Get source argument for copy constructor. Returns null if not a copy
+    // constructor. 
+    static const VarDecl* getCCSrc(const CXXConstructorDecl *CD,
+                                   FunctionArgList &Args) {
+      if (CD->isCopyOrMoveConstructor() && CD->isImplicitlyDefined())
+        return Args[Args.size() - 1];
+      return 0; 
+    }
+

Please name this something like getTrivialCopySource and use /// comments.

 void CodeGenFunction::EmitCtorPrologue(const CXXConstructorDecl *CD,
@@ -770,8 +1107,15 @@
 
   InitializeVTablePointers(ClassDecl);
 
-  for (unsigned I = 0, E = MemberInitializers.size(); I != E; ++I)
-    EmitMemberInitializer(*this, ClassDecl, MemberInitializers[I], CD, Args);
+  if (getLangOpts().getGC() == LangOptions::NonGC) {
+    ConstructorMemcpyizer CM(*this, CD, Args);
+    for (unsigned I = 0, E = MemberInitializers.size(); I != E; ++I)
+      CM.addMemberInitializer(MemberInitializers[I]);
+    CM.finish();
+  } else {
+    for (unsigned I = 0, E = MemberInitializers.size(); I != E; ++I)
+      EmitMemberInitializer(*this, ClassDecl, MemberInitializers[I], CD, 
Args);                                                                          
                                                                                
                                                                                
                                  
+  }

You shouldn't need to split out specifically on GC mode here, since you're
already setting MemcpyableCtor based on that.

With those changes, go ahead and commit.

John.
_______________________________________________
cfe-commits mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits

Reply via email to