]> granicus.if.org Git - clang/commitdiff
Implement a few more cases for copy constructor synthesis.
authorEli Friedman <eli.friedman@gmail.com>
Mon, 16 Nov 2009 21:47:41 +0000 (21:47 +0000)
committerEli Friedman <eli.friedman@gmail.com>
Mon, 16 Nov 2009 21:47:41 +0000 (21:47 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@88971 91177308-0d34-0410-b5e6-96231b3b80d8

lib/CodeGen/CGCXX.cpp
test/CodeGenCXX/copy-constructor-synthesis.cpp

index a3ab476511dec9e48f02445bef43d4a75551729c..02d5c513af4d187c81b9afc676adf8967b39f237 100644 (file)
@@ -1381,8 +1381,16 @@ CodeGenFunction::SynthesizeCXXCopyConstructor(const CXXConstructorDecl *Ctor,
     // Do a built-in assignment of scalar data members.
     LValue LHS = EmitLValueForField(LoadOfThis, *Field, false, 0);
     LValue RHS = EmitLValueForField(LoadOfSrc, *Field, false, 0);
-    RValue RVRHS = EmitLoadOfLValue(RHS, FieldType);
-    EmitStoreThroughLValue(RVRHS, LHS, FieldType);
+    if (!hasAggregateLLVMType(Field->getType())) {
+      RValue RVRHS = EmitLoadOfLValue(RHS, Field->getType());
+      EmitStoreThroughLValue(RVRHS, LHS, Field->getType());
+    } else if (Field->getType()->isAnyComplexType()) {
+      ComplexPairTy Pair = LoadComplexFromAddr(RHS.getAddress(),
+                                               RHS.isVolatileQualified());
+      StoreComplexToAddr(Pair, LHS.getAddress(), LHS.isVolatileQualified());
+    } else {
+      EmitAggregateCopy(LHS.getAddress(), RHS.getAddress(), Field->getType());
+    }
   }
   FinishFunction();
 }
index 60552a38931c86066d662d002958eff717d517c6..3b8f7821abcf3a2162f0ab0498f97bfe566200ce 100644 (file)
@@ -44,6 +44,8 @@ struct X  : M, N, P { // ...
   const char *name;
   unsigned bf1 : 8;
   unsigned bf2 : 16;
+  int arr[2];
+  _Complex float complex;
 
   union {
     int au_i1;