aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/CodeGen/CGClass.cpp
diff options
context:
space:
mode:
authorJohn McCall <rjmccall@apple.com>2012-03-28 23:30:44 +0000
committerJohn McCall <rjmccall@apple.com>2012-03-28 23:30:44 +0000
commit1a0877f99dc8130f3b85ab096bc03059e4c3cd0a (patch)
treeed675c50db4cc6b68ac8636470be7746e92b6814 /clang/lib/CodeGen/CGClass.cpp
parent7e58b3862a61b1297e1e6a12e14205d1d2df346b (diff)
downloadllvm-1a0877f99dc8130f3b85ab096bc03059e4c3cd0a.zip
llvm-1a0877f99dc8130f3b85ab096bc03059e4c3cd0a.tar.gz
llvm-1a0877f99dc8130f3b85ab096bc03059e4c3cd0a.tar.bz2
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. llvm-svn: 153613
Diffstat (limited to 'clang/lib/CodeGen/CGClass.cpp')
-rw-r--r--clang/lib/CodeGen/CGClass.cpp14
1 files changed, 10 insertions, 4 deletions
diff --git a/clang/lib/CodeGen/CGClass.cpp b/clang/lib/CodeGen/CGClass.cpp
index b452c1b..254ef80 100644
--- a/clang/lib/CodeGen/CGClass.cpp
+++ b/clang/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);