diff options
author | John McCall <rjmccall@apple.com> | 2012-03-28 23:30:44 +0000 |
---|---|---|
committer | John McCall <rjmccall@apple.com> | 2012-03-28 23:30:44 +0000 |
commit | 57cd1b89cd91433ce1991a5bff36fe776a263796 (patch) | |
tree | 9d65d25e15649b8487c5a4e9fda2910c1a7dce74 /lib/CodeGen/CGClass.cpp | |
parent | b684a42154a555206a33ac47a52ad2a306cfa2b4 (diff) |
When we can't prove that the target of an aggregate copy is
a complete object, the memcpy needs to use the data size of
the structure instead of its sizeof() value. Fixes PR12204.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@153613 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/CGClass.cpp')
-rw-r--r-- | lib/CodeGen/CGClass.cpp | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/lib/CodeGen/CGClass.cpp b/lib/CodeGen/CGClass.cpp index b452c1b7ab..254ef8001d 100644 --- a/lib/CodeGen/CGClass.cpp +++ b/lib/CodeGen/CGClass.cpp @@ -401,7 +401,8 @@ static void EmitBaseInitializer(CodeGenFunction &CGF, AggValueSlot::forAddr(V, Alignment, Qualifiers(), AggValueSlot::IsDestructed, AggValueSlot::DoesNotNeedGCBarriers, - AggValueSlot::IsNotAliased); + AggValueSlot::IsNotAliased, + AggValueSlot::IsNotCompleteObject); CGF.EmitAggExpr(BaseInit->getInit(), AggSlot); @@ -449,7 +450,8 @@ static void EmitAggMemberInitializer(CodeGenFunction &CGF, AggValueSlot::forLValue(LV, AggValueSlot::IsDestructed, AggValueSlot::DoesNotNeedGCBarriers, - AggValueSlot::IsNotAliased); + AggValueSlot::IsNotAliased, + AggValueSlot::IsCompleteObject); CGF.EmitAggExpr(Init, Slot); } @@ -589,7 +591,8 @@ static void EmitMemberInitializer(CodeGenFunction &CGF, // Copy the aggregate. CGF.EmitAggregateCopy(LHS.getAddress(), Src.getAddress(), FieldType, - LHS.isVolatileQualified()); + LHS.isVolatileQualified(), + /*destIsCompleteObject*/ true); return; } } @@ -1371,7 +1374,10 @@ CodeGenFunction::EmitDelegatingCXXConstructorCall(const CXXConstructorDecl *Ctor AggValueSlot::forAddr(ThisPtr, Alignment, Qualifiers(), AggValueSlot::IsDestructed, AggValueSlot::DoesNotNeedGCBarriers, - AggValueSlot::IsNotAliased); + AggValueSlot::IsNotAliased, + CurGD.getCtorType() == Ctor_Complete + ? AggValueSlot::IsCompleteObject + : AggValueSlot::IsNotCompleteObject); EmitAggExpr(Ctor->init_begin()[0]->getInit(), AggSlot); |