;
25using namespaceCodeGen;
28structMemberCallInfo {
37llvm::Value *This, llvm::Value *ImplicitParam,
40 auto*MD = cast<CXXMethodDecl>(GD.
getDecl());
42assert(CE ==
nullptr|| isa<CXXMemberCallExpr>(CE) ||
43isa<CXXOperatorCallExpr>(CE));
44assert(MD->isImplicitObjectMemberFunction() &&
45 "Trying to emit a member or operator call expr on a static method!");
59 unsignedPrefixSize = Args.size() - 1;
69 unsignedArgsToSkip = 0;
70 if(
const auto*Op = dyn_cast<CXXOperatorCallExpr>(CE)) {
71 if(
const auto*M = dyn_cast<CXXMethodDecl>(Op->getCalleeDecl()))
73 static_cast<unsigned>(!M->isExplicitObjectMemberFunction());
80 "No CallExpr specified for function with non-zero number of arguments");
82 return{required, PrefixSize};
85RValueCodeGenFunction::EmitCXXMemberOrOperatorCall(
87 ReturnValueSlotReturnValue, llvm::Value *This, llvm::Value *ImplicitParam,
89llvm::CallBase **CallOrInvoke) {
93*
this, MD, This, ImplicitParam, ImplicitParamTy, CE, Args, RtlArgs);
95Args, FPT, CallInfo.ReqArgs, CallInfo.PrefixSize);
104llvm::CallBase **CallOrInvoke) {
107assert(!ThisTy.
isNull());
109 "Pointer/Object mixup");
113 if(SrcAS != DstAS) {
122ImplicitParamTy, CE, Args,
nullptr);
131 QualTypeDestroyedType =
E->getDestroyedType();
136 Expr*BaseExpr =
E->getBase();
141 if(
E->isArrow()) {
144BaseQuals = PTy->getPointeeType().getQualifiers();
185 returncast<CXXRecordDecl>(Ty->
getDecl());
192llvm::CallBase **CallOrInvoke) {
195 if(isa<BinaryOperator>(callee))
198 const MemberExpr*ME = cast<MemberExpr>(callee);
211 boolIsArrow = ME->
isArrow();
215HasQualifier, Qualifier, IsArrow,
216 Base, CallOrInvoke);
222 const Expr*
Base, llvm::CallBase **CallOrInvoke) {
223assert(isa<CXXMemberCallExpr>(CE) || isa<CXXOperatorCallExpr>(CE));
226 boolCanUseVirtualCall = MD->
isVirtual() && !HasQualifier;
229 if(CanUseVirtualCall &&
233assert(DevirtualizedMethod);
235 const Expr*Inner =
Base->IgnoreParenBaseCasts();
243DevirtualizedMethod =
nullptr;
253DevirtualizedMethod =
nullptr;
257 boolTrivialForCodegen =
259 boolTrivialAssignment =
268 LValueTrivialAssignmentRHS;
269 if(
auto*OCE = dyn_cast<CXXOperatorCallExpr>(CE)) {
270 if(OCE->isAssignmentOp()) {
271 if(TrivialAssignment) {
274RtlArgs = &RtlArgStorage;
297assert(
ReturnValue.isNull() &&
"Constructor shouldn't have return value");
305 false,
This.getAddress(), Args,
307 false, CallOrInvoke);
311 if(TrivialForCodegen) {
312 if(isa<CXXDestructorDecl>(MD))
315 if(TrivialAssignment) {
321 LValueRHS = isa<CXXOperatorCallExpr>(CE)
322? TrivialAssignmentRHS
329 "unknown trivial member function");
334DevirtualizedMethod ? DevirtualizedMethod : MD;
336 if(
const auto*Dtor = dyn_cast<CXXDestructorDecl>(CalleeDecl))
353 if(
const auto*CMCE = dyn_cast<CXXMemberCallExpr>(CE)) {
354 auto*IOA = CMCE->getImplicitObjectArgument();
356 if(IsImplicitObjectCXXThis)
357SkippedChecks.
set(SanitizerKind::Alignment,
true);
358 if(IsImplicitObjectCXXThis || isa<DeclRefExpr>(IOA))
359SkippedChecks.
set(SanitizerKind::Null,
true);
364 This.emitRawPointer(*
this),
374 boolUseVirtualCall = CanUseVirtualCall && !DevirtualizedMethod;
378 "Destructor shouldn't have explicit parameters");
379assert(
ReturnValue.isNull() &&
"Destructor shouldn't have return value");
380 if(UseVirtualCall) {
383cast<CXXMemberCallExpr>(CE), CallOrInvoke);
387 if(
getLangOpts().AppleKext && Dtor->isVirtual() && HasQualifier)
389 else if(!DevirtualizedMethod)
397IsArrow ?
Base->getType()->getPointeeType() :
Base->getType();
409 if(UseVirtualCall) {
412 if(
SanOpts.
has(SanitizerKind::CFINVCall) &&
423 else if(!DevirtualizedMethod)
436*
this, CalleeDecl,
This.getAddress(), UseVirtualCall);
437 This.setAddress(NewThisAddr);
442 nullptr,
QualType(), CE, RtlArgs, CallOrInvoke);
448llvm::CallBase **CallOrInvoke) {
473llvm::Value *ThisPtrForCall =
nullptr;
476ThisPtrForCall, MemFnPtr, MPT);
500 "Trying to emit a member call expr on a static method!");
503 false,
E->getArg(0), CallOrInvoke);
508llvm::CallBase **CallOrInvoke) {
516 if(
Base->isEmpty())
532std::vector<CharUnits> VBPtrOffsets =
534 for(
CharUnitsVBPtrOffset : VBPtrOffsets) {
536 if(VBPtrOffset >= NVSize)
538std::pair<CharUnits, CharUnits> LastStore = Stores.pop_back_val();
539 CharUnitsLastStoreOffset = LastStore.first;
540 CharUnitsLastStoreSize = LastStore.second;
542 CharUnitsSplitBeforeOffset = LastStoreOffset;
543 CharUnitsSplitBeforeSize = VBPtrOffset - SplitBeforeOffset;
544assert(!SplitBeforeSize.
isNegative() &&
"negative store size!");
545 if(!SplitBeforeSize.
isZero())
546Stores.emplace_back(SplitBeforeOffset, SplitBeforeSize);
548 CharUnitsSplitAfterOffset = VBPtrOffset + VBPtrWidth;
549 CharUnitsSplitAfterSize = LastStoreSize - SplitAfterOffset;
550assert(!SplitAfterSize.
isNegative() &&
"negative store size!");
551 if(!SplitAfterSize.
isZero())
552Stores.emplace_back(SplitAfterOffset, SplitAfterSize);
562 if(!NullConstantForBase->isNullValue()) {
563llvm::GlobalVariable *NullVariable =
newllvm::GlobalVariable(
564CGF.
CGM.
getModule(), NullConstantForBase->getType(),
565 true, llvm::GlobalVariable::PrivateLinkage,
566NullConstantForBase, Twine());
570NullVariable->setAlignment(Align.
getAsAlign());
575 for(std::pair<CharUnits, CharUnits> Store : Stores) {
578llvm::Value *StoreSizeVal = CGF.
CGM.
getSize(StoreSize);
589 for(std::pair<CharUnits, CharUnits> Store : Stores) {
592llvm::Value *StoreSizeVal = CGF.
CGM.
getSize(StoreSize);
595CGF.
Builder.getInt8(0), StoreSizeVal);
603assert(!Dest.
isIgnored() &&
"Must have a destination!");
610 if(
E->requiresZeroInitialization() && !Dest.
isZeroed()) {
611 switch(
E->getConstructionKind()) {
629 if(
getLangOpts().ElideConstructors &&
E->isElidable()) {
635 const Expr*SrcObj =
E->getArg(0);
649 boolForVirtualBase =
false;
652 switch(
E->getConstructionKind()) {
664ForVirtualBase =
true;
679Exp =
E->getSubExpr();
680assert(isa<CXXConstructExpr>(Exp) &&
681 "EmitSynthesizedCXXCopyCtor - unknown copy ctor expr");
684RunCleanupsScope
Scope(*
this);
690 if(
E->requiresZeroInitialization())
694&&
"EmitSynthesizedCXXCopyCtor - Copied-in Array");
705 if(
E->getOperatorNew()->isReservedGlobalPlacementOperator())
713 unsignedminElements,
714llvm::Value *&numElements,
715llvm::Value *&sizeWithoutCookie) {
722 returnsizeWithoutCookie;
726 unsignedsizeWidth = CGF.
SizeTy->getBitWidth();
729llvm::APInt cookieSize(sizeWidth,
739assert(isa<llvm::IntegerType>(numElements->getType()));
748= (*e->
getArraySize())->getType()->isSignedIntegerOrEnumerationType();
749llvm::IntegerType *numElementsType
750= cast<llvm::IntegerType>(numElements->getType());
751 unsignednumElementsWidth = numElementsType->getBitWidth();
754llvm::APInt arraySizeMultiplier(sizeWidth, 1);
757 type= CAT->getElementType();
758arraySizeMultiplier *= CAT->getSize();
762llvm::APInt typeSizeMultiplier(sizeWidth, typeSize.
getQuantity());
763typeSizeMultiplier *= arraySizeMultiplier;
770 if(llvm::ConstantInt *numElementsC =
771dyn_cast<llvm::ConstantInt>(numElements)) {
772 constllvm::APInt &count = numElementsC->getValue();
774 boolhasAnyOverflow =
false;
777 if(isSigned && count.isNegative())
778hasAnyOverflow =
true;
783 else if(numElementsWidth > sizeWidth &&
784numElementsWidth - sizeWidth > count.countl_zero())
785hasAnyOverflow =
true;
788llvm::APInt adjustedCount = count.zextOrTrunc(sizeWidth);
792 if(adjustedCount.ult(minElements))
793hasAnyOverflow =
true;
798numElements = llvm::ConstantInt::get(CGF.
SizeTy,
799adjustedCount * arraySizeMultiplier);
803llvm::APInt allocationSize
804= adjustedCount.umul_ov(typeSizeMultiplier, overflow);
805hasAnyOverflow |= overflow;
808 if(cookieSize != 0) {
811sizeWithoutCookie = llvm::ConstantInt::get(CGF.
SizeTy, allocationSize);
813allocationSize = allocationSize.uadd_ov(cookieSize, overflow);
814hasAnyOverflow |= overflow;
818 if(hasAnyOverflow) {
819size = llvm::Constant::getAllOnesValue(CGF.
SizeTy);
821size = llvm::ConstantInt::get(CGF.
SizeTy, allocationSize);
839llvm::Value *hasOverflow =
nullptr;
844 if(numElementsWidth > sizeWidth) {
845llvm::APInt threshold =
846llvm::APInt::getOneBitSet(numElementsWidth, sizeWidth);
848llvm::Value *thresholdV
849= llvm::ConstantInt::get(numElementsType, threshold);
851hasOverflow = CGF.
Builder.CreateICmpUGE(numElements, thresholdV);
852numElements = CGF.
Builder.CreateTrunc(numElements, CGF.
SizeTy);
855}
else if(isSigned) {
856 if(numElementsWidth < sizeWidth)
857numElements = CGF.
Builder.CreateSExt(numElements, CGF.
SizeTy);
864 if(typeSizeMultiplier == 1)
865hasOverflow = CGF.
Builder.CreateICmpSLT(numElements,
866llvm::ConstantInt::get(CGF.
SizeTy, minElements));
869}
else if(numElementsWidth < sizeWidth) {
870numElements = CGF.
Builder.CreateZExt(numElements, CGF.
SizeTy);
873assert(numElements->getType() == CGF.
SizeTy);
878hasOverflow = CGF.
Builder.CreateICmpULT(numElements,
879llvm::ConstantInt::get(CGF.
SizeTy, minElements));
880}
else if(numElementsWidth > sizeWidth) {
884hasOverflow = CGF.
Builder.CreateOr(hasOverflow,
885CGF.
Builder.CreateICmpULT(numElements,
886llvm::ConstantInt::get(CGF.
SizeTy, minElements)));
899 if(typeSizeMultiplier != 1) {
900llvm::Function *umul_with_overflow
904llvm::ConstantInt::get(CGF.
SizeTy, typeSizeMultiplier);
905llvm::Value *result =
906CGF.
Builder.CreateCall(umul_with_overflow, {size, tsmV});
908llvm::Value *overflowed = CGF.
Builder.CreateExtractValue(result, 1);
910hasOverflow = CGF.
Builder.CreateOr(hasOverflow, overflowed);
912hasOverflow = overflowed;
914size = CGF.
Builder.CreateExtractValue(result, 0);
917 if(arraySizeMultiplier != 1) {
920 if(typeSize.
isOne()) {
921assert(arraySizeMultiplier == typeSizeMultiplier);
927llvm::ConstantInt::get(CGF.
SizeTy, arraySizeMultiplier);
928numElements = CGF.
Builder.CreateMul(numElements, asmV);
933assert(arraySizeMultiplier == 1);
937 if(cookieSize != 0) {
938sizeWithoutCookie = size;
940llvm::Function *uadd_with_overflow
943llvm::Value *cookieSizeV = llvm::ConstantInt::get(CGF.
SizeTy, cookieSize);
944llvm::Value *result =
945CGF.
Builder.CreateCall(uadd_with_overflow, {size, cookieSizeV});
947llvm::Value *overflowed = CGF.
Builder.CreateExtractValue(result, 1);
949hasOverflow = CGF.
Builder.CreateOr(hasOverflow, overflowed);
951hasOverflow = overflowed;
953size = CGF.
Builder.CreateExtractValue(result, 0);
960size = CGF.
Builder.CreateSelect(hasOverflow,
961llvm::Constant::getAllOnesValue(CGF.
SizeTy),
966sizeWithoutCookie = size;
968assert(sizeWithoutCookie &&
"didn't set sizeWithoutCookie?");
998llvm_unreachable(
"bad evaluation kind");
1003 AddressBeginPtr, llvm::Value *NumElements,
1004llvm::Value *AllocSizeWithoutCookie) {
1007 if(!
E->hasInitializer())
1012 unsignedInitListElements = 0;
1014 const Expr*
Init=
E->getInitializer();
1017CleanupDeactivationScope deactivation(*
this);
1018 boolpushedCleanup =
false;
1025 autoTryMemsetInitialization = [&]() ->
bool{
1035 auto*RemainingSize = AllocSizeWithoutCookie;
1036 if(InitListElements) {
1038 auto*InitializedSize = llvm::ConstantInt::get(
1039RemainingSize->getType(),
1040 getContext().getTypeSizeInChars(ElementType).getQuantity() *
1042RemainingSize =
Builder.CreateSub(RemainingSize, InitializedSize);
1054 const Expr*IgnoreParen =
nullptr;
1056IgnoreParen =
Init->IgnoreParenImpCasts();
1057CPLIE = dyn_cast<CXXParenListInitExpr>(IgnoreParen);
1058SL = dyn_cast<StringLiteral>(IgnoreParen);
1059OCEE = dyn_cast<ObjCEncodeExpr>(IgnoreParen);
1063 if(ILE || CPLIE || SL || OCEE) {
1084cast<ConstantArrayType>(
Init->getType()->getAsArrayTypeUnsafe())
1087CurPtr, InitListElements,
"string.init.end");
1090llvm::ConstantInt *ConstNum = dyn_cast<llvm::ConstantInt>(NumElements);
1091 if(!ConstNum || !ConstNum->equalsInt(InitListElements)) {
1092 boolOK = TryMemsetInitialization();
1094assert(OK &&
"couldn't memset character type?");
1101InitListElements = InitExprs.size();
1105 QualTypeAllocType =
E->getAllocatedType();
1115AllocaTrackerRAII AllocaTracker(*
this);
1120llvm::Instruction *DominatingIP =
1125EndOfInit, ElementType, ElementAlign,
1128.AddAuxAllocas(AllocaTracker.Take());
1131pushedCleanup =
true;
1136 for(
const Expr*IE : InitExprs) {
1162 while(
Init&&
Init->getType()->isConstantArrayType()) {
1163 auto*SubILE = dyn_cast<InitListExpr>(
Init);
1166assert(SubILE->getNumInits() == 0 &&
"explicit inits in array filler?");
1167 Init= SubILE->getArrayFiller();
1176llvm::ConstantInt *ConstNum = dyn_cast<llvm::ConstantInt>(NumElements);
1177 if(ConstNum && ConstNum->getZExtValue() <= InitListElements) {
1181assert(
Init&&
"have trailing elements to initialize but no initializer");
1190 if(!CCE->requiresZeroInitialization() || Ctor->
getParent()->
isEmpty())
1193 if(TryMemsetInitialization())
1205 if(InitListElements)
1206NumElements =
Builder.CreateSub(
1208llvm::ConstantInt::get(NumElements->getType(), InitListElements));
1211CCE->requiresZeroInitialization());
1217 if(isa<ImplicitValueInitExpr>(
Init)) {
1218 if(TryMemsetInitialization())
1229assert(
getContext().hasSameUnqualifiedType(ElementType,
Init->getType()) &&
1230 "got wrong type of element to initialize");
1233 if(
auto*ILE = dyn_cast<InitListExpr>(
Init))
1234 if(ILE->
getNumInits() == 0 && TryMemsetInitialization())
1239 if(
auto*ILE = dyn_cast<InitListExpr>(
Init)) {
1241 if(RType->getDecl()->isStruct()) {
1242 unsignedNumElements = 0;
1243 if(
auto*CXXRD = dyn_cast<CXXRecordDecl>(RType->getDecl()))
1244NumElements = CXXRD->getNumBases();
1245 for(
auto*Field : RType->getDecl()->fields())
1246 if(!
Field->isUnnamedBitField())
1250 for(
unsignedi = 0, e = ILE->
getNumInits(); i != e; ++i)
1251 if(!isa<ImplicitValueInitExpr>(ILE->
getInit(i)))
1253 if(ILE->
getNumInits() == NumElements && TryMemsetInitialization())
1260llvm::BasicBlock *EntryBB =
Builder.GetInsertBlock();
1273EndPtr,
"array.isempty");
1274 Builder.CreateCondBr(IsEmpty, ContBB, LoopBB);
1281llvm::PHINode *CurPtrPhi =
1283CurPtrPhi->addIncoming(CurPtr.
emitRawPointer(*
this), EntryBB);
1293llvm::Instruction *DominatingIP =
1307deactivation.ForceDeactivate();
1310llvm::Value *NextPtr =
Builder.CreateConstInBoundsGEP1_32(
1315llvm::Value *IsEnd =
Builder.CreateICmpEQ(NextPtr, EndPtr,
"array.atend");
1316 Builder.CreateCondBr(IsEnd, ContBB, LoopBB);
1317CurPtrPhi->addIncoming(NextPtr,
Builder.GetInsertBlock());
1323 QualTypeElementType, llvm::Type *ElementTy,
1324 AddressNewPtr, llvm::Value *NumElements,
1325llvm::Value *AllocSizeWithoutCookie) {
1329AllocSizeWithoutCookie);
1330 else if(
const Expr*
Init=
E->getInitializer())
1341llvm::CallBase *CallOrInvoke;
1346Args, CalleeType,
false),
1354llvm::Function *Fn = dyn_cast<llvm::Function>(CalleePtr);
1356Fn && Fn->hasFnAttribute(llvm::Attribute::NoBuiltin)) {
1357CallOrInvoke->addFnAttr(llvm::Attribute::Builtin);
1374 if(
auto*FD = dyn_cast<FunctionDecl>(
Decl))
1377llvm_unreachable(
"predeclared global operator new/delete is missing");
1382structUsualDeleteParams {
1383 boolDestroyingDelete =
false;
1385 boolAlignment =
false;
1390UsualDeleteParams Params;
1400Params.DestroyingDelete =
true;
1407Params.Size =
true;
1412Params.Alignment =
true;
1416assert(AI == AE &&
"unexpected usual deallocation function parameter");
1424 template<
typenameTraits>
1427 typedef typenameTraits::ValueTy ValueTy;
1429 typedef typenameTraits::RValueTy RValueTy;
1430 structPlacementArg {
1435 unsignedNumPlacementArgs : 31;
1436LLVM_PREFERRED_TYPE(
bool)
1437 unsignedPassAlignmentToPlacementDelete : 1;
1443PlacementArg *getPlacementArgs() {
1444 return reinterpret_cast<PlacementArg *
>(
this+ 1);
1448 static size_tgetExtraSize(
size_tNumPlacementArgs) {
1449 returnNumPlacementArgs *
sizeof(PlacementArg);
1452CallDeleteDuringNew(
size_tNumPlacementArgs,
1454ValueTy AllocSize,
boolPassAlignmentToPlacementDelete,
1456: NumPlacementArgs(NumPlacementArgs),
1457PassAlignmentToPlacementDelete(PassAlignmentToPlacementDelete),
1458OperatorDelete(OperatorDelete), Ptr(Ptr), AllocSize(AllocSize),
1459AllocAlign(AllocAlign) {}
1461 voidsetPlacementArg(
unsignedI, RValueTy Arg,
QualType Type) {
1462assert(I < NumPlacementArgs &&
"index out of range");
1463getPlacementArgs()[I] = {Arg,
Type};
1472DeleteArgs.
add(Traits::get(CGF, Ptr), FPT->getParamType(0));
1475UsualDeleteParams Params;
1476 if(NumPlacementArgs) {
1479Params.Alignment = PassAlignmentToPlacementDelete;
1486assert(!Params.DestroyingDelete &&
1487 "should not call destroying delete in a new-expression");
1491DeleteArgs.add(Traits::get(CGF, AllocSize),
1498 if(Params.Alignment)
1499DeleteArgs.add(
RValue::get(llvm::ConstantInt::get(
1504 for(
unsignedI = 0; I != NumPlacementArgs; ++I) {
1505 autoArg = getPlacementArgs()[I];
1506DeleteArgs.add(Traits::get(CGF, Arg.ArgValue), Arg.ArgType);
1520llvm::Value *AllocSize,
1523 unsignedNumNonPlacementArgs =
E->passAlignment() ? 2 : 1;
1528 structDirectCleanupTraits {
1529 typedefllvm::Value *ValueTy;
1535 typedefCallDeleteDuringNew<DirectCleanupTraits> DirectCleanup;
1538 EHCleanup,
E->getNumPlacementArgs(),
E->getOperatorDelete(),
1539NewPtr.
emitRawPointer(CGF), AllocSize,
E->passAlignment(), AllocAlign);
1540 for(
unsignedI = 0, N =
E->getNumPlacementArgs(); I != N; ++I) {
1541 auto&Arg = NewArgs[I + NumNonPlacementArgs];
1542Cleanup->setPlacementArg(I, Arg.getRValue(CGF), Arg.Ty);
1554 structConditionalCleanupTraits {
1558 return V.restore(CGF);
1561 typedefCallDeleteDuringNew<ConditionalCleanupTraits> ConditionalCleanup;
1563ConditionalCleanup *Cleanup = CGF.
EHStack 1565 E->getNumPlacementArgs(),
1566 E->getOperatorDelete(),
1569 E->passAlignment(),
1571 for(
unsignedI = 0, N =
E->getNumPlacementArgs(); I != N; ++I) {
1572 auto&Arg = NewArgs[I + NumNonPlacementArgs];
1573Cleanup->setPlacementArg(
1589 unsignedminElements = 0;
1590 if(
E->isArray() &&
E->hasInitializer()) {
1591 const Expr*
Init=
E->getInitializer();
1594 const Expr*IgnoreParen =
Init->IgnoreParenImpCasts();
1596isa<StringLiteral>(IgnoreParen) || isa<ObjCEncodeExpr>(IgnoreParen)) {
1598cast<ConstantArrayType>(
Init->getType()->getAsArrayTypeUnsafe())
1600}
else if(ILE || CPLIE) {
1605llvm::Value *numElements =
nullptr;
1606llvm::Value *allocSizeWithoutCookie =
nullptr;
1607llvm::Value *allocSize =
1609allocSizeWithoutCookie);
1617assert(
E->getNumPlacementArgs() == 1);
1618 const Expr*
arg= *
E->placement_arguments().begin();
1631 if(
E->getOperatorDelete() &&
1632!
E->getOperatorDelete()->isReservedGlobalPlacementOperator()) {
1640 unsignedParamsToSkip = 0;
1647 if(allocSize != allocSizeWithoutCookie) {
1649allocAlign = std::max(allocAlign, cookieAlign);
1653 if(
E->passAlignment()) {
1657assert(
getContext().hasSameUnqualifiedType(
1660 "wrong type for alignment parameter");
1664assert(allocator->
isVariadic() &&
"can't pass alignment to allocator");
1666allocatorArgs.
add(
1672 EmitCallArgs(allocatorArgs, allocatorType,
E->placement_arguments(),
1673AbstractCallee(),
ParamsToSkip);
1680 if(
auto*newCall = dyn_cast<llvm::CallBase>(RV.
getScalarVal()))
1689 if(!
E->passAlignment() &&
1691 unsignedAllocatorAlign = llvm::bit_floor(std::min<uint64_t>(
1693allocationAlign = std::max(
1694allocationAlign,
getContext().toCharUnitsFromBits(AllocatorAlign));
1704 boolnullCheck =
E->shouldNullCheckAllocation() &&
1708llvm::BasicBlock *nullCheckBB =
nullptr;
1709llvm::BasicBlock *contBB =
nullptr;
1713ConditionalEvaluation conditional(*
this);
1716conditional.begin(*
this);
1718nullCheckBB =
Builder.GetInsertBlock();
1723 Builder.CreateCondBr(isNull, contBB, notNullBB);
1730llvm::Instruction *cleanupDominator =
nullptr;
1731 if(
E->getOperatorDelete() &&
1732!
E->getOperatorDelete()->isReservedGlobalPlacementOperator()) {
1736cleanupDominator =
Builder.CreateUnreachable();
1739assert((allocSize == allocSizeWithoutCookie) ==
1741 if(allocSize != allocSizeWithoutCookie) {
1742assert(
E->isArray());
1765SkippedChecks.
set(SanitizerKind::Null, nullCheck);
1767 E->getAllocatedTypeSourceInfo()->getTypeLoc().
getBeginLoc(),
1768result, allocType, result.
getAlignment(), SkippedChecks,
1772allocSizeWithoutCookie);
1777 if(operatorDeleteCleanup.
isValid()) {
1779cleanupDominator->eraseFromParent();
1783conditional.end(*
this);
1785llvm::BasicBlock *notNullBB =
Builder.GetInsertBlock();
1788llvm::PHINode *PHI =
Builder.CreatePHI(resultPtr->getType(), 2);
1789PHI->addIncoming(resultPtr, notNullBB);
1790PHI->addIncoming(llvm::Constant::getNullValue(resultPtr->getType()),
1800llvm::Value *DeletePtr,
QualTypeDeleteTy,
1801llvm::Value *NumElements,
1803assert((!NumElements && CookieSize.
isZero()) ||
1810 autoParamTypeIt = DeleteFTy->param_type_begin();
1817llvm::AllocaInst *DestroyingDeleteTag =
nullptr;
1818 if(Params.DestroyingDelete) {
1823DestroyingDeleteTag->setAlignment(Align.
getAsAlign());
1830 QualTypeSizeType = *ParamTypeIt++;
1840 if(!CookieSize.
isZero())
1848 if(Params.Alignment) {
1849 QualTypeAlignValType = *ParamTypeIt++;
1853llvm::Value *Align = llvm::ConstantInt::get(
ConvertType(AlignValType),
1855DeleteArgs.add(
RValue::get(Align), AlignValType);
1858assert(ParamTypeIt == DeleteFTy->param_type_end() &&
1859 "unknown parameter to usual delete function");
1866 if(DestroyingDeleteTag && DestroyingDeleteTag->use_empty())
1867DestroyingDeleteTag->eraseFromParent();
1877CallObjectDelete(llvm::Value *Ptr,
1880: Ptr(Ptr), OperatorDelete(OperatorDelete), ElementType(ElementType) {}
1890llvm::Value *CompletePtr,
1893OperatorDelete, ElementType);
1904 if(Dtor && Dtor->isVirtual())
1919llvm::BasicBlock *UnconditionalDeleteBlock) {
1929assert(!OperatorDelete->isDestroyingOperatorDelete());
1940 boolUseVirtualCall =
true;
1942 if(
auto*DevirtualizedDtor =
1943dyn_cast_or_null<const CXXDestructorDecl>(
1946UseVirtualCall =
false;
1952Dtor = DevirtualizedDtor;
1959UseVirtualCall =
true;
1962 if(UseVirtualCall) {
1974CGF.
EHStack.pushCleanup<CallObjectDelete>(
2001CGF.
EmitBlock(UnconditionalDeleteBlock);
2015llvm::Value *NumElements;
2019CallArrayDelete(llvm::Value *Ptr,
2021llvm::Value *NumElements,
2024: Ptr(Ptr), OperatorDelete(OperatorDelete), NumElements(NumElements),
2025ElementType(ElementType), CookieSize(CookieSize) {}
2028CGF.
EmitDeleteCall(OperatorDelete, Ptr, ElementType, NumElements,
2039llvm::Value *numElements =
nullptr;
2040llvm::Value *allocatedPtr =
nullptr;
2043numElements, allocatedPtr, cookieSize);
2045assert(allocatedPtr &&
"ReadArrayCookie didn't set allocated pointer");
2048 const FunctionDecl*operatorDelete =
E->getOperatorDelete();
2050allocatedPtr, operatorDelete,
2051numElements, elementType,
2056assert(numElements &&
"no element count for a type with a destructor!");
2064deletedPtr.
getElementType(), arrayBegin, numElements,
"delete.end");
2080 const Expr*Arg =
E->getArgument();
2099 QualTypeDeleteTy =
E->getDestroyedType();
2103 if(
E->getOperatorDelete()->isDestroyingOperatorDelete()) {
2116GEP.push_back(Zero);
2120=
getContext().getAsConstantArrayType(DeleteTy)) {
2122DeleteTy = Arr->getElementType();
2125GEP.push_back(Zero);
2134 if(
E->isArrayForm()) {
2144llvm::Type *StdTypeInfoPtrTy,
2145 boolHasNullCheck) {
2156ThisPtr, SrcRecordTy);
2163llvm::BasicBlock *BadTypeidBlock =
2168CGF.
Builder.CreateCondBr(
IsNull, BadTypeidBlock, EndBlock);
2188 autoMaybeASCast = [=](
auto&&
TypeInfo) {
2195 if(
E->isTypeOperand()) {
2207 if(
E->isPotentiallyEvaluated() && !
E->isMostDerived(
getContext()))
2209 E->hasNullCheck());
2219 returnllvm::Constant::getNullValue(DestLTy);
2226CGF.
Builder.ClearInsertionPoint();
2227 returnllvm::PoisonValue::get(DestLTy);
2243 if(IsDynamicCastToVoid) {
2250SrcRecordTy = SrcTy;
2264 if(!
Builder.GetInsertBlock())
2270assert(SrcRecordTy->
isRecordType() &&
"source type must be a record type!");
2274 boolIsExact = !IsDynamicCastToVoid &&
2282 boolShouldNullCheckSrcValue =
2286llvm::BasicBlock *CastNull =
nullptr;
2287llvm::BasicBlock *CastNotNull =
nullptr;
2290 if(ShouldNullCheckSrcValue) {
2299llvm::Value *
Value;
2300 if(IsDynamicCastToVoid) {
2302}
else if(IsExact) {
2306*
this, ThisAddr, SrcRecordTy, DestTy, DestRecordTy, CastEnd, CastNull);
2309 "destination type must be a record type!");
2311DestTy, DestRecordTy, CastEnd);
2313CastNotNull =
Builder.GetInsertBlock();
2315llvm::Value *NullValue =
nullptr;
2316 if(ShouldNullCheckSrcValue) {
2321CastNull =
Builder.GetInsertBlock();
2330PHI->addIncoming(
Value, CastNotNull);
2331PHI->addIncoming(NullValue, CastNull);
static MemberCallInfo commonEmitCXXMemberOrOperatorCall(CodeGenFunction &CGF, GlobalDecl GD, llvm::Value *This, llvm::Value *ImplicitParam, QualType ImplicitParamTy, const CallExpr *CE, CallArgList &Args, CallArgList *RtlArgs)
static llvm::Value * EmitTypeidFromVTable(CodeGenFunction &CGF, const Expr *E, llvm::Type *StdTypeInfoPtrTy, bool HasNullCheck)
static llvm::Value * EmitDynamicCastToNull(CodeGenFunction &CGF, QualType DestTy)
static RValue EmitNewDeleteCall(CodeGenFunction &CGF, const FunctionDecl *CalleeDecl, const FunctionProtoType *CalleeType, const CallArgList &Args)
Emit a call to an operator new or operator delete function, as implicitly created by new-expressions ...
static void EmitDestroyingObjectDelete(CodeGenFunction &CGF, const CXXDeleteExpr *DE, Address Ptr, QualType ElementType)
Emit the code for deleting a single object with a destroying operator delete.
static void EmitNullBaseClassInitialization(CodeGenFunction &CGF, Address DestPtr, const CXXRecordDecl *Base)
static void EnterNewDeleteCleanup(CodeGenFunction &CGF, const CXXNewExpr *E, Address NewPtr, llvm::Value *AllocSize, CharUnits AllocAlign, const CallArgList &NewArgs)
Enter a cleanup to call 'operator delete' if the initializer in a new-expression throws.
static bool EmitObjectDelete(CodeGenFunction &CGF, const CXXDeleteExpr *DE, Address Ptr, QualType ElementType, llvm::BasicBlock *UnconditionalDeleteBlock)
Emit the code for deleting a single object.
static UsualDeleteParams getUsualDeleteParams(const FunctionDecl *FD)
static CXXRecordDecl * getCXXRecord(const Expr *E)
static CharUnits CalculateCookiePadding(CodeGenFunction &CGF, const CXXNewExpr *E)
static void EmitArrayDelete(CodeGenFunction &CGF, const CXXDeleteExpr *E, Address deletedPtr, QualType elementType)
Emit the code for deleting an array of objects.
static void StoreAnyExprIntoOneUnit(CodeGenFunction &CGF, const Expr *Init, QualType AllocType, Address NewPtr, AggValueSlot::Overlap_t MayOverlap)
static void EmitNewInitializer(CodeGenFunction &CGF, const CXXNewExpr *E, QualType ElementType, llvm::Type *ElementTy, Address NewPtr, llvm::Value *NumElements, llvm::Value *AllocSizeWithoutCookie)
static llvm::Value * EmitCXXNewAllocSize(CodeGenFunction &CGF, const CXXNewExpr *e, unsigned minElements, llvm::Value *&numElements, llvm::Value *&sizeWithoutCookie)
llvm::MachO::Target Target
static QualType getPointeeType(const MemRegion *R)
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
TranslationUnitDecl * getTranslationUnitDecl() const
const ConstantArrayType * getAsConstantArrayType(QualType T) const
CharUnits getTypeAlignInChars(QualType T) const
Return the ABI-specified alignment of a (complete) type T, in characters.
DeclarationNameTable DeclarationNames
const ASTRecordLayout & getASTRecordLayout(const RecordDecl *D) const
Get or compute information about the layout of the specified record (struct/union/class) D,...
bool hasSameType(QualType T1, QualType T2) const
Determine whether the given types T1 and T2 are equivalent.
QualType getPointerType(QualType T) const
Return the uniqued reference to the type for a pointer to the specified type.
QualType getBaseElementType(const ArrayType *VAT) const
Return the innermost element type of an array type.
CanQualType getSizeType() const
Return the unique type for "size_t" (C99 7.17), defined in <stddef.h>.
CharUnits getTypeSizeInChars(QualType T) const
Return the size of the specified (complete) type T, in characters.
CharUnits toCharUnitsFromBits(int64_t BitSize) const
Convert a size in bits to a size in characters.
uint64_t getConstantArrayElementCount(const ConstantArrayType *CA) const
Return number of constant array elements.
ASTRecordLayout - This class contains layout information for one RecordDecl, which is a struct/union/...
CharUnits getNonVirtualAlignment() const
getNonVirtualAlignment - Get the non-virtual alignment (in chars) of an object, which is the alignmen...
CharUnits getNonVirtualSize() const
getNonVirtualSize - Get the non-virtual size (in chars) of an object, which is the size of the object...
Represents an array type, per C99 6.7.5.2 - Array Declarators.
A builtin binary operation expression such as "x + y" or "x <= y".
Represents a call to a CUDA kernel function.
Represents a call to a C++ constructor.
Represents a C++ constructor within a class.
bool isDefaultConstructor() const
Whether this constructor is a default constructor (C++ [class.ctor]p5), which can be used to default-...
Represents a delete expression for memory deallocation and destructor calls, e.g.
FunctionDecl * getOperatorDelete() const
Represents a C++ destructor within a class.
A C++ dynamic_cast expression (C++ [expr.dynamic.cast]).
bool isAlwaysNull() const
isAlwaysNull - Return whether the result of the dynamic_cast is proven to always be null.
Represents a call to a member function that may be written either with member call syntax (e....
Represents a static or instance method of a struct/union/class.
bool isImplicitObjectMemberFunction() const
[C++2b][dcl.fct]/p7 An implicit object member function is a non-static member function without an exp...
const CXXRecordDecl * getParent() const
Return the parent of this method declaration, which is the class in which this method is defined.
QualType getThisType() const
Return the type of the this pointer.
bool isMoveAssignmentOperator() const
Determine whether this is a move assignment operator.
Qualifiers getMethodQualifiers() const
CXXMethodDecl * getDevirtualizedMethod(const Expr *Base, bool IsAppleKext)
If it's possible to devirtualize a call to this method, return the called function.
CXXMethodDecl * getCorrespondingMethodInClass(const CXXRecordDecl *RD, bool MayBeBase=false)
Find the method in RD that corresponds to this one.
bool isCopyAssignmentOperator() const
Determine whether this is a copy-assignment operator, regardless of whether it was declared implicitl...
Represents a new-expression for memory allocation and constructor calls, e.g: "new CXXNewExpr(foo)".
QualType getAllocatedType() const
std::optional< Expr * > getArraySize()
This might return std::nullopt even if isArray() returns true, since there might not be an array size...
A call to an overloaded operator written using operator syntax.
Represents a list-initialization with parenthesis.
ArrayRef< Expr * > getInitExprs()
Represents a C++ pseudo-destructor (C++ [expr.pseudo]).
Represents a C++ struct/union/class.
bool isEffectivelyFinal() const
Determine whether it's impossible for a class to be derived from this class.
bool hasTrivialDestructor() const
Determine whether this class has a trivial destructor (C++ [class.dtor]p3)
bool isDynamicClass() const
bool hasDefinition() const
bool isEmpty() const
Determine whether this is an empty class in the sense of (C++11 [meta.unary.prop]).
CXXDestructorDecl * getDestructor() const
Returns the destructor decl for this class.
A C++ typeid expression (C++ [expr.typeid]), which gets the type_info that corresponds to the supplie...
CallExpr - Represents a function call (C99 6.5.2.2, C++ [expr.call]).
Expr * getArg(unsigned Arg)
getArg - Return the specified argument.
SourceLocation getBeginLoc() const LLVM_READONLY
FunctionDecl * getDirectCallee()
If the callee is a FunctionDecl, return it. Otherwise return null.
CharUnits - This is an opaque type for sizes expressed in character units.
CharUnits alignmentAtOffset(CharUnits offset) const
Given that this is a non-zero alignment value, what is the alignment at the given offset?
bool isNegative() const
isNegative - Test whether the quantity is less than zero.
bool isZero() const
isZero - Test whether the quantity equals zero.
llvm::Align getAsAlign() const
getAsAlign - Returns Quantity as a valid llvm::Align, Beware llvm::Align assumes power of two 8-bit b...
QuantityType getQuantity() const
getQuantity - Get the raw integer representation of this quantity.
CharUnits alignmentOfArrayElement(CharUnits elementSize) const
Given that this is the alignment of the first element of an array, return the minimum alignment of an...
bool isOne() const
isOne - Test whether the quantity equals one.
static CharUnits Zero()
Zero - Construct a CharUnits quantity of zero.
Like RawAddress, an abstract representation of an aligned address, but the pointer contained in this ...
llvm::Value * emitRawPointer(CodeGenFunction &CGF) const
Return the pointer contained in this class after authenticating it and adding offset to it if necessa...
CharUnits getAlignment() const
llvm::Type * getElementType() const
Return the type of the values stored in this address.
Address withElementType(llvm::Type *ElemTy) const
Return address with different element type, but same pointer and alignment.
Address setKnownNonNull()
void setAlignment(CharUnits Value)
llvm::PointerType * getType() const
Return the type of the pointer value.
bool isSanitizerChecked() const
Address getAddress() const
IsZeroed_t isZeroed() const
static AggValueSlot forAddr(Address addr, Qualifiers quals, IsDestructed_t isDestructed, NeedsGCBarriers_t needsGC, IsAliased_t isAliased, Overlap_t mayOverlap, IsZeroed_t isZeroed=IsNotZeroed, IsSanitizerChecked_t isChecked=IsNotSanitizerChecked)
forAddr - Make a slot for an aggregate value.
A scoped helper to set the current debug location to the specified location or preferred location of ...
llvm::StoreInst * CreateStore(llvm::Value *Val, Address Addr, bool IsVolatile=false)
Address CreateConstInBoundsByteGEP(Address Addr, CharUnits Offset, const llvm::Twine &Name="")
Given a pointer to i8, adjust it by a given constant offset.
llvm::Value * CreateIsNull(Address Addr, const Twine &Name="")
llvm::CallInst * CreateMemSet(Address Dest, llvm::Value *Value, llvm::Value *Size, bool IsVolatile=false)
llvm::LoadInst * CreateLoad(Address Addr, const llvm::Twine &Name="")
llvm::LoadInst * CreateFlagLoad(llvm::Value *Addr, const llvm::Twine &Name="")
Emit a load from an i1 flag variable.
Address CreateLaunderInvariantGroup(Address Addr)
llvm::CallInst * CreateMemCpy(Address Dest, Address Src, llvm::Value *Size, bool IsVolatile=false)
llvm::ConstantInt * getSize(CharUnits N)
Address CreateConstInBoundsGEP(Address Addr, uint64_t Index, const llvm::Twine &Name="")
Given addr = T* ... produce name = getelementptr inbounds addr, i64 index where i64 is actually the t...
Address CreateInBoundsGEP(Address Addr, ArrayRef< llvm::Value * > IdxList, llvm::Type *ElementType, CharUnits Align, const Twine &Name="")
virtual RValue EmitCUDAKernelCallExpr(CodeGenFunction &CGF, const CUDAKernelCallExpr *E, ReturnValueSlot ReturnValue, llvm::CallBase **CallOrInvoke=nullptr)
virtual bool shouldEmitExactDynamicCast(QualType DestRecordTy)=0
virtual std::vector< CharUnits > getVBPtrOffsets(const CXXRecordDecl *RD)
Gets the offsets of all the virtual base pointers in a given class.
virtual void ReadArrayCookie(CodeGenFunction &CGF, Address Ptr, const CXXDeleteExpr *expr, QualType ElementType, llvm::Value *&NumElements, llvm::Value *&AllocPtr, CharUnits &CookieSize)
Reads the array cookie associated with the given pointer, if it has one.
virtual bool shouldTypeidBeNullChecked(QualType SrcRecordTy)=0
virtual std::pair< llvm::Value *, const CXXRecordDecl * > LoadVTablePtr(CodeGenFunction &CGF, Address This, const CXXRecordDecl *RD)=0
Load a vtable from This, an object of polymorphic type RD, or from one of its virtual bases if it doe...
virtual Address adjustThisArgumentForVirtualFunctionCall(CodeGenFunction &CGF, GlobalDecl GD, Address This, bool VirtualCall)
Perform ABI-specific "this" argument adjustment required prior to a call of a virtual function.
virtual void emitVirtualObjectDelete(CodeGenFunction &CGF, const CXXDeleteExpr *DE, Address Ptr, QualType ElementType, const CXXDestructorDecl *Dtor)=0
virtual llvm::Value * emitExactDynamicCast(CodeGenFunction &CGF, Address Value, QualType SrcRecordTy, QualType DestTy, QualType DestRecordTy, llvm::BasicBlock *CastSuccess, llvm::BasicBlock *CastFail)=0
Emit a dynamic_cast from SrcRecordTy to DestRecordTy.
virtual const CXXRecordDecl * getThisArgumentTypeForMethod(GlobalDecl GD)
Get the type of the implicit "this" parameter used by a method.
virtual bool EmitBadCastCall(CodeGenFunction &CGF)=0
virtual llvm::Value * EmitTypeid(CodeGenFunction &CGF, QualType SrcRecordTy, Address ThisPtr, llvm::Type *StdTypeInfoPtrTy)=0
virtual CGCallee EmitLoadOfMemberFunctionPointer(CodeGenFunction &CGF, const Expr *E, Address This, llvm::Value *&ThisPtrForCall, llvm::Value *MemPtr, const MemberPointerType *MPT)
Load a member function from an object and a member function pointer.
virtual llvm::Value * EmitVirtualDestructorCall(CodeGenFunction &CGF, const CXXDestructorDecl *Dtor, CXXDtorType DtorType, Address This, DeleteOrMemberCallExpr E, llvm::CallBase **CallOrInvoke)=0
Emit the ABI-specific virtual destructor call.
virtual CharUnits GetArrayCookieSize(const CXXNewExpr *expr)
Returns the extra size required in order to store the array cookie for the given new-expression.
virtual void EmitBadTypeidCall(CodeGenFunction &CGF)=0
virtual llvm::Value * emitDynamicCastToVoid(CodeGenFunction &CGF, Address Value, QualType SrcRecordTy)=0
virtual llvm::Value * emitDynamicCastCall(CodeGenFunction &CGF, Address Value, QualType SrcRecordTy, QualType DestTy, QualType DestRecordTy, llvm::BasicBlock *CastEnd)=0
virtual Address InitializeArrayCookie(CodeGenFunction &CGF, Address NewPtr, llvm::Value *NumElements, const CXXNewExpr *expr, QualType ElementType)
Initialize the array cookie for the given allocation.
virtual bool shouldDynamicCastCallBeNullChecked(bool SrcIsPtr, QualType SrcRecordTy)=0
All available information about a concrete callee.
static CGCallee forVirtual(const CallExpr *CE, GlobalDecl MD, Address Addr, llvm::FunctionType *FTy)
static CGCallee forDirect(llvm::Constant *functionPtr, const CGCalleeInfo &abstractInfo=CGCalleeInfo())
void addHeapAllocSiteMetadata(llvm::CallBase *CallSite, QualType AllocatedTy, SourceLocation Loc)
Add heapallocsite metadata for MSAllocator calls.
CGFunctionInfo - Class to encapsulate the information about a function definition.
CallArgList - Type for representing both the value and type of arguments in a call.
void add(RValue rvalue, QualType type)
void addFrom(const CallArgList &other)
Add all the arguments from another CallArgList to this one.
CodeGenFunction - This class organizes the per-function state that is used while generating LLVM code...
void EmitSynthesizedCXXCopyCtorCall(const CXXConstructorDecl *D, Address This, Address Src, const CXXConstructExpr *E)
void pushCallObjectDeleteCleanup(const FunctionDecl *OperatorDelete, llvm::Value *CompletePtr, QualType ElementType)
void EmitARCDestroyWeak(Address addr)
void EmitNullInitialization(Address DestPtr, QualType Ty)
EmitNullInitialization - Generate code to set a value of the given type to null, If the type contains...
GlobalDecl CurGD
CurGD - The GlobalDecl for the current function being compiled.
void DeactivateCleanupBlock(EHScopeStack::stable_iterator Cleanup, llvm::Instruction *DominatingIP)
DeactivateCleanupBlock - Deactivates the given cleanup block.
static TypeEvaluationKind getEvaluationKind(QualType T)
getEvaluationKind - Return the TypeEvaluationKind of QualType T.
bool sanitizePerformTypeCheck() const
Whether any type-checking sanitizers are enabled.
SanitizerSet SanOpts
Sanitizers enabled for this function.
void EmitVTablePtrCheckForCall(const CXXRecordDecl *RD, llvm::Value *VTable, CFITypeCheckKind TCK, SourceLocation Loc)
EmitVTablePtrCheckForCall - Virtual method MD is being called via VTable.
RValue EmitCUDAKernelCallExpr(const CUDAKernelCallExpr *E, ReturnValueSlot ReturnValue, llvm::CallBase **CallOrInvoke)
void EmitCallArgs(CallArgList &Args, PrototypeWrapper Prototype, llvm::iterator_range< CallExpr::const_arg_iterator > ArgRange, AbstractCallee AC=AbstractCallee(), unsigned ParamsToSkip=0, EvaluationOrder Order=EvaluationOrder::Default)
RValue EmitCXXMemberOrOperatorCall(const CXXMethodDecl *Method, const CGCallee &Callee, ReturnValueSlot ReturnValue, llvm::Value *This, llvm::Value *ImplicitParam, QualType ImplicitParamTy, const CallExpr *E, CallArgList *RtlArgs, llvm::CallBase **CallOrInvoke)
void pushIrregularPartialArrayCleanup(llvm::Value *arrayBegin, Address arrayEndPointer, QualType elementType, CharUnits elementAlignment, Destroyer *destroyer)
void EmitSynthesizedCXXCopyCtor(Address Dest, Address Src, const Expr *Exp)
void EmitCXXAggrConstructorCall(const CXXConstructorDecl *D, const ArrayType *ArrayTy, Address ArrayPtr, const CXXConstructExpr *E, bool NewPointerIsChecked, bool ZeroInitialization=false)
void EmitCXXDestructorCall(const CXXDestructorDecl *D, CXXDtorType Type, bool ForVirtualBase, bool Delegating, Address This, QualType ThisTy)
RValue EmitCXXMemberOrOperatorMemberCallExpr(const CallExpr *CE, const CXXMethodDecl *MD, ReturnValueSlot ReturnValue, bool HasQualifier, NestedNameSpecifier *Qualifier, bool IsArrow, const Expr *Base, llvm::CallBase **CallOrInvoke)
LValue EmitLValue(const Expr *E, KnownNonNull_t IsKnownNonNull=NotKnownNonNull)
EmitLValue - Emit code to compute a designator that specifies the location of the expression.
llvm::SmallVector< DeferredDeactivateCleanup > DeferredDeactivationCleanupStack
void EmitDeleteCall(const FunctionDecl *DeleteFD, llvm::Value *Ptr, QualType DeleteTy, llvm::Value *NumElements=nullptr, CharUnits CookieSize=CharUnits())
llvm::BasicBlock * createBasicBlock(const Twine &name="", llvm::Function *parent=nullptr, llvm::BasicBlock *before=nullptr)
createBasicBlock - Create an LLVM basic block.
RValue EmitCXXPseudoDestructorExpr(const CXXPseudoDestructorExpr *E)
const LangOptions & getLangOpts() const
void emitArrayDestroy(llvm::Value *begin, llvm::Value *end, QualType elementType, CharUnits elementAlign, Destroyer *destroyer, bool checkZeroLength, bool useEHCleanup)
void EmitBlock(llvm::BasicBlock *BB, bool IsFinished=false)
EmitBlock - Emit the given block.
llvm::AllocaInst * CreateTempAlloca(llvm::Type *Ty, const Twine &Name="tmp", llvm::Value *ArraySize=nullptr)
CreateTempAlloca - This creates an alloca and inserts it into the entry block if ArraySize is nullptr...
@ TCK_ConstructorCall
Checking the 'this' pointer for a constructor call.
@ TCK_MemberCall
Checking the 'this' pointer for a call to a non-static member function.
@ TCK_DynamicOperation
Checking the operand of a dynamic_cast or a typeid expression.
void EmitIgnoredExpr(const Expr *E)
EmitIgnoredExpr - Emit an expression in a context which ignores the result.
llvm::Type * ConvertTypeForMem(QualType T)
void EmitAggregateAssign(LValue Dest, LValue Src, QualType EltTy)
Emit an aggregate assignment.
void EmitScalarInit(const Expr *init, const ValueDecl *D, LValue lvalue, bool capturedByInit)
@ ForceRightToLeft
! Language semantics require right-to-left evaluation.
Destroyer * getDestroyer(QualType::DestructionKind destructionKind)
void EmitNewArrayInitializer(const CXXNewExpr *E, QualType elementType, llvm::Type *ElementTy, Address NewPtr, llvm::Value *NumElements, llvm::Value *AllocSizeWithoutCookie)
void initFullExprCleanup()
Set up the last cleanup that was pushed as a conditional full-expression cleanup.
bool isInConditionalBranch() const
isInConditionalBranch - Return true if we're currently emitting one branch or the other of a conditio...
llvm::Value * getTypeSize(QualType Ty)
Returns calculated size of the specified type.
Address EmitPointerWithAlignment(const Expr *Addr, LValueBaseInfo *BaseInfo=nullptr, TBAAAccessInfo *TBAAInfo=nullptr, KnownNonNull_t IsKnownNonNull=NotKnownNonNull)
EmitPointerWithAlignment - Given an expression with a pointer type, emit the value and compute our be...
void EmitARCRelease(llvm::Value *value, ARCPreciseLifetime_t precise)
void EmitComplexExprIntoLValue(const Expr *E, LValue dest, bool isInit)
EmitComplexExprIntoLValue - Emit the given expression of complex type and place its result into the s...
RValue EmitCXXMemberCallExpr(const CXXMemberCallExpr *E, ReturnValueSlot ReturnValue, llvm::CallBase **CallOrInvoke=nullptr)
RValue EmitBuiltinNewDeleteCall(const FunctionProtoType *Type, const CallExpr *TheCallExpr, bool IsDelete)
void EmitCXXConstructorCall(const CXXConstructorDecl *D, CXXCtorType Type, bool ForVirtualBase, bool Delegating, AggValueSlot ThisAVS, const CXXConstructExpr *E)
CGDebugInfo * getDebugInfo()
void EmitBranch(llvm::BasicBlock *Block)
EmitBranch - Emit a branch to the specified basic block from the current insert block,...
void EmitCXXDeleteExpr(const CXXDeleteExpr *E)
const TargetCodeGenInfo & getTargetHooks() const
void EmitAggExpr(const Expr *E, AggValueSlot AS)
EmitAggExpr - Emit the computation of the specified expression of aggregate type.
RValue EmitCXXMemberPointerCallExpr(const CXXMemberCallExpr *E, ReturnValueSlot ReturnValue, llvm::CallBase **CallOrInvoke)
RValue EmitCall(const CGFunctionInfo &CallInfo, const CGCallee &Callee, ReturnValueSlot ReturnValue, const CallArgList &Args, llvm::CallBase **CallOrInvoke, bool IsMustTail, SourceLocation Loc, bool IsVirtualFunctionPointerThunk=false)
EmitCall - Generate a call of the given function, expecting the given result type,...
ASTContext & getContext() const
CGCallee BuildAppleKextVirtualCall(const CXXMethodDecl *MD, NestedNameSpecifier *Qual, llvm::Type *Ty)
void PopCleanupBlock(bool FallThroughIsBranchThrough=false, bool ForDeactivation=false)
PopCleanupBlock - Will pop the cleanup entry on the stack and process all branch fixups.
bool needsEHCleanup(QualType::DestructionKind kind)
Determines whether an EH cleanup is required to destroy a type with the given destruction kind.
void EmitCXXConstructExpr(const CXXConstructExpr *E, AggValueSlot Dest)
RValue EmitCXXOperatorMemberCallExpr(const CXXOperatorCallExpr *E, const CXXMethodDecl *MD, ReturnValueSlot ReturnValue, llvm::CallBase **CallOrInvoke)
llvm::Type * ConvertType(QualType T)
llvm::Value * EmitCXXTypeidExpr(const CXXTypeidExpr *E)
CodeGenTypes & getTypes() const
void EmitTypeCheck(TypeCheckKind TCK, SourceLocation Loc, LValue LV, QualType Type, SanitizerSet SkippedChecks=SanitizerSet(), llvm::Value *ArraySize=nullptr)
llvm::Value * EmitDynamicCast(Address V, const CXXDynamicCastExpr *DCE)
LValue MakeAddrLValue(Address Addr, QualType T, AlignmentSource Source=AlignmentSource::Type)
const CallExpr * MustTailCall
Address ReturnValue
ReturnValue - The temporary alloca to hold the return value.
llvm::Value * EmitScalarExpr(const Expr *E, bool IgnoreResultAssign=false)
EmitScalarExpr - Emit the computation of the specified expression of LLVM scalar type,...
llvm::Value * EmitCXXNewExpr(const CXXNewExpr *E)
void EmitARCDestroyStrong(Address addr, ARCPreciseLifetime_t precise)
void pushRegularPartialArrayCleanup(llvm::Value *arrayBegin, llvm::Value *arrayEnd, QualType elementType, CharUnits elementAlignment, Destroyer *destroyer)
static bool IsWrappedCXXThis(const Expr *E)
Check if E is a C++ "this" pointer wrapped in value-preserving casts.
void EmitExplicitCastExprType(const ExplicitCastExpr *E, CodeGenFunction *CGF=nullptr)
Emit type info if type of an expression is a variably modified type.
llvm::Module & getModule() const
llvm::Constant * EmitNullConstantForBase(const CXXRecordDecl *Record)
Return a null constant appropriate for zero-initializing a base class with the given type.
llvm::Constant * GetAddrOfRTTIDescriptor(QualType Ty, bool ForEH=false)
Get the address of the RTTI descriptor for the given type.
llvm::Constant * GetAddrOfFunction(GlobalDecl GD, llvm::Type *Ty=nullptr, bool ForVTable=false, bool DontDefer=false, ForDefinition_t IsForDefinition=NotForDefinition)
Return the address of the given function.
llvm::Constant * getAddrOfCXXStructor(GlobalDecl GD, const CGFunctionInfo *FnInfo=nullptr, llvm::FunctionType *FnType=nullptr, bool DontDefer=false, ForDefinition_t IsForDefinition=NotForDefinition)
Return the address of the constructor/destructor of the given type.
const LangOptions & getLangOpts() const
CGCUDARuntime & getCUDARuntime()
Return a reference to the configured CUDA runtime.
CharUnits getNaturalTypeAlignment(QualType T, LValueBaseInfo *BaseInfo=nullptr, TBAAAccessInfo *TBAAInfo=nullptr, bool forPointeeType=false)
CodeGenTypes & getTypes()
CGCXXABI & getCXXABI() const
const CodeGenOptions & getCodeGenOpts() const
llvm::Function * getIntrinsic(unsigned IID, ArrayRef< llvm::Type * > Tys={})
LangAS GetGlobalVarAddressSpace(const VarDecl *D)
Return the AST address space of the underlying global variable for D, as determined by its declaratio...
llvm::ConstantInt * getSize(CharUnits numChars)
Emit the given number of characters as a value of type size_t.
llvm::Type * ConvertType(QualType T)
ConvertType - Convert type T into a llvm::Type.
const CGFunctionInfo & arrangeCXXMethodDeclaration(const CXXMethodDecl *MD)
C++ methods have some special rules and also have implicit parameters.
CanQualType DeriveThisType(const CXXRecordDecl *RD, const CXXMethodDecl *MD)
Derives the 'this' type for codegen purposes, i.e.
llvm::FunctionType * GetFunctionType(const CGFunctionInfo &Info)
GetFunctionType - Get the LLVM function type for.
const CGFunctionInfo & arrangeCXXMethodCall(const CallArgList &args, const FunctionProtoType *type, RequiredArgs required, unsigned numPrefixArgs)
Arrange a call to a C++ method, passing the given arguments.
const CGFunctionInfo & arrangeFreeFunctionCall(const CallArgList &Args, const FunctionType *Ty, bool ChainCall)
Figure out the rules for calling a function with the given formal type using the given arguments.
bool isZeroInitializable(QualType T)
IsZeroInitializable - Return whether a type can be zero-initialized (in the C++ sense) with an LLVM z...
const CGFunctionInfo & arrangeCXXStructorDeclaration(GlobalDecl GD)
llvm::Constant * tryEmitAbstract(const Expr *E, QualType T)
Try to emit the result of the given expression as an abstract constant.
Information for lazily generating a cleanup.
A saved depth on the scope stack.
stable_iterator stable_begin() const
Create a stable reference to the top of the EH stack.
T * pushCleanupWithExtra(CleanupKind Kind, size_t N, As... A)
Push a cleanup with non-constant storage requirements on the stack.
iterator find(stable_iterator save) const
Turn a stable reference to a scope depth into a unstable pointer to the EH stack.
AlignmentSource getAlignmentSource() const
LValue - This represents an lvalue references.
Address getAddress() const
RValue - This trivial value class is used to represent the result of an expression that is evaluated.
static RValue get(llvm::Value *V)
static RValue getAggregate(Address addr, bool isVolatile=false)
Convert an Address to an RValue.
llvm::Value * getScalarVal() const
getScalarVal() - Return the Value* of this scalar value.
A class for recording the number of arguments that a function signature requires.
static RequiredArgs forPrototypePlus(const FunctionProtoType *prototype, unsigned additional)
Compute the arguments required by the given formal prototype, given that there may be some additional...
ReturnValueSlot - Contains the address where the return value of a function can be stored,...
Address performAddrSpaceCast(CodeGen::CodeGenFunction &CGF, Address Addr, LangAS SrcAddr, LangAS DestAddr, llvm::Type *DestTy, bool IsNonNull=false) const
Represents the canonical version of C arrays with a specified constant size.
DeclContext * getParent()
getParent - Returns the containing DeclContext.
lookup_result lookup(DeclarationName Name) const
lookup - Find the declarations (if any) with the given Name in this context.
Decl - This represents one declaration (or definition), e.g.
The name of a declaration.
QualType getIntegerType() const
Return the integer type this enum decl corresponds to.
A helper class that allows the use of isa/cast/dyncast to detect TagType objects of enums.
EnumDecl * getDecl() const
QualType getTypeAsWritten() const
getTypeAsWritten - Returns the type that this expression is casting to, as written in the source code...
Represents an expression â generally a full-expression â that introduces cleanups to be run at the en...
This represents one expression.
Expr * IgnoreParens() LLVM_READONLY
Skip past any parentheses which might surround this expression until reaching a fixed point.
bool isTemporaryObject(ASTContext &Ctx, const CXXRecordDecl *TempTy) const
Determine whether the result of this expression is a temporary object of the given class type.
SourceLocation getExprLoc() const LLVM_READONLY
getExprLoc - Return the preferred location for the arrow when diagnosing a problem with a generic exp...
Represents a function declaration or definition.
bool isDestroyingOperatorDelete() const
Determine whether this is a destroying operator delete.
QualType getReturnType() const
bool isTrivial() const
Whether this function is "trivial" in some specialized C++ senses.
bool isVariadic() const
Whether this function is variadic.
bool isReservedGlobalPlacementOperator() const
Determines whether this operator new or delete is one of the reserved global placement operators: voi...
bool isReplaceableGlobalAllocationFunction(std::optional< unsigned > *AlignmentParam=nullptr, bool *IsNothrow=nullptr) const
Determines whether this function is one of the replaceable global allocation functions: void *operato...
bool isDefaulted() const
Whether this function is defaulted.
OverloadedOperatorKind getOverloadedOperator() const
getOverloadedOperator - Which C++ overloaded operator this function represents, if any.
Represents a prototype with parameter type info, e.g.
param_type_iterator param_type_begin() const
unsigned getNumParams() const
QualType getParamType(unsigned i) const
param_type_iterator param_type_end() const
GlobalDecl - represents a global declaration.
CXXCtorType getCtorType() const
const Decl * getDecl() const
Represents an implicitly-generated value initialization of an object of a given type.
Describes an C or C++ initializer list.
bool isStringLiteralInit() const
Is this an initializer for an array of characters, initialized by a string literal or an @encode?
unsigned getNumInits() const
Expr * getArrayFiller()
If this initializer list initializes an array with more elements than there are initializers in the l...
const Expr * getInit(unsigned Init) const
ArrayRef< Expr * > inits()
MemberExpr - [C99 6.5.2.3] Structure and Union Members.
ValueDecl * getMemberDecl() const
Retrieve the member declaration to which this expression refers.
bool hasQualifier() const
Determines whether this member expression actually had a C++ nested-name-specifier prior to the name ...
NestedNameSpecifier * getQualifier() const
If the member name was qualified, retrieves the nested-name-specifier that precedes the member name.
A pointer to member type per C++ 8.3.3 - Pointers to members.
Represents a C++ nested name specifier, such as "\::std::vector<int>::".
ObjCEncodeExpr, used for @encode in Objective-C.
PointerType - C99 6.7.5.1 - Pointer Declarators.
A (possibly-)qualified type.
bool isVolatileQualified() const
Determine whether this type is volatile-qualified.
bool isNull() const
Return true if this QualType doesn't point to a type yet.
LangAS getAddressSpace() const
Return the address space of this type.
Qualifiers getQualifiers() const
Retrieve the set of qualifiers applied to this type.
Qualifiers::ObjCLifetime getObjCLifetime() const
Returns lifetime attribute of this type.
QualType getCanonicalType() const
DestructionKind isDestructedType() const
Returns a nonzero value if objects of this type require non-trivial work to clean up after.
bool isPODType(const ASTContext &Context) const
Determine whether this is a Plain Old Data (POD) type (C++ 3.9p10).
bool hasStrongOrWeakObjCLifetime() const
The collection of all-type qualifiers we support.
@ OCL_Strong
Assigning into this object requires the old value to be released and the new value to be retained.
@ OCL_ExplicitNone
This object can be modified without requiring retains or releases.
@ OCL_None
There is no lifetime qualification on this type.
@ OCL_Weak
Reading or writing from this object requires a barrier call.
@ OCL_Autoreleasing
Assigning into this object requires a lifetime extension.
LangAS getAddressSpace() const
bool mayInsertExtraPadding(bool EmitRemark=false) const
Whether we are allowed to insert extra padding between fields.
A helper class that allows the use of isa/cast/dyncast to detect TagType objects of structs/unions/cl...
RecordDecl * getDecl() const
Base for LValueReferenceType and RValueReferenceType.
Scope - A scope is a transient data structure that is used while parsing the program.
Encodes a location in the source.
SourceLocation getBeginLoc() const LLVM_READONLY
StringLiteral - This represents a string literal expression, e.g.
The base class of the type hierarchy.
CXXRecordDecl * getAsCXXRecordDecl() const
Retrieves the CXXRecordDecl that this type refers to, either because the type is a RecordType or beca...
bool isConstantArrayType() const
bool isVoidPointerType() const
bool isPointerType() const
bool isIntegerType() const
isIntegerType() does not include complex integers (a GCC extension).
const T * castAs() const
Member-template castAs<specific type>.
QualType getPointeeType() const
If this is a pointer, ObjC object pointer, or block pointer, this returns the respective pointee.
const ArrayType * getAsArrayTypeUnsafe() const
A variant of getAs<> for array types which silently discards qualifiers from the outermost type.
const T * getAs() const
Member-template getAs<specific type>'.
bool isRecordType() const
@ Decl
The l-value was an access to a declared entity or something equivalently strong, like the address of ...
@ EHCleanup
Denotes a cleanup that should run when a scope is exited using exceptional control flow (a throw stat...
const internal::VariadicAllOfMatcher< Type > type
Matches Types in the clang AST.
const AstTypeMatcher< ArrayType > arrayType
Matches all kinds of arrays.
bool This(InterpState &S, CodePtr OpPC)
bool Zero(InterpState &S, CodePtr OpPC)
The JSON file list parser is used to communicate input to InstallAPI.
CXXCtorType
C++ constructor types.
@ Ctor_Base
Base object ctor.
@ Ctor_Complete
Complete object ctor.
@ Dtor_Complete
Complete object dtor.
LangAS
Defines the address space values used by the address space qualifier of QualType.
const FunctionProtoType * T
bool declaresSameEntity(const Decl *D1, const Decl *D2)
Determine whether two declarations declare the same entity.
__DEVICE__ _Tp arg(const std::complex< _Tp > &__c)
llvm::IntegerType * Int8Ty
i8, i16, i32, and i64
CharUnits getPointerSize() const
llvm::IntegerType * SizeTy
CharUnits getSizeAlign() const
llvm::PointerType * Int8PtrTy
CharUnits getPointerAlign() const
A metaprogramming class for ensuring that a value will dominate an arbitrary position in a function.
static saved_type save(CodeGenFunction &CGF, type value)
void set(SanitizerMask K, bool Value)
Enable or disable a certain (single) sanitizer.
bool has(SanitizerMask K) const
Check if a certain (single) sanitizer is enabled.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4