diff options
Diffstat (limited to 'contrib/llvm/tools/clang/lib/CodeGen/CGClass.cpp')
-rw-r--r-- | contrib/llvm/tools/clang/lib/CodeGen/CGClass.cpp | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/contrib/llvm/tools/clang/lib/CodeGen/CGClass.cpp b/contrib/llvm/tools/clang/lib/CodeGen/CGClass.cpp index 6303e20..2aedf95 100644 --- a/contrib/llvm/tools/clang/lib/CodeGen/CGClass.cpp +++ b/contrib/llvm/tools/clang/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, |