Lines Matching full:cgf
225 ApplyNonVirtualAndVirtualOffset(CodeGenFunction &CGF, Address addr,
236 baseOffset = llvm::ConstantInt::get(CGF.PtrDiffTy,
239 baseOffset = CGF.Builder.CreateAdd(virtualOffset, baseOffset);
247 ptr = CGF.Builder.CreateBitCast(ptr, CGF.Int8PtrTy);
248 ptr = CGF.Builder.CreateInBoundsGEP(ptr, baseOffset, "add.ptr");
255 alignment = CGF.CGM.getVBaseAlignment(addr.getAlignment(),
482 void Emit(CodeGenFunction &CGF, Flags flags) override {
484 cast<CXXMethodDecl>(CGF.CurCodeDecl)->getParent();
488 CGF.GetAddressOfDirectBaseInCompleteClass(CGF.LoadCXXThisAddress(),
491 CGF.EmitCXXDestructorCall(D, Dtor_Base, BaseIsVirtual,
520 static void EmitBaseInitializer(CodeGenFunction &CGF,
527 Address ThisPtr = CGF.LoadCXXThisAddress();
542 if (BaseInitializerUsesThis(CGF.getContext(), BaseInit->getInit()))
543 CGF.InitializeVTablePointers(ClassDecl);
548 CGF.GetAddressOfDirectBaseInCompleteClass(ThisPtr, ClassDecl,
557 CGF.EmitAggExpr(BaseInit->getInit(), AggSlot);
559 if (CGF.CGM.getLangOpts().Exceptions &&
561 CGF.EHStack.pushCleanup<CallBaseDtor>(EHCleanup, BaseClassDecl,
565 static void EmitAggMemberInitializer(CodeGenFunction &CGF,
579 llvm::Value *ArrayIndex = CGF.Builder.CreateLoad(ArrayIndexVar);
580 Dest = CGF.Builder.CreateInBoundsGEP(Dest, ArrayIndex, "destaddress");
582 Next = CGF.Builder.CreateAdd(ArrayIndex, Next, "inc");
583 CGF.Builder.CreateStore(Next, ArrayIndexVar);
586 CharUnits EltSize = CGF.getContext().getTypeSizeInChars(T);
591 switch (CGF.getEvaluationKind(T)) {
593 CGF.EmitScalarInit(Init, /*decl*/ nullptr, LV, false);
596 CGF.EmitComplexExprIntoLValue(Init, LV, /*isInit*/ true);
605 CGF.EmitAggExpr(Init, Slot);
613 const ConstantArrayType *Array = CGF.getContext().getAsConstantArrayType(T);
615 Address IndexVar = CGF.GetAddrOfLocalVar(ArrayIndexes[Index]);
620 CGF.Builder.CreateStore(Zero, IndexVar);
623 llvm::BasicBlock *CondBlock = CGF.createBasicBlock("for.cond");
624 llvm::BasicBlock *AfterFor = CGF.createBasicBlock("for.end");
626 CGF.EmitBlock(CondBlock);
628 llvm::BasicBlock *ForBody = CGF.createBasicBlock("for.body");
632 llvm::Value *Counter = CGF.Builder.CreateLoad(IndexVar);
635 llvm::Value *IsLess = CGF.Builder.CreateICmpULT(Counter, NumElementsPtr,
639 CGF.Builder.CreateCondBr(IsLess, ForBody, AfterFor);
641 CGF.EmitBlock(ForBody);
642 llvm::BasicBlock *ContinueBlock = CGF.createBasicBlock("for.inc");
646 EmitAggMemberInitializer(CGF, LHS, Init, ArrayIndexVar,
649 CGF.EmitBlock(ContinueBlock);
653 Counter = CGF.Builder.CreateLoad(IndexVar);
654 NextVal = CGF.Builder.CreateAdd(Counter, NextVal, "inc");
655 CGF.Builder.CreateStore(NextVal, IndexVar);
658 CGF.EmitBranch(CondBlock);
661 CGF.EmitBlock(AfterFor, true);
681 static void EmitLValueForAnyFieldInitialization(CodeGenFunction &CGF,
689 LHS = CGF.EmitLValueForFieldInitialization(LHS, cast<FieldDecl>(I));
691 LHS = CGF.EmitLValueForFieldInitialization(LHS, Field);
695 static void EmitMemberInitializer(CodeGenFunction &CGF,
700 ApplyDebugLocation Loc(CGF, MemberInit->getSourceLocation());
709 llvm::Value *ThisPtr = CGF.LoadCXXThis();
710 QualType RecordTy = CGF.getContext().getTypeDeclType(ClassDecl);
711 LValue LHS = CGF.MakeNaturalAlignAddrLValue(ThisPtr, RecordTy);
713 EmitLValueForAnyFieldInitialization(CGF, MemberInit, LHS);
721 = CGF.getContext().getAsConstantArrayType(FieldType);
724 QualType BaseElementTy = CGF.getContext().getBaseElementType(Array);
726 if (BaseElementTy.isPODType(CGF.getContext()) ||
729 CGF.CGM.getCXXABI().getSrcArgforCopyCtor(Constructor, Args);
731 = CGF.Builder.CreateLoad(CGF.GetAddrOfLocalVar(Args[SrcArgIndex]));
732 LValue ThisRHSLV = CGF.MakeNaturalAlignAddrLValue(SrcPtr, RecordTy);
733 LValue Src = CGF.EmitLValueForFieldInitialization(ThisRHSLV, Field);
736 CGF.EmitAggregateCopy(LHS.getAddress(), Src.getAddress(), FieldType,
741 if (CGF.needsEHCleanup(dtorKind))
742 CGF.pushEHDestroy(dtorKind, LHS.getAddress(), FieldType);
750 CGF.EmitInitializerForField(Field, LHS, MemberInit->getInit(), ArrayIndexes);
978 explicit CopyingValueRepresentation(CodeGenFunction &CGF)
979 : CGF(CGF), OldSanOpts(CGF.SanOpts) {
980 CGF.SanOpts.set(SanitizerKind::Bool, false);
981 CGF.SanOpts.set(SanitizerKind::Enum, false);
984 CGF.SanOpts = OldSanOpts;
987 CodeGenFunction &CGF;
995 FieldMemcpyizer(CodeGenFunction &CGF, const CXXRecordDecl *ClassDecl,
997 : CGF(CGF), ClassDecl(ClassDecl), SrcRec(SrcRec),
998 RecLayout(CGF.getContext().getASTRecordLayout(ClassDecl)),
1004 if (CGF.getContext().getLangOpts().SanitizeAddressFieldPadding)
1022 LastField->getBitWidthValue(CGF.getContext()) :
1023 CGF.getContext().getTypeSize(LastField->getType());
1026 CGF.getContext().getCharWidth() - 1;
1028 CGF.getContext().toCharUnitsFromBits(MemcpySizeBits);
1042 CGF.getTypes().getCGRecordLayout(FirstField->getParent());
1046 FirstByteOffset = CGF.getContext().toBits(BFInfo.StorageOffset);
1052 QualType RecordTy = CGF.getContext().getTypeDeclType(ClassDecl);
1053 Address ThisPtr = CGF.LoadCXXThisAddress();
1054 LValue DestLV = CGF.MakeAddrLValue(ThisPtr, RecordTy);
1055 LValue Dest = CGF.EmitLValueForFieldInitialization(DestLV, FirstField);
1056 llvm::Value *SrcPtr = CGF.Builder.CreateLoad(CGF.GetAddrOfLocalVar(SrcRec));
1057 LValue SrcLV = CGF.MakeNaturalAlignAddrLValue(SrcPtr, RecordTy);
1058 LValue Src = CGF.EmitLValueForFieldInitialization(SrcLV, FirstField);
1071 CodeGenFunction &CGF;
1078 llvm::Type::getInt8PtrTy(CGF.getLLVMContext(), DPT->getAddressSpace());
1079 DestPtr = CGF.Builder.CreateBitCast(DestPtr, DBP);
1083 llvm::Type::getInt8PtrTy(CGF.getLLVMContext(), SPT->getAddressSpace());
1084 SrcPtr = CGF.Builder.CreateBitCast(SrcPtr, SBP);
1086 CGF.Builder.CreateMemCpy(DestPtr, SrcPtr, Size.getQuantity());
1131 static const VarDecl *getTrivialCopySource(CodeGenFunction &CGF,
1135 return Args[CGF.CGM.getCXXABI().getSrcArgforCopyCtor(CD, Args)];
1151 !(FieldType.isTriviallyCopyableType(CGF.getContext()) ||
1164 ConstructorMemcpyizer(CodeGenFunction &CGF, const CXXConstructorDecl *CD,
1166 : FieldMemcpyizer(CGF, CD->getParent(), getTrivialCopySource(CGF, CD, Args)),
1170 CGF.getLangOpts().getGC() == LangOptions::NonGC),
1179 EmitMemberInitializer(CGF, ConstructorDecl->getParent(), MemberInit,
1189 CopyingValueRepresentation CVR(CGF);
1190 EmitMemberInitializer(CGF, ConstructorDecl->getParent(),
1204 Address ThisPtr = CGF.LoadCXXThisAddress();
1205 QualType RecordTy = CGF.getContext().getTypeDeclType(ClassDecl);
1206 LValue LHS = CGF.MakeAddrLValue(ThisPtr, RecordTy);
1212 if (!CGF.needsEHCleanup(dtorKind))
1215 EmitLValueForAnyFieldInitialization(CGF, MemberInit, FieldLHS);
1216 CGF.pushEHDestroy(dtorKind, FieldLHS.getAddress(), FieldType);
1306 AssignmentMemcpyizer(CodeGenFunction &CGF, const CXXMethodDecl *AD,
1308 : FieldMemcpyizer(CGF, AD->getParent(), Args[Args.size() - 1]),
1309 AssignmentsMemcpyable(CGF.getLangOpts().getGC() == LangOptions::NonGC) {
1320 CGF.EmitStmt(S);
1327 CopyingValueRepresentation CVR(CGF);
1328 CGF.EmitStmt(AggregatedStmts[0]);
1484 static bool CanSkipVTablePointerInitialization(CodeGenFunction &CGF,
1495 if (!FieldHasTrivialDestructorBody(CGF.getContext(), Field))
1618 void Emit(CodeGenFunction &CGF, Flags flags) override {
1619 const CXXDestructorDecl *Dtor = cast<CXXDestructorDecl>(CGF.CurCodeDecl);
1621 CGF.EmitDeleteCall(Dtor->getOperatorDelete(), CGF.LoadCXXThis(),
1622 CGF.getContext().getTagDeclType(ClassDecl));
1635 void Emit(CodeGenFunction &CGF, Flags flags) override {
1636 llvm::BasicBlock *callDeleteBB = CGF.createBasicBlock("dtor.call_delete");
1637 llvm::BasicBlock *continueBB = CGF.createBasicBlock("dtor.continue");
1639 = CGF.Builder.CreateIsNull(ShouldDeleteCondition);
1640 CGF.Builder.CreateCondBr(ShouldCallDelete, continueBB, callDeleteBB);
1642 CGF.EmitBlock(callDeleteBB);
1643 const CXXDestructorDecl *Dtor = cast<CXXDestructorDecl>(CGF.CurCodeDecl);
1645 CGF.EmitDeleteCall(Dtor->getOperatorDelete(), CGF.LoadCXXThis(),
1646 CGF.getContext().getTagDeclType(ClassDecl));
1647 CGF.Builder.CreateBr(continueBB);
1649 CGF.EmitBlock(continueBB);
1664 void Emit(CodeGenFunction &CGF, Flags flags) override {
1666 Address thisValue = CGF.LoadCXXThisAddress();
1667 QualType RecordTy = CGF.getContext().getTagDeclType(field->getParent());
1668 LValue ThisLV = CGF.MakeAddrLValue(thisValue, RecordTy);
1669 LValue LV = CGF.EmitLValueForField(ThisLV, field);
1672 CGF.emitDestroy(LV.getAddress(), field->getType(), destroyer,
1677 static void EmitSanitizerDtorCallback(CodeGenFunction &CGF, llvm::Value *Ptr,
1681 llvm::Value *Args[] = {CGF.Builder.CreateBitCast(Ptr, CGF.VoidPtrTy),
1682 llvm::ConstantInt::get(CGF.SizeTy, PoisonSize)};
1684 llvm::Type *ArgTypes[] = {CGF.VoidPtrTy, CGF.SizeTy};
1687 llvm::FunctionType::get(CGF.VoidTy, ArgTypes, false);
1689 CGF.CGM.CreateRuntimeFunction(FnType, "__sanitizer_dtor_callback");
1690 CGF.EmitNounwindRuntimeCall(Fn, Args);
1702 void Emit(CodeGenFunction &CGF, Flags flags) override {
1704 CGF.getContext().getASTRecordLayout(Dtor->getParent());
1711 CGF.CurFn->addFnAttr("disable-tail-calls", "true");
1715 ASTContext &Context = CGF.getContext();
1729 PoisonMembers(CGF, startIndex, Layout.getFieldCount());
1733 PoisonMembers(CGF, startIndex, fieldIndex);
1746 void PoisonMembers(CodeGenFunction &CGF, unsigned layoutStartOffset,
1748 ASTContext &Context = CGF.getContext();
1753 CGF.SizeTy,
1757 llvm::Value *OffsetPtr = CGF.Builder.CreateGEP(
1758 CGF.Builder.CreateBitCast(CGF.LoadCXXThis(), CGF.Int8PtrTy),
1777 EmitSanitizerDtorCallback(CGF, OffsetPtr, PoisonSize);
1788 void Emit(CodeGenFunction &CGF, Flags flags) override {
1791 ASTContext &Context = CGF.getContext();
1793 llvm::Value *VTablePtr = CGF.LoadCXXThis();
1796 Context.toCharUnitsFromBits(CGF.PointerWidthInBits).getQuantity();
1799 EmitSanitizerDtorCallback(CGF, VTablePtr, PoisonSize);
2035 void CodeGenFunction::destroyCXXObject(CodeGenFunction &CGF,
2042 CGF.EmitCXXDestructorCall(dtor, Dtor_Complete, /*for vbase*/ false,
2077 static bool canEmitDelegateCallArgs(CodeGenFunction &CGF,
2084 if (CGF.getTarget().getCXXABI().areArgsDestroyedLeftToRightInCallee()) {
2092 CGF.CGM.getTypes().arrangeCXXConstructorCall(Args, Ctor, Type, 0);
2358 void Emit(CodeGenFunction &CGF, Flags flags) override {
2359 CGF.EmitCXXDestructorCall(Dtor, Type, /*ForVirtualBase=*/false,
2408 void Emit(CodeGenFunction &CGF, Flags flags) override {
2409 CGF.EmitCXXDestructorCall(Dtor, Dtor_Complete,