diff options
author | Dimitry Andric <dim@FreeBSD.org> | 2012-05-03 16:53:59 +0000 |
---|---|---|
committer | Dimitry Andric <dim@FreeBSD.org> | 2012-05-03 16:53:59 +0000 |
commit | 6b9a6e390fbb92c40eb9c6ac9e7abbd88dd7a767 (patch) | |
tree | 2e51705e103e92c7be1b21e8bd8ffd5b5d0e4d52 /lib/CodeGen/CGClass.cpp | |
parent | dbe13110f59f48b4dbb7552b3ac2935acdeece7f (diff) |
Notes
Diffstat (limited to 'lib/CodeGen/CGClass.cpp')
-rw-r--r-- | lib/CodeGen/CGClass.cpp | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/lib/CodeGen/CGClass.cpp b/lib/CodeGen/CGClass.cpp index 6303e2069d58f..2aedf95e6a11e 100644 --- a/lib/CodeGen/CGClass.cpp +++ b/lib/CodeGen/CGClass.cpp @@ -555,15 +555,17 @@ static void EmitMemberInitializer(CodeGenFunction &CGF, QualType FieldType = Field->getType(); llvm::Value *ThisPtr = CGF.LoadCXXThis(); + QualType RecordTy = CGF.getContext().getTypeDeclType(ClassDecl); LValue LHS; - + // If we are initializing an anonymous union field, drill down to the field. if (MemberInit->isIndirectMemberInitializer()) { LHS = CGF.EmitLValueForAnonRecordField(ThisPtr, MemberInit->getIndirectMember(), 0); FieldType = MemberInit->getIndirectMember()->getAnonField()->getType(); } else { - LHS = CGF.EmitLValueForFieldInitialization(ThisPtr, Field, 0); + LValue ThisLHSLV = CGF.MakeNaturalAlignAddrLValue(ThisPtr, RecordTy); + LHS = CGF.EmitLValueForFieldInitialization(ThisLHSLV, Field); } // Special case: if we are in a copy or move constructor, and we are copying @@ -585,7 +587,8 @@ static void EmitMemberInitializer(CodeGenFunction &CGF, unsigned SrcArgIndex = Args.size() - 1; llvm::Value *SrcPtr = CGF.Builder.CreateLoad(CGF.GetAddrOfLocalVar(Args[SrcArgIndex])); - LValue Src = CGF.EmitLValueForFieldInitialization(SrcPtr, Field, 0); + LValue ThisRHSLV = CGF.MakeNaturalAlignAddrLValue(SrcPtr, RecordTy); + LValue Src = CGF.EmitLValueForFieldInitialization(ThisRHSLV, Field); // Copy the aggregate. CGF.EmitAggregateCopy(LHS.getAddress(), Src.getAddress(), FieldType, @@ -978,7 +981,9 @@ namespace { void Emit(CodeGenFunction &CGF, Flags flags) { // Find the address of the field. llvm::Value *thisValue = CGF.LoadCXXThis(); - LValue LV = CGF.EmitLValueForField(thisValue, field, /*CVRQualifiers=*/0); + QualType RecordTy = CGF.getContext().getTagDeclType(field->getParent()); + LValue ThisLV = CGF.MakeAddrLValue(thisValue, RecordTy); + LValue LV = CGF.EmitLValueForField(ThisLV, field); assert(LV.isSimple()); CGF.emitDestroy(LV.getAddress(), field->getType(), destroyer, |