diff options
author | Fariborz Jahanian <fjahanian@apple.com> | 2009-08-10 18:34:26 +0000 |
---|---|---|
committer | Fariborz Jahanian <fjahanian@apple.com> | 2009-08-10 18:34:26 +0000 |
commit | 7cc52cf09f93bbc05f24b6f6fd3572a18d48c6da (patch) | |
tree | 02b8282481b721c52d4c42467915e7fee0e491ec | |
parent | 850e0f9e7e28d8b5c9815849805cbe7ce8c29f59 (diff) | |
download | bcm5719-llvm-7cc52cf09f93bbc05f24b6f6fd3572a18d48c6da.tar.gz bcm5719-llvm-7cc52cf09f93bbc05f24b6f6fd3572a18d48c6da.zip |
ir-gen for generating copying of scalar data members in
a synthesized copy constructor.
llvm-svn: 78580
-rw-r--r-- | clang/lib/CodeGen/CGCXX.cpp | 6 | ||||
-rw-r--r-- | clang/test/CodeGenCXX/copy-constructor-synthesis.cpp | 13 |
2 files changed, 16 insertions, 3 deletions
diff --git a/clang/lib/CodeGen/CGCXX.cpp b/clang/lib/CodeGen/CGCXX.cpp index 55693d1073d..8f6cfc05ddc 100644 --- a/clang/lib/CodeGen/CGCXX.cpp +++ b/clang/lib/CodeGen/CGCXX.cpp @@ -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(); } diff --git a/clang/test/CodeGenCXX/copy-constructor-synthesis.cpp b/clang/test/CodeGenCXX/copy-constructor-synthesis.cpp index a993926f190..851a4ea60a5 100644 --- a/clang/test/CodeGenCXX/copy-constructor-synthesis.cpp +++ b/clang/test/CodeGenCXX/copy-constructor-synthesis.cpp @@ -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() |