Lines Matching refs:CGF
113 ApplyNonVirtualAndVirtualOffset(CodeGenFunction &CGF, llvm::Value *ptr,
122 baseOffset = llvm::ConstantInt::get(CGF.PtrDiffTy,
125 baseOffset = CGF.Builder.CreateAdd(virtualOffset, baseOffset);
132 ptr = CGF.Builder.CreateBitCast(ptr, CGF.Int8PtrTy);
133 ptr = CGF.Builder.CreateInBoundsGEP(ptr, baseOffset, "add.ptr");
345 void Emit(CodeGenFunction &CGF, Flags flags) override {
347 cast<CXXMethodDecl>(CGF.CurCodeDecl)->getParent();
351 CGF.GetAddressOfDirectBaseInCompleteClass(CGF.LoadCXXThis(),
354 CGF.EmitCXXDestructorCall(D, Dtor_Base, BaseIsVirtual,
383 static void EmitBaseInitializer(CodeGenFunction &CGF,
390 llvm::Value *ThisPtr = CGF.LoadCXXThis();
405 if (BaseInitializerUsesThis(CGF.getContext(), BaseInit->getInit()))
406 CGF.InitializeVTablePointers(ClassDecl);
411 CGF.GetAddressOfDirectBaseInCompleteClass(ThisPtr, ClassDecl,
414 CharUnits Alignment = CGF.getContext().getTypeAlignInChars(BaseType);
421 CGF.EmitAggExpr(BaseInit->getInit(), AggSlot);
423 if (CGF.CGM.getLangOpts().Exceptions &&
425 CGF.EHStack.pushCleanup<CallBaseDtor>(EHCleanup, BaseClassDecl,
429 static void EmitAggMemberInitializer(CodeGenFunction &CGF,
443 llvm::Value *ArrayIndex = CGF.Builder.CreateLoad(ArrayIndexVar);
444 Dest = CGF.Builder.CreateInBoundsGEP(Dest, ArrayIndex, "destaddress");
446 Next = CGF.Builder.CreateAdd(ArrayIndex, Next, "inc");
447 CGF.Builder.CreateStore(Next, ArrayIndexVar);
451 CharUnits Align = CGF.getContext().getTypeAlignInChars(T);
455 switch (CGF.getEvaluationKind(T)) {
457 CGF.EmitScalarInit(Init, /*decl*/ nullptr, LV, false);
460 CGF.EmitComplexExprIntoLValue(Init, LV, /*isInit*/ true);
469 CGF.EmitAggExpr(Init, Slot);
477 const ConstantArrayType *Array = CGF.getContext().getAsConstantArrayType(T);
480 = CGF.GetAddrOfLocalVar(ArrayIndexes[Index]);
486 CGF.ConvertType(CGF.getContext().getSizeType()));
487 CGF.Builder.CreateStore(Zero, IndexVar);
490 llvm::BasicBlock *CondBlock = CGF.createBasicBlock("for.cond");
491 llvm::BasicBlock *AfterFor = CGF.createBasicBlock("for.end");
493 CGF.EmitBlock(CondBlock);
495 llvm::BasicBlock *ForBody = CGF.createBasicBlock("for.body");
499 llvm::Value *Counter = CGF.Builder.CreateLoad(IndexVar);
502 llvm::Value *IsLess = CGF.Builder.CreateICmpULT(Counter, NumElementsPtr,
506 CGF.Builder.CreateCondBr(IsLess, ForBody, AfterFor);
508 CGF.EmitBlock(ForBody);
509 llvm::BasicBlock *ContinueBlock = CGF.createBasicBlock("for.inc");
513 EmitAggMemberInitializer(CGF, LHS, Init, ArrayIndexVar,
516 CGF.EmitBlock(ContinueBlock);
520 Counter = CGF.Builder.CreateLoad(IndexVar);
521 NextVal = CGF.Builder.CreateAdd(Counter, NextVal, "inc");
522 CGF.Builder.CreateStore(NextVal, IndexVar);
525 CGF.EmitBranch(CondBlock);
528 CGF.EmitBlock(AfterFor, true);
531 static void EmitMemberInitializer(CodeGenFunction &CGF,
544 llvm::Value *ThisPtr = CGF.LoadCXXThis();
545 QualType RecordTy = CGF.getContext().getTypeDeclType(ClassDecl);
546 LValue LHS = CGF.MakeNaturalAlignAddrLValue(ThisPtr, RecordTy);
553 LHS = CGF.EmitLValueForFieldInitialization(LHS, cast<FieldDecl>(I));
556 LHS = CGF.EmitLValueForFieldInitialization(LHS, Field);
565 = CGF.getContext().getAsConstantArrayType(FieldType);
568 QualType BaseElementTy = CGF.getContext().getBaseElementType(Array);
570 if (BaseElementTy.isPODType(CGF.getContext()) ||
576 = CGF.Builder.CreateLoad(CGF.GetAddrOfLocalVar(Args[SrcArgIndex]));
577 LValue ThisRHSLV = CGF.MakeNaturalAlignAddrLValue(SrcPtr, RecordTy);
578 LValue Src = CGF.EmitLValueForFieldInitialization(ThisRHSLV, Field);
581 CGF.EmitAggregateCopy(LHS.getAddress(), Src.getAddress(), FieldType,
590 CGF.EmitInitializerForField(Field, LHS, MemberInit->getInit(), ArrayIndexes);
757 explicit CopyingValueRepresentation(CodeGenFunction &CGF)
758 : CGF(CGF), SO(*CGF.SanOpts), OldSanOpts(CGF.SanOpts) {
761 CGF.SanOpts = &SO;
764 CGF.SanOpts = OldSanOpts;
767 CodeGenFunction &CGF;
776 FieldMemcpyizer(CodeGenFunction &CGF, const CXXRecordDecl *ClassDecl,
778 : CGF(CGF), ClassDecl(ClassDecl), SrcRec(SrcRec),
779 RecLayout(CGF.getContext().getASTRecordLayout(ClassDecl)),
800 LastField->getBitWidthValue(CGF.getContext()) :
801 CGF.getContext().getTypeSize(LastField->getType());
804 CGF.getContext().getCharWidth() - 1;
806 CGF.getContext().toCharUnitsFromBits(MemcpySizeBits);
821 CGF.getTypes().getCGRecordLayout(FirstField->getParent());
825 Alignment = CGF.getContext().getDeclAlign(FirstField);
828 assert((CGF.getContext().toCharUnitsFromBits(FirstFieldOffset) %
832 QualType RecordTy = CGF.getContext().getTypeDeclType(ClassDecl);
833 llvm::Value *ThisPtr = CGF.LoadCXXThis();
834 LValue DestLV = CGF.MakeNaturalAlignAddrLValue(ThisPtr, RecordTy);
835 LValue Dest = CGF.EmitLValueForFieldInitialization(DestLV, FirstField);
836 llvm::Value *SrcPtr = CGF.Builder.CreateLoad(CGF.GetAddrOfLocalVar(SrcRec));
837 LValue SrcLV = CGF.MakeNaturalAlignAddrLValue(SrcPtr, RecordTy);
838 LValue Src = CGF.EmitLValueForFieldInitialization(SrcLV, FirstField);
851 CodeGenFunction &CGF;
860 llvm::Type::getInt8PtrTy(CGF.getLLVMContext(), DPT->getAddressSpace());
861 DestPtr = CGF.Builder.CreateBitCast(DestPtr, DBP);
865 CGF.getLLVMContext(), SPT->getAddressSpace());
866 SrcPtr = CGF.Builder.CreateBitCast(SrcPtr, SBP);
868 CGF.Builder.CreateMemCpy(DestPtr, SrcPtr, Size.getQuantity(),
935 !(FieldType.isTriviallyCopyableType(CGF.getContext()) ||
948 ConstructorMemcpyizer(CodeGenFunction &CGF, const CXXConstructorDecl *CD,
950 : FieldMemcpyizer(CGF, CD->getParent(), getTrivialCopySource(CD, Args)),
954 CGF.getLangOpts().getGC() == LangOptions::NonGC),
963 EmitMemberInitializer(CGF, ConstructorDecl->getParent(), MemberInit,
973 CopyingValueRepresentation CVR(CGF);
974 EmitMemberInitializer(CGF, ConstructorDecl->getParent(),
987 llvm::Value *ThisPtr = CGF.LoadCXXThis();
988 QualType RecordTy = CGF.getContext().getTypeDeclType(ClassDecl);
989 LValue LHS = CGF.MakeNaturalAlignAddrLValue(ThisPtr, RecordTy);
994 if (CGF.needsEHCleanup(dtorKind))
995 CGF.pushEHDestroy(dtorKind, LHS.getAddress(), FieldType);
1089 AssignmentMemcpyizer(CodeGenFunction &CGF, const CXXMethodDecl *AD,
1091 : FieldMemcpyizer(CGF, AD->getParent(), Args[Args.size() - 1]),
1092 AssignmentsMemcpyable(CGF.getLangOpts().getGC() == LangOptions::NonGC) {
1103 CGF.EmitStmt(S);
1110 CopyingValueRepresentation CVR(CGF);
1111 CGF.EmitStmt(AggregatedStmts[0]);
1364 void Emit(CodeGenFunction &CGF, Flags flags) override {
1365 const CXXDestructorDecl *Dtor = cast<CXXDestructorDecl>(CGF.CurCodeDecl);
1367 CGF.EmitDeleteCall(Dtor->getOperatorDelete(), CGF.LoadCXXThis(),
1368 CGF.getContext().getTagDeclType(ClassDecl));
1380 void Emit(CodeGenFunction &CGF, Flags flags) override {
1381 llvm::BasicBlock *callDeleteBB = CGF.createBasicBlock("dtor.call_delete");
1382 llvm::BasicBlock *continueBB = CGF.createBasicBlock("dtor.continue");
1384 = CGF.Builder.CreateIsNull(ShouldDeleteCondition);
1385 CGF.Builder.CreateCondBr(ShouldCallDelete, continueBB, callDeleteBB);
1387 CGF.EmitBlock(callDeleteBB);
1388 const CXXDestructorDecl *Dtor = cast<CXXDestructorDecl>(CGF.CurCodeDecl);
1390 CGF.EmitDeleteCall(Dtor->getOperatorDelete(), CGF.LoadCXXThis(),
1391 CGF.getContext().getTagDeclType(ClassDecl));
1392 CGF.Builder.CreateBr(continueBB);
1394 CGF.EmitBlock(continueBB);
1409 void Emit(CodeGenFunction &CGF, Flags flags) override {
1411 llvm::Value *thisValue = CGF.LoadCXXThis();
1412 QualType RecordTy = CGF.getContext().getTagDeclType(field->getParent());
1413 LValue ThisLV = CGF.MakeAddrLValue(thisValue, RecordTy);
1414 LValue LV = CGF.EmitLValueForField(ThisLV, field);
1417 CGF.emitDestroy(LV.getAddress(), field->getType(), destroyer,
1632 void CodeGenFunction::destroyCXXObject(CodeGenFunction &CGF,
1639 CGF.EmitCXXDestructorCall(dtor, Dtor_Complete, /*for vbase*/ false,
1784 void Emit(CodeGenFunction &CGF, Flags flags) override {
1785 CGF.EmitCXXDestructorCall(Dtor, Type, /*ForVirtualBase=*/false,
1836 void Emit(CodeGenFunction &CGF, Flags flags) override {
1837 CGF.EmitCXXDestructorCall(Dtor, Dtor_Complete,