]> granicus.if.org Git - clang/commitdiff
ir-gen for generating copying of scalar data members in
authorFariborz Jahanian <fjahanian@apple.com>
Mon, 10 Aug 2009 18:34:26 +0000 (18:34 +0000)
committerFariborz Jahanian <fjahanian@apple.com>
Mon, 10 Aug 2009 18:34:26 +0000 (18:34 +0000)
a synthesized copy constructor.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@78580 91177308-0d34-0410-b5e6-96231b3b80d8

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

index 55693d1073d945795ecf8dd0b9e61145b880ddc9..8f6cfc05ddcdc7b977f41341fa43115265ac65ce 100644 (file)
@@ -855,7 +855,11 @@ void CodeGenFunction::SynthesizeCXXCopyConstructor(const CXXConstructorDecl *CD,
                               0 /*ClassDecl*/, FieldClassDecl, FieldType);
       continue;
     }
-    // FIXME. Do a built-in assignment of scalar data members.
+    // 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);
   }
   FinishFunction();
 }  
index a993926f190b4ccb4a1cd3daf23e8332bbc06879..851a4ea60a56817bce39d566f344ab2e019f0fc5 100644 (file)
@@ -26,12 +26,21 @@ struct P {
 
 
 struct X  : M, N, P { // ...
-       X(){}
+       X() : f1(1.0), d1(2.0), i1(3), name("HELLO"), bf1(0xff), bf2(0xabcd) {}
         P p0;
        void pr() { printf("iM = %d iN = %d, m1.iM = %d\n", iM, iN, m1.iM); 
-                    printf("im = %d p0.iP = %d, p1.iP = %d\n", iP, p0.iP, p1.iP); }
+                    printf("im = %d p0.iP = %d, p1.iP = %d\n", iP, p0.iP, p1.iP); 
+                    printf("f1 = %f  d1 = %f  i1 = %d name(%s) \n", f1, d1, i1, name);
+                   printf("bf1 = %x  bf2 = %x\n", bf1, bf2);
+                   }
        M m1;
         P p1;
+       float f1;
+       double d1;
+       int i1;
+       const char *name;
+       unsigned bf1 : 8;
+        unsigned bf2 : 16;
 };
 
 int main()