diff options
author | Sebastian Redl <sebastian.redl@getdesigned.at> | 2011-08-30 19:58:05 +0000 |
---|---|---|
committer | Sebastian Redl <sebastian.redl@getdesigned.at> | 2011-08-30 19:58:05 +0000 |
commit | 85ea7aa961deac1d754f610af8062ae3f8b4e2a5 (patch) | |
tree | d780103715ecc52cfee9c776ca760dc9818b0268 /lib/CodeGen/CGClass.cpp | |
parent | 955fadbdfecfa24a590febe66a86519096787f2d (diff) |
Declare and define implicit move constructor and assignment operator.
This makes the code duplication of implicit special member handling even worse,
but the cleanup will have to come later. For now, this works.
Follow-up with tests for explicit defaulting and enabling the __has_feature
flag to come.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@138821 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/CGClass.cpp')
-rw-r--r-- | lib/CodeGen/CGClass.cpp | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/lib/CodeGen/CGClass.cpp b/lib/CodeGen/CGClass.cpp index 8bdfbf1231..6e0e1d418f 100644 --- a/lib/CodeGen/CGClass.cpp +++ b/lib/CodeGen/CGClass.cpp @@ -527,6 +527,12 @@ namespace { } }; } + +static bool hasTrivialCopyOrMoveConstructor(const CXXRecordDecl *Record, + bool Moving) { + return Moving ? Record->hasTrivialMoveConstructor() : + Record->hasTrivialCopyConstructor(); +} static void EmitMemberInitializer(CodeGenFunction &CGF, const CXXRecordDecl *ClassDecl, @@ -572,7 +578,7 @@ static void EmitMemberInitializer(CodeGenFunction &CGF, const ConstantArrayType *Array = CGF.getContext().getAsConstantArrayType(FieldType); if (Array && Constructor->isImplicit() && - Constructor->isCopyConstructor()) { + Constructor->isCopyOrMoveConstructor()) { llvm::Type *SizeTy = CGF.ConvertType(CGF.getContext().getSizeType()); @@ -595,7 +601,8 @@ static void EmitMemberInitializer(CodeGenFunction &CGF, // constructors, perform a single aggregate copy. const CXXRecordDecl *Record = BaseElementTy->getAsCXXRecordDecl(); if (BaseElementTy.isPODType(CGF.getContext()) || - (Record && Record->hasTrivialCopyConstructor())) { + (Record && hasTrivialCopyOrMoveConstructor(Record, + Constructor->isMoveConstructor()))) { // Find the source pointer. We knows it's the last argument because // we know we're in a copy constructor. unsigned SrcArgIndex = Args.size() - 1; @@ -1201,7 +1208,8 @@ CodeGenFunction::EmitCXXConstructorCall(const CXXConstructorDecl *D, } assert(ArgBeg + 1 == ArgEnd && "unexpected argcount for trivial ctor"); - assert(D->isCopyConstructor() && "trivial 1-arg ctor not a copy ctor"); + assert(D->isCopyOrMoveConstructor() && + "trivial 1-arg ctor not a copy/move ctor"); const Expr *E = (*ArgBeg); QualType Ty = E->getType(); @@ -1223,7 +1231,8 @@ CodeGenFunction::EmitSynthesizedCXXCopyCtorCall(const CXXConstructorDecl *D, CallExpr::const_arg_iterator ArgEnd) { if (D->isTrivial()) { assert(ArgBeg + 1 == ArgEnd && "unexpected argcount for trivial ctor"); - assert(D->isCopyConstructor() && "trivial 1-arg ctor not a copy ctor"); + assert(D->isCopyOrMoveConstructor() && + "trivial 1-arg ctor not a copy/move ctor"); EmitAggregateCopy(This, Src, (*ArgBeg)->getType()); return; } |