21 #include "llvm/IR/CallSite.h"
22 #include "llvm/IR/Intrinsics.h"
24 using namespace clang;
25 using namespace CodeGen;
28 struct MemberCallInfo {
40 assert(CE ==
nullptr || isa<CXXMemberCallExpr>(CE) ||
41 isa<CXXOperatorCallExpr>(CE));
43 "Trying to emit a member or operator call expr on a static method!");
50 RD ? C.getPointerType(C.getTypeDeclType(RD)) : C.VoidPtrTy);
59 unsigned PrefixSize = Args.size() - 1;
69 unsigned ArgsToSkip = isa<CXXOperatorCallExpr>(CE) ? 1 : 0;
75 "No CallExpr specified for function with non-zero number of arguments");
77 return {required, PrefixSize};
88 *
this, MD, This, ImplicitParam, ImplicitParamTy, CE, Args, RtlArgs);
90 Args, FPT, CallInfo.ReqArgs, CallInfo.PrefixSize);
91 return EmitCall(FnInfo, Callee, ReturnValue, Args);
100 ImplicitParamTy, CE, Args,
nullptr);
161 return cast<CXXRecordDecl>(Ty->
getDecl());
170 if (isa<BinaryOperator>(callee))
173 const MemberExpr *ME = cast<MemberExpr>(callee);
176 if (MD->isStatic()) {
189 CE, MD, ReturnValue, HasQualifier, Qualifier, IsArrow, Base);
196 assert(isa<CXXMemberCallExpr>(CE) || isa<CXXOperatorCallExpr>(CE));
199 bool CanUseVirtualCall = MD->
isVirtual() && !HasQualifier;
202 if (CanUseVirtualCall &&
206 assert(DevirtualizedMethod);
216 DevirtualizedMethod =
nullptr;
226 DevirtualizedMethod =
nullptr;
234 if (
auto *OCE = dyn_cast<CXXOperatorCallExpr>(CE)) {
235 if (OCE->isAssignmentOp()) {
236 RtlArgs = &RtlArgStorage;
251 if (isa<CXXDestructorDecl>(MD))
return RValue::get(
nullptr);
252 if (isa<CXXConstructorDecl>(MD) &&
253 cast<CXXConstructorDecl>(MD)->isDefaultConstructor())
260 LValue RHS = isa<CXXOperatorCallExpr>(CE)
262 (*RtlArgs)[0].RV.getScalarVal(),
269 if (isa<CXXConstructorDecl>(MD) &&
270 cast<CXXConstructorDecl>(MD)->isCopyOrMoveConstructor()) {
272 assert(CE->
getNumArgs() == 1 &&
"unexpected argcount for trivial ctor");
277 llvm_unreachable(
"unknown trivial member function");
283 DevirtualizedMethod ? DevirtualizedMethod : MD;
285 if (
const auto *Dtor = dyn_cast<CXXDestructorDecl>(CalleeDecl))
288 else if (
const auto *Ctor = dyn_cast<CXXConstructorDecl>(CalleeDecl))
305 if (
const auto *CMCE = dyn_cast<CXXMemberCallExpr>(CE)) {
306 auto *IOA = CMCE->getImplicitObjectArgument();
308 if (IsImplicitObjectCXXThis)
309 SkippedChecks.
set(SanitizerKind::Alignment,
true);
310 if (IsImplicitObjectCXXThis || isa<DeclRefExpr>(IOA))
311 SkippedChecks.
set(SanitizerKind::Null,
true);
328 bool UseVirtualCall = CanUseVirtualCall && !DevirtualizedMethod;
332 "Destructor shouldn't have explicit parameters");
333 assert(ReturnValue.
isNull() &&
"Destructor shouldn't have return value");
334 if (UseVirtualCall) {
336 *
this, Dtor,
Dtor_Complete, This, cast<CXXMemberCallExpr>(CE));
341 else if (!DevirtualizedMethod)
347 cast<CXXDestructorDecl>(DevirtualizedMethod);
353 CalleeDecl, Callee, ReturnValue, This.
getPointer(),
364 }
else if (UseVirtualCall) {
377 else if (!DevirtualizedMethod)
382 DevirtualizedMethod);
388 *
this, CalleeDecl, This, UseVirtualCall);
392 CalleeDecl, Callee, ReturnValue, This.
getPointer(),
429 ThisPtrForCall, MemFnPtr, MPT);
454 "Trying to emit a member call expr on a static method!");
456 E, MD, ReturnValue,
false,
nullptr,
484 std::vector<CharUnits> VBPtrOffsets =
486 for (
CharUnits VBPtrOffset : VBPtrOffsets) {
488 if (VBPtrOffset >= NVSize)
490 std::pair<CharUnits, CharUnits> LastStore = Stores.pop_back_val();
491 CharUnits LastStoreOffset = LastStore.first;
492 CharUnits LastStoreSize = LastStore.second;
494 CharUnits SplitBeforeOffset = LastStoreOffset;
495 CharUnits SplitBeforeSize = VBPtrOffset - SplitBeforeOffset;
496 assert(!SplitBeforeSize.
isNegative() &&
"negative store size!");
497 if (!SplitBeforeSize.
isZero())
498 Stores.emplace_back(SplitBeforeOffset, SplitBeforeSize);
500 CharUnits SplitAfterOffset = VBPtrOffset + VBPtrWidth;
501 CharUnits SplitAfterSize = LastStoreSize - SplitAfterOffset;
502 assert(!SplitAfterSize.
isNegative() &&
"negative store size!");
503 if (!SplitAfterSize.
isZero())
504 Stores.emplace_back(SplitAfterOffset, SplitAfterSize);
514 if (!NullConstantForBase->isNullValue()) {
515 llvm::GlobalVariable *NullVariable =
new llvm::GlobalVariable(
517 true, llvm::GlobalVariable::PrivateLinkage,
518 NullConstantForBase, Twine());
522 NullVariable->setAlignment(Align.getQuantity());
527 for (std::pair<CharUnits, CharUnits>
Store : Stores) {
541 for (std::pair<CharUnits, CharUnits>
Store : Stores) {
547 CGF.
Builder.getInt8(0), StoreSizeVal);
555 assert(!Dest.
isIgnored() &&
"Must have a destination!");
577 if (CD->isTrivial() && CD->isDefaultConstructor())
597 bool ForVirtualBase =
false;
598 bool Delegating =
false;
612 ForVirtualBase =
true;
628 Exp =
E->getSubExpr();
629 assert(isa<CXXConstructExpr>(Exp) &&
630 "EmitSynthesizedCXXCopyCtor - unknown copy ctor expr");
643 &&
"EmitSynthesizedCXXCopyCtor - Copied-in Array");
662 unsigned minElements,
671 return sizeWithoutCookie;
675 unsigned sizeWidth = CGF.
SizeTy->getBitWidth();
678 llvm::APInt cookieSize(sizeWidth,
688 assert(isa<llvm::IntegerType>(numElements->getType()));
698 llvm::IntegerType *numElementsType
699 = cast<llvm::IntegerType>(numElements->getType());
700 unsigned numElementsWidth = numElementsType->getBitWidth();
703 llvm::APInt arraySizeMultiplier(sizeWidth, 1);
706 type = CAT->getElementType();
707 arraySizeMultiplier *= CAT->getSize();
711 llvm::APInt typeSizeMultiplier(sizeWidth, typeSize.
getQuantity());
712 typeSizeMultiplier *= arraySizeMultiplier;
719 if (llvm::ConstantInt *numElementsC =
720 dyn_cast<llvm::ConstantInt>(numElements)) {
721 const llvm::APInt &count = numElementsC->getValue();
723 bool hasAnyOverflow =
false;
726 if (isSigned && count.isNegative())
727 hasAnyOverflow =
true;
732 else if (numElementsWidth > sizeWidth &&
733 numElementsWidth - sizeWidth > count.countLeadingZeros())
734 hasAnyOverflow =
true;
737 llvm::APInt adjustedCount = count.zextOrTrunc(sizeWidth);
741 if (adjustedCount.ult(minElements))
742 hasAnyOverflow =
true;
747 numElements = llvm::ConstantInt::get(CGF.
SizeTy,
748 adjustedCount * arraySizeMultiplier);
752 llvm::APInt allocationSize
753 = adjustedCount.umul_ov(typeSizeMultiplier, overflow);
754 hasAnyOverflow |= overflow;
757 if (cookieSize != 0) {
760 sizeWithoutCookie = llvm::ConstantInt::get(CGF.
SizeTy, allocationSize);
762 allocationSize = allocationSize.uadd_ov(cookieSize, overflow);
763 hasAnyOverflow |= overflow;
767 if (hasAnyOverflow) {
768 size = llvm::Constant::getAllOnesValue(CGF.
SizeTy);
770 size = llvm::ConstantInt::get(CGF.
SizeTy, allocationSize);
793 if (numElementsWidth > sizeWidth) {
794 llvm::APInt threshold(numElementsWidth, 1);
795 threshold <<= sizeWidth;
798 = llvm::ConstantInt::get(numElementsType, threshold);
800 hasOverflow = CGF.
Builder.CreateICmpUGE(numElements, thresholdV);
801 numElements = CGF.
Builder.CreateTrunc(numElements, CGF.
SizeTy);
804 }
else if (isSigned) {
805 if (numElementsWidth < sizeWidth)
806 numElements = CGF.
Builder.CreateSExt(numElements, CGF.
SizeTy);
813 if (typeSizeMultiplier == 1)
814 hasOverflow = CGF.
Builder.CreateICmpSLT(numElements,
815 llvm::ConstantInt::get(CGF.
SizeTy, minElements));
818 }
else if (numElementsWidth < sizeWidth) {
819 numElements = CGF.
Builder.CreateZExt(numElements, CGF.
SizeTy);
822 assert(numElements->getType() == CGF.
SizeTy);
827 hasOverflow = CGF.
Builder.CreateICmpULT(numElements,
828 llvm::ConstantInt::get(CGF.
SizeTy, minElements));
829 }
else if (numElementsWidth > sizeWidth) {
833 hasOverflow = CGF.
Builder.CreateOr(hasOverflow,
834 CGF.
Builder.CreateICmpULT(numElements,
835 llvm::ConstantInt::get(CGF.
SizeTy, minElements)));
848 if (typeSizeMultiplier != 1) {
853 llvm::ConstantInt::get(CGF.
SizeTy, typeSizeMultiplier);
855 CGF.
Builder.CreateCall(umul_with_overflow, {size, tsmV});
859 hasOverflow = CGF.
Builder.CreateOr(hasOverflow, overflowed);
861 hasOverflow = overflowed;
863 size = CGF.
Builder.CreateExtractValue(result, 0);
866 if (arraySizeMultiplier != 1) {
869 if (typeSize.
isOne()) {
870 assert(arraySizeMultiplier == typeSizeMultiplier);
876 llvm::ConstantInt::get(CGF.
SizeTy, arraySizeMultiplier);
877 numElements = CGF.
Builder.CreateMul(numElements, asmV);
882 assert(arraySizeMultiplier == 1);
886 if (cookieSize != 0) {
887 sizeWithoutCookie = size;
894 CGF.
Builder.CreateCall(uadd_with_overflow, {size, cookieSizeV});
898 hasOverflow = CGF.
Builder.CreateOr(hasOverflow, overflowed);
900 hasOverflow = overflowed;
902 size = CGF.
Builder.CreateExtractValue(result, 0);
909 size = CGF.
Builder.CreateSelect(hasOverflow,
910 llvm::Constant::getAllOnesValue(CGF.
SizeTy),
915 sizeWithoutCookie = size;
917 assert(sizeWithoutCookie &&
"didn't set sizeWithoutCookie?");
944 llvm_unreachable(
"bad evaluation kind");
958 unsigned InitListElements = 0;
964 llvm::Instruction *CleanupDominator =
nullptr;
971 auto TryMemsetInitialization = [&]() ->
bool {
981 auto *RemainingSize = AllocSizeWithoutCookie;
982 if (InitListElements) {
984 auto *InitializedSize = llvm::ConstantInt::get(
985 RemainingSize->getType(),
988 RemainingSize =
Builder.CreateSub(RemainingSize, InitializedSize);
997 if (
const InitListExpr *ILE = dyn_cast<InitListExpr>(Init)) {
1000 if (ILE->isStringLiteralInit()) {
1013 cast<ConstantArrayType>(ILE->getType()->getAsArrayTypeUnsafe())
1014 ->getSize().getZExtValue();
1023 llvm::ConstantInt *ConstNum = dyn_cast<llvm::ConstantInt>(NumElements);
1024 if (!ConstNum || !ConstNum->equalsInt(InitListElements)) {
1025 bool OK = TryMemsetInitialization();
1027 assert(OK &&
"couldn't memset character type?");
1032 InitListElements = ILE->getNumInits();
1054 ElementType, ElementAlign,
1060 for (
unsigned i = 0, e = ILE->getNumInits(); i != e; ++i) {
1073 ILE->getInit(i)->getType(), CurPtr);
1081 Init = ILE->getArrayFiller();
1090 assert(SubILE->getNumInits() == 0 &&
"explicit inits in array filler?");
1091 Init = SubILE->getArrayFiller();
1100 llvm::ConstantInt *ConstNum = dyn_cast<llvm::ConstantInt>(NumElements);
1101 if (ConstNum && ConstNum->getZExtValue() <= InitListElements) {
1103 if (CleanupDominator)
1108 assert(Init &&
"have trailing elements to initialize but no initializer");
1120 if (TryMemsetInitialization())
1132 if (InitListElements)
1133 NumElements =
Builder.CreateSub(
1135 llvm::ConstantInt::get(NumElements->getType(), InitListElements));
1137 CCE->requiresZeroInitialization());
1143 if (isa<ImplicitValueInitExpr>(Init)) {
1144 if (TryMemsetInitialization())
1156 "got wrong type of element to initialize");
1159 if (
auto *ILE = dyn_cast<InitListExpr>(Init))
1160 if (ILE->getNumInits() == 0 && TryMemsetInitialization())
1165 if (
auto *ILE = dyn_cast<InitListExpr>(Init)) {
1167 if (RType->getDecl()->isStruct()) {
1168 unsigned NumElements = 0;
1169 if (
auto *CXXRD = dyn_cast<CXXRecordDecl>(RType->getDecl()))
1170 NumElements = CXXRD->getNumBases();
1171 for (
auto *Field : RType->getDecl()->fields())
1172 if (!Field->isUnnamedBitfield())
1175 if (ILE->getNumInits() == NumElements)
1176 for (
unsigned i = 0, e = ILE->getNumInits(); i != e; ++i)
1177 if (!isa<ImplicitValueInitExpr>(ILE->getInit(i)))
1179 if (ILE->getNumInits() == NumElements && TryMemsetInitialization())
1186 llvm::BasicBlock *EntryBB =
Builder.GetInsertBlock();
1199 Builder.CreateCondBr(IsEmpty, ContBB, LoopBB);
1206 llvm::PHINode *CurPtrPhi =
1208 CurPtrPhi->addIncoming(CurPtr.
getPointer(), EntryBB);
1210 CurPtr =
Address(CurPtrPhi, ElementAlign);
1219 ElementType, ElementAlign,
1222 CleanupDominator =
Builder.CreateUnreachable();
1229 if (CleanupDominator) {
1231 CleanupDominator->eraseFromParent();
1242 Builder.CreateCondBr(IsEnd, ContBB, LoopBB);
1243 CurPtrPhi->addIncoming(NextPtr,
Builder.GetInsertBlock());
1255 AllocSizeWithoutCookie);
1266 llvm::Instruction *CallOrInvoke;
1271 Args, CalleeType,
false),
1279 llvm::Function *Fn = dyn_cast<llvm::Function>(CalleePtr);
1281 Fn && Fn->hasFnAttribute(llvm::Attribute::NoBuiltin)) {
1283 if (llvm::CallInst *CI = dyn_cast<llvm::CallInst>(CallOrInvoke))
1284 CI->addAttribute(llvm::AttributeList::FunctionIndex,
1285 llvm::Attribute::Builtin);
1286 else if (llvm::InvokeInst *II = dyn_cast<llvm::InvokeInst>(CallOrInvoke))
1287 II->addAttribute(llvm::AttributeList::FunctionIndex,
1288 llvm::Attribute::Builtin);
1290 llvm_unreachable(
"unexpected kind of call instruction");
1300 const Stmt *ArgS = Arg;
1305 .getCXXOperatorName(IsDelete ? OO_Delete : OO_New);
1307 if (
auto *FD = dyn_cast<FunctionDecl>(
Decl))
1308 if (Ctx.hasSameType(FD->getType(),
QualType(Type, 0)))
1310 llvm_unreachable(
"predeclared global operator new/delete is missing");
1313 static std::pair<bool, bool>
1321 bool PassSize =
false;
1322 bool PassAlignment =
false;
1324 if (AI != AE && (*AI)->isIntegerType()) {
1329 if (AI != AE && (*AI)->isAlignValT()) {
1330 PassAlignment =
true;
1334 assert(AI == AE &&
"unexpected usual deallocation function parameter");
1335 return {PassSize, PassAlignment};
1342 template<
typename Traits>
1345 typedef typename Traits::ValueTy ValueTy;
1347 typedef typename Traits::RValueTy RValueTy;
1348 struct PlacementArg {
1353 unsigned NumPlacementArgs : 31;
1354 unsigned PassAlignmentToPlacementDelete : 1;
1360 PlacementArg *getPlacementArgs() {
1361 return reinterpret_cast<PlacementArg *
>(
this + 1);
1365 static size_t getExtraSize(
size_t NumPlacementArgs) {
1366 return NumPlacementArgs *
sizeof(PlacementArg);
1369 CallDeleteDuringNew(
size_t NumPlacementArgs,
1371 ValueTy AllocSize,
bool PassAlignmentToPlacementDelete,
1373 : NumPlacementArgs(NumPlacementArgs),
1374 PassAlignmentToPlacementDelete(PassAlignmentToPlacementDelete),
1375 OperatorDelete(OperatorDelete), Ptr(Ptr), AllocSize(AllocSize),
1376 AllocAlign(AllocAlign) {}
1378 void setPlacementArg(
unsigned I, RValueTy Arg,
QualType Type) {
1379 assert(I < NumPlacementArgs &&
"index out of range");
1380 getPlacementArgs()[
I] = {Arg, Type};
1392 bool PassSize =
false;
1393 bool PassAlignment =
false;
1394 if (NumPlacementArgs) {
1397 PassAlignment = PassAlignmentToPlacementDelete;
1401 std::tie(PassSize, PassAlignment) =
1407 DeleteArgs.add(Traits::get(CGF, AllocSize),
1415 DeleteArgs.add(
RValue::get(llvm::ConstantInt::get(
1416 CGF.
SizeTy, AllocAlign.getQuantity())),
1420 for (
unsigned I = 0;
I != NumPlacementArgs; ++
I) {
1421 auto Arg = getPlacementArgs()[
I];
1422 DeleteArgs.add(Traits::get(CGF, Arg.ArgValue), Arg.ArgType);
1444 struct DirectCleanupTraits {
1451 typedef CallDeleteDuringNew<DirectCleanupTraits> DirectCleanup;
1453 DirectCleanup *Cleanup = CGF.
EHStack
1462 auto &Arg = NewArgs[
I + NumNonPlacementArgs];
1463 Cleanup->setPlacementArg(
I, Arg.RV, Arg.Ty);
1475 struct ConditionalCleanupTraits {
1479 return V.restore(CGF);
1482 typedef CallDeleteDuringNew<ConditionalCleanupTraits> ConditionalCleanup;
1484 ConditionalCleanup *Cleanup = CGF.
EHStack
1493 auto &Arg = NewArgs[
I + NumNonPlacementArgs];
1509 unsigned minElements = 0;
1515 ->getSize().getZExtValue();
1524 allocSizeWithoutCookie);
1555 unsigned ParamsToSkip = 0;
1562 if (allocSize != allocSizeWithoutCookie) {
1564 allocAlign =
std::max(allocAlign, cookieAlign);
1575 "wrong type for alignment parameter");
1579 assert(allocator->
isVariadic() &&
"can't pass alignment to allocator");
1600 unsigned AllocatorAlign = llvm::PowerOf2Floor(std::min<uint64_t>(
1603 allocationAlign,
getContext().toCharUnitsFromBits(AllocatorAlign));
1606 allocation =
Address(RV.getScalarVal(), allocationAlign);
1616 llvm::BasicBlock *nullCheckBB =
nullptr;
1617 llvm::BasicBlock *contBB =
nullptr;
1624 conditional.
begin(*
this);
1626 nullCheckBB =
Builder.GetInsertBlock();
1632 Builder.CreateCondBr(isNull, contBB, notNullBB);
1639 llvm::Instruction *cleanupDominator =
nullptr;
1645 cleanupDominator =
Builder.CreateUnreachable();
1648 assert((allocSize == allocSizeWithoutCookie) ==
1650 if (allocSize != allocSizeWithoutCookie) {
1670 allocSizeWithoutCookie);
1676 if (result.
getType() != resultType)
1682 if (operatorDeleteCleanup.
isValid()) {
1684 cleanupDominator->eraseFromParent();
1689 conditional.
end(*
this);
1691 llvm::BasicBlock *notNullBB =
Builder.GetInsertBlock();
1694 llvm::PHINode *PHI =
Builder.CreatePHI(resultPtr->getType(), 2);
1695 PHI->addIncoming(resultPtr, notNullBB);
1696 PHI->addIncoming(llvm::Constant::getNullValue(resultPtr->getType()),
1709 assert((!NumElements && CookieSize.
isZero()) ||
1717 std::pair<bool, bool> PassSizeAndAlign =
1720 auto ParamTypeIt = DeleteFTy->param_type_begin();
1728 if (PassSizeAndAlign.first) {
1729 QualType SizeType = *ParamTypeIt++;
1736 Size =
Builder.CreateMul(Size, NumElements);
1739 if (!CookieSize.
isZero())
1747 if (PassSizeAndAlign.second) {
1748 QualType AlignValType = *ParamTypeIt++;
1756 assert(ParamTypeIt == DeleteFTy->param_type_end() &&
1757 "unknown parameter to usual delete function");
1773 : Ptr(Ptr), OperatorDelete(OperatorDelete), ElementType(ElementType) {}
1786 OperatorDelete, ElementType);
1825 OperatorDelete, ElementType);
1866 : Ptr(Ptr), OperatorDelete(OperatorDelete), NumElements(NumElements),
1867 ElementType(ElementType), CookieSize(CookieSize) {}
1870 CGF.
EmitDeleteCall(OperatorDelete, Ptr, ElementType, NumElements,
1885 numElements, allocatedPtr, cookieSize);
1887 assert(allocatedPtr &&
"ReadArrayCookie didn't set allocated pointer");
1892 allocatedPtr, operatorDelete,
1893 numElements, elementType,
1898 assert(numElements &&
"no element count for a type with a destructor!");
1906 CGF.
Builder.CreateInBoundsGEP(arrayBegin, numElements,
"delete.end");
1931 Builder.CreateCondBr(IsNull, DeleteEnd, DeleteNotNull);
1942 GEP.push_back(Zero);
1946 =
getContext().getAsConstantArrayType(DeleteTy)) {
1948 DeleteTy = Arr->getElementType();
1951 GEP.push_back(Zero);
1972 if (
const auto *CE = dyn_cast<CastExpr>(E)) {
1973 if (!CE->getSubExpr()->isGLValue())
1978 if (
const auto *OVE = dyn_cast<OpaqueValueExpr>(E))
1981 if (
const auto *BO = dyn_cast<BinaryOperator>(E))
1982 if (BO->getOpcode() == BO_Comma)
1985 if (
const auto *ACO = dyn_cast<AbstractConditionalOperator>(E))
1991 if (isa<ArraySubscriptExpr>(E))
1994 if (
const auto *UO = dyn_cast<UnaryOperator>(E))
1995 if (UO->getOpcode() == UO_Deref)
2017 llvm::BasicBlock *BadTypeidBlock =
2022 CGF.
Builder.CreateCondBr(IsNull, BadTypeidBlock, EndBlock);
2061 return llvm::Constant::getNullValue(DestLTy);
2069 return llvm::UndefValue::get(DestLTy);
2088 bool isDynamicCastToVoid;
2096 isDynamicCastToVoid =
false;
2097 SrcRecordTy = SrcTy;
2101 assert(SrcRecordTy->
isRecordType() &&
"source type must be a record type!");
2106 bool ShouldNullCheckSrcValue =
2110 llvm::BasicBlock *CastNull =
nullptr;
2111 llvm::BasicBlock *CastNotNull =
nullptr;
2114 if (ShouldNullCheckSrcValue) {
2119 Builder.CreateCondBr(IsNull, CastNull, CastNotNull);
2124 if (isDynamicCastToVoid) {
2129 "destination type must be a record type!");
2131 DestTy, DestRecordTy, CastEnd);
2132 CastNotNull =
Builder.GetInsertBlock();
2135 if (ShouldNullCheckSrcValue) {
2144 if (ShouldNullCheckSrcValue) {
2145 llvm::PHINode *PHI =
Builder.CreatePHI(Value->getType(), 2);
2146 PHI->addIncoming(Value, CastNotNull);
2147 PHI->addIncoming(llvm::Constant::getNullValue(Value->getType()), CastNull);
2162 i != e; ++i, ++CurField) {
2165 if (CurField->hasCapturedVLAType()) {
2166 auto VAT = CurField->getCapturedVLAType();
A call to an overloaded operator written using operator syntax.
ValueDecl * getMemberDecl() const
Retrieve the member declaration to which this expression refers.
ReturnValueSlot - Contains the address where the return value of a function can be stored...
virtual llvm::Value * EmitVirtualDestructorCall(CodeGenFunction &CGF, const CXXDestructorDecl *Dtor, CXXDtorType DtorType, Address This, const CXXMemberCallExpr *CE)=0
Emit the ABI-specific virtual destructor call.
bool isNegative() const
isNegative - Test whether the quantity is less than zero.
unsigned getNumInits() const
virtual void EmitBadTypeidCall(CodeGenFunction &CGF)=0
FunctionDecl - An instance of this class is created to represent a function declaration or definition...
void end(CodeGenFunction &CGF)
CGCallee BuildAppleKextVirtualCall(const CXXMethodDecl *MD, NestedNameSpecifier *Qual, llvm::Type *Ty)
BuildAppleKextVirtualCall - This routine is to support gcc's kext ABI making indirect call to virtual...
PointerType - C99 6.7.5.1 - Pointer Declarators.
llvm::iterator_range< arg_iterator > placement_arguments()
Destroyer * getDestroyer(QualType::DestructionKind destructionKind)
A (possibly-)qualified type.
bool isConstantArrayType() const
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 ...
bool isPODType(const ASTContext &Context) const
Determine whether this is a Plain Old Data (POD) type (C++ 3.9p10).
CodeGenTypes & getTypes()
llvm::Type * ConvertTypeForMem(QualType T)
Expr * getArg(unsigned Arg)
getArg - Return the specified argument.
bool hasTrivialDestructor() const
Determine whether this class has a trivial destructor (C++ [class.dtor]p3)
DestructionKind isDestructedType() const
Returns a nonzero value if objects of this type require non-trivial work to clean up after...
CXXCtorType getCtorType() const
bool isElidable() const
Whether this construction is elidable.
llvm::Module & getModule() const
void EmitARCDestroyWeak(Address addr)
void @objc_destroyWeak(i8** addr) Essentially objc_storeWeak(addr, nil).
bool isOne() const
isOne - Test whether the quantity equals one.
Stmt - This represents one statement.
bool isInConditionalBranch() const
isInConditionalBranch - Return true if we're currently emitting one branch or the other of a conditio...
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...
void EmitNewArrayInitializer(const CXXNewExpr *E, QualType elementType, llvm::Type *ElementTy, Address NewPtr, llvm::Value *NumElements, llvm::Value *AllocSizeWithoutCookie)
llvm::ConstantInt * getSize(CharUnits N)
CanQualType getSizeType() const
Return the unique type for "size_t" (C99 7.17), defined in <stddef.h>.
virtual bool shouldTypeidBeNullChecked(bool IsDeref, QualType SrcRecordTy)=0
Checking the 'this' pointer for a constructor call.
QuantityType getQuantity() const
getQuantity - Get the raw integer representation of this quantity.
NestedNameSpecifier * getQualifier() const
If the member name was qualified, retrieves the nested-name-specifier that precedes the member name...
bool isRecordType() const
Decl - This represents one declaration (or definition), e.g.
Address getAddress() const
void EmitTypeCheck(TypeCheckKind TCK, SourceLocation Loc, llvm::Value *V, QualType Type, CharUnits Alignment=CharUnits::Zero(), SanitizerSet SkippedChecks=SanitizerSet())
Emit a check that V is the address of storage of the appropriate size and alignment for an object of ...
virtual bool shouldDynamicCastCallBeNullChecked(bool SrcIsPtr, QualType SrcRecordTy)=0
bool hasDefinition() const
const void * Store
Store - This opaque type encapsulates an immutable mapping from locations to values.
QualType getPointeeType() const
The base class of the type hierarchy.
void EmitStoreThroughLValue(RValue Src, LValue Dst, bool isInit=false)
EmitStoreThroughLValue - Store the specified rvalue into the specified lvalue, where both are guarant...
void EmitComplexExprIntoLValue(const Expr *E, LValue dest, bool isInit)
EmitComplexExprIntoLValue - Emit the given expression of complex type and place its result into the s...
QualType getRecordType(const RecordDecl *Decl) const
Represents an array type, per C99 6.7.5.2 - Array Declarators.
Represents a call to a C++ constructor.
RValue EmitCXXMemberCallExpr(const CXXMemberCallExpr *E, ReturnValueSlot ReturnValue)
The l-value was an access to a declared entity or something equivalently strong, like the address of ...
const LangOptions & getLangOpts() const
LValue EmitLValueForFieldInitialization(LValue Base, const FieldDecl *Field)
EmitLValueForFieldInitialization - Like EmitLValueForField, except that if the Field is a reference...
llvm::IntegerType * Int8Ty
i8, i16, i32, and i64
Represents a C++ constructor within a class.
Expr * ignoreParenBaseCasts() LLVM_READONLY
Ignore parentheses and derived-to-base casts.
bool isCopyAssignmentOperator() const
Determine whether this is a copy-assignment operator, regardless of whether it was declared implicitl...
static llvm::Value * EmitCXXNewAllocSize(CodeGenFunction &CGF, const CXXNewExpr *e, unsigned minElements, llvm::Value *&numElements, llvm::Value *&sizeWithoutCookie)
Expr *const * const_capture_init_iterator
Const iterator that walks over the capture initialization arguments.
static saved_type save(CodeGenFunction &CGF, type value)
llvm::Type * getElementType() const
Return the type of the values stored in this address.
const Expr * getCallee() const
static std::pair< bool, bool > shouldPassSizeAndAlignToUsualDelete(const FunctionProtoType *FPT)
T * pushCleanupWithExtra(CleanupKind Kind, size_t N, As...A)
Push a cleanup with non-constant storage requirements on the stack.
field_iterator field_begin() const
uint64_t getTypeSize(QualType T) const
Return the size of the specified (complete) type T, in bits.
Address CreateConstInBoundsByteGEP(Address Addr, CharUnits Offset, const llvm::Twine &Name="")
Given a pointer to i8, adjust it by a given constant offset.
const CGFunctionInfo & arrangeCXXStructorDeclaration(const CXXMethodDecl *MD, StructorType Type)
static MemberCallInfo commonEmitCXXMemberOrOperatorCall(CodeGenFunction &CGF, const CXXMethodDecl *MD, llvm::Value *This, llvm::Value *ImplicitParam, QualType ImplicitParamTy, const CallExpr *CE, CallArgList &Args, CallArgList *RtlArgs)
IsZeroed_t isZeroed() const
RValue EmitCUDAKernelCallExpr(const CUDAKernelCallExpr *E, ReturnValueSlot ReturnValue)
Represents an expression – generally a full-expression – that introduces cleanups to be run at the en...
bool isMoveAssignmentOperator() const
Determine whether this is a move assignment operator.
RValue EmitCXXMemberOrOperatorCall(const CXXMethodDecl *Method, const CGCallee &Callee, ReturnValueSlot ReturnValue, llvm::Value *This, llvm::Value *ImplicitParam, QualType ImplicitParamTy, const CallExpr *E, CallArgList *RtlArgs)
The collection of all-type qualifiers we support.
unsigned getNumParams() const
An object to manage conditionally-evaluated expressions.
llvm::Value * EmitCXXNewExpr(const CXXNewExpr *E)
bool isEmpty() const
Determine whether this is an empty class in the sense of (C++11 [meta.unary.prop]).
CodeGenFunction - This class organizes the per-function state that is used while generating LLVM code...
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
llvm::Value * EmitDynamicCast(Address V, const CXXDynamicCastExpr *DCE)
void EmitSynthesizedCXXCopyCtorCall(const CXXConstructorDecl *D, Address This, Address Src, const CXXConstructExpr *E)
llvm::Constant * getAddrOfCXXStructor(const CXXMethodDecl *MD, StructorType Type, 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.
QualType getReturnType() const
static llvm::Value * EmitTypeidFromVTable(CodeGenFunction &CGF, const Expr *E, llvm::Type *StdTypeInfoPtrTy)
llvm::IntegerType * SizeTy
Denotes a cleanup that should run when a scope is exited using exceptional control flow (a throw stat...
bool isPotentiallyEvaluated() const
Determine whether this typeid has a type operand which is potentially evaluated, per C++11 [expr...
static CharUnits Zero()
Zero - Construct a CharUnits quantity of zero.
A metaprogramming class for ensuring that a value will dominate an arbitrary position in a function...
bool hasStrongOrWeakObjCLifetime() const
void EmitCXXConstructorCall(const CXXConstructorDecl *D, CXXCtorType Type, bool ForVirtualBase, bool Delegating, Address This, const CXXConstructExpr *E)
void EmitInitializerForField(FieldDecl *Field, LValue LHS, Expr *Init)
virtual RValue EmitCUDAKernelCallExpr(CodeGenFunction &CGF, const CUDAKernelCallExpr *E, ReturnValueSlot ReturnValue)
Describes an C or C++ initializer list.
A C++ typeid expression (C++ [expr.typeid]), which gets the type_info that corresponds to the supplie...
void pushRegularPartialArrayCleanup(llvm::Value *arrayBegin, llvm::Value *arrayEnd, QualType elementType, CharUnits elementAlignment, Destroyer *destroyer)
pushRegularPartialArrayCleanup - Push an EH cleanup to destroy already-constructed elements of the gi...
CGCUDARuntime & getCUDARuntime()
Return a reference to the configured CUDA runtime.
bool isAlwaysNull() const
isAlwaysNull - Return whether the result of the dynamic_cast is proven to always be null...
Address CreateElementBitCast(Address Addr, llvm::Type *Ty, const llvm::Twine &Name="")
Cast the element type of the given address to a different type, preserving information like the align...
CharUnits - This is an opaque type for sizes expressed in character units.
void EmitARCDestroyStrong(Address addr, ARCPreciseLifetime_t precise)
Destroy a __strong variable.
const CXXRecordDecl * getParent() const
Returns the parent of this method declaration, which is the class in which this method is defined...
unsigned getNewAlign() const
Return the largest alignment for which a suitably-sized allocation with '::operator new(size_t)' is g...
bool isDefaulted() const
Whether this function is defaulted per C++0x.
capture_init_iterator capture_init_begin()
Retrieve the first initialization argument for this lambda expression (which initializes the first ca...
Expr * getInitializer()
The initializer of this new-expression.
Expr * getExprOperand() const
virtual llvm::Value * EmitDynamicCastCall(CodeGenFunction &CGF, Address Value, QualType SrcRecordTy, QualType DestTy, QualType DestRecordTy, llvm::BasicBlock *CastEnd)=0
virtual llvm::Value * EmitDynamicCastToVoid(CodeGenFunction &CGF, Address Value, QualType SrcRecordTy, QualType DestTy)=0
const ArrayType * getAsArrayType(QualType T) const
Type Query functions.
A builtin binary operation expression such as "x + y" or "x <= y".
bool needsEHCleanup(QualType::DestructionKind kind)
Determines whether an EH cleanup is required to destroy a type with the given destruction kind...
RecordDecl * getDecl() const
CharUnits getPointerSize() const
llvm::CallInst * CreateMemCpy(Address Dest, Address Src, llvm::Value *Size, bool IsVolatile=false)
void EmitAggregateAssign(Address DestPtr, Address SrcPtr, QualType EltTy)
EmitAggregateCopy - Emit an aggregate assignment.
bool isVariadic() const
Whether this function is variadic.
QualType getTypeAsWritten() const
getTypeAsWritten - Returns the type that this expression is casting to, as written in the source code...
Scope - A scope is a transient data structure that is used while parsing the program.
static void StoreAnyExprIntoOneUnit(CodeGenFunction &CGF, const Expr *Init, QualType AllocType, Address NewPtr)
void initFullExprCleanup()
Set up the last cleaup that was pushed as a conditional full-expression cleanup.
void EmitDeleteCall(const FunctionDecl *DeleteFD, llvm::Value *Ptr, QualType DeleteTy, llvm::Value *NumElements=nullptr, CharUnits CookieSize=CharUnits())
const ASTRecordLayout & getASTRecordLayout(const RecordDecl *D) const
Get or compute information about the layout of the specified record (struct/union/class) D...
llvm::BasicBlock * createBasicBlock(const Twine &name="", llvm::Function *parent=nullptr, llvm::BasicBlock *before=nullptr)
createBasicBlock - Create an LLVM basic block.
void EmitIgnoredExpr(const Expr *E)
EmitIgnoredExpr - Emit an expression in a context which ignores the result.
static void EmitNullBaseClassInitialization(CodeGenFunction &CGF, Address DestPtr, const CXXRecordDecl *Base)
AlignmentSource getAlignmentSource() const
A C++ lambda expression, which produces a function object (of unspecified type) that can be invoked l...
const CGFunctionInfo & arrangeCXXMethodDeclaration(const CXXMethodDecl *MD)
C++ methods have some special rules and also have implicit parameters.
GlobalDecl CurGD
CurGD - The GlobalDecl for the current function being compiled.
CharUnits getTypeSizeInChars(QualType T) const
Return the size of the specified (complete) type T, in characters.
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...
bool isArrow() const
Determine whether this pseudo-destructor expression was written using an '->' (otherwise, it used a '.
detail::InMemoryDirectory::const_iterator I
CXXMethodDecl * getCorrespondingMethodInClass(const CXXRecordDecl *RD, bool MayBeBase=false)
Find the method in RD that corresponds to this one.
void begin(CodeGenFunction &CGF)
This object can be modified without requiring retains or releases.
Checking the 'this' pointer for a call to a non-static member function.
const ArrayType * getAsArrayTypeUnsafe() const
A variant of getAs<> for array types which silently discards qualifiers from the outermost type...
EnumDecl * getDecl() const
FunctionDecl * getOperatorDelete() const
void EmitCXXConstructExpr(const CXXConstructExpr *E, AggValueSlot Dest)
Represents a C++ pseudo-destructor (C++ [expr.pseudo]).
void addFrom(const CallArgList &other)
Add all the arguments from another CallArgList to this one.
QualType getParamType(unsigned i) const
Represents a prototype with parameter type info, e.g.
virtual CharUnits GetArrayCookieSize(const CXXNewExpr *expr)
Returns the extra size required in order to store the array cookie for the given new-expression.
Qualifiers::ObjCLifetime getObjCLifetime() const
Returns lifetime attribute of this type.
param_type_iterator param_type_begin() const
RValue - This trivial value class is used to represent the result of an expression that is evaluated...
FunctionDecl * getOperatorDelete() const
QualType getPointeeType() const
If this is a pointer, ObjC object pointer, or block pointer, this returns the respective pointee...
ASTRecordLayout - This class contains layout information for one RecordDecl, which is a struct/union/...
bool requiresZeroInitialization() const
Whether this construction first requires zero-initialization before the initializer is called...
bool isSignedIntegerOrEnumerationType() const
Determines whether this is an integer type that is signed or an enumeration types whose underlying ty...
llvm::Value * GetVTablePtr(Address This, llvm::Type *VTableTy, const CXXRecordDecl *VTableClass)
GetVTablePtr - Return the Value of the vtable pointer member pointed to by This.
static TypeEvaluationKind getEvaluationKind(QualType T)
hasAggregateLLVMType - Return true if the specified AST type will map into an aggregate LLVM type or ...
llvm::Value * getPointer() const
Expr - This represents one expression.
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.
CGCXXABI & getCXXABI() const
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.
Enters a new scope for capturing cleanups, all of which will be executed once the scope is exited...
RValue EmitCXXPseudoDestructorExpr(const CXXPseudoDestructorExpr *E)
void pushCallObjectDeleteCleanup(const FunctionDecl *OperatorDelete, llvm::Value *CompletePtr, QualType ElementType)
void EmitCallArgs(CallArgList &Args, const T *CallArgTypeInfo, llvm::iterator_range< CallExpr::const_arg_iterator > ArgRange, AbstractCallee AC=AbstractCallee(), unsigned ParamsToSkip=0, EvaluationOrder Order=EvaluationOrder::Default)
EmitCallArgs - Emit call arguments for a function.
void EmitCXXAggrConstructorCall(const CXXConstructorDecl *D, const ArrayType *ArrayTy, Address ArrayPtr, const CXXConstructExpr *E, bool ZeroInitialization=false)
EmitCXXAggrConstructorCall - Emit a loop to call a particular constructor for each of several members...
static CGCallee forDirect(llvm::Constant *functionPtr, const CGCalleeInfo &abstractInfo=CGCalleeInfo())
SourceLocation getExprLoc() const LLVM_READONLY
Represents a C++ destructor within a class.
CharUnits getNonVirtualAlignment() const
getNonVirtualSize - Get the non-virtual alignment (in chars) of an object, which is the alignment of ...
virtual bool EmitBadCastCall(CodeGenFunction &CGF)=0
ConstructionKind getConstructionKind() const
Determine whether this constructor is actually constructing a base class (rather than a complete obje...
void add(RValue rvalue, QualType type, bool needscopy=false)
stable_iterator stable_begin() const
Create a stable reference to the top of the EH stack.
CharUnits toCharUnitsFromBits(int64_t BitSize) const
Convert a size in bits to a size in characters.
A class for recording the number of arguments that a function signature requires. ...
bool isReplaceableGlobalAllocationFunction(bool *IsAligned=nullptr) const
Determines whether this function is one of the replaceable global allocation functions: void *operato...
bool shouldNullCheckAllocation(const ASTContext &Ctx) const
True if the allocation result needs to be null-checked.
QualType getAllocatedType() const
void EmitLambdaExpr(const LambdaExpr *E, AggValueSlot Dest)
RValue EmitCXXMemberOrOperatorMemberCallExpr(const CallExpr *CE, const CXXMethodDecl *MD, ReturnValueSlot ReturnValue, bool HasQualifier, NestedNameSpecifier *Qualifier, bool IsArrow, const Expr *Base)
LValue MakeNaturalAlignAddrLValue(llvm::Value *V, QualType T)
Address EmitPointerWithAlignment(const Expr *Addr, LValueBaseInfo *BaseInfo=nullptr)
EmitPointerWithAlignment - Given an expression with a pointer type, emit the value and compute our be...
static void EmitObjectDelete(CodeGenFunction &CGF, const CXXDeleteExpr *DE, Address Ptr, QualType ElementType)
Emit the code for deleting a single object.
llvm::CallInst * CreateMemSet(Address Dest, llvm::Value *Value, llvm::Value *Size, bool IsVolatile=false)
llvm::Value * EmitCastToVoidPtr(llvm::Value *value)
Emit a cast to void* in the appropriate address space.
llvm::Function * getIntrinsic(unsigned IID, ArrayRef< llvm::Type * > Tys=None)
void emitArrayDestroy(llvm::Value *begin, llvm::Value *end, QualType elementType, CharUnits elementAlign, Destroyer *destroyer, bool checkZeroLength, bool useEHCleanup)
emitArrayDestroy - Destroys all the elements of the given array, beginning from last to first...
CharUnits getSizeAlign() const
static AggValueSlot forAddr(Address addr, Qualifiers quals, IsDestructed_t isDestructed, NeedsGCBarriers_t needsGC, IsAliased_t isAliased, IsZeroed_t isZeroed=IsNotZeroed)
forAddr - Make a slot for an aggregate value.
GlobalDecl - represents a global declaration.
The l-value was considered opaque, so the alignment was determined from a type.
There is no lifetime qualification on this type.
A C++ dynamic_cast expression (C++ [expr.dynamic.cast]).
void set(SanitizerMask K, bool Value)
Enable or disable a certain (single) sanitizer.
Address CreateBitCast(Address Addr, llvm::Type *Ty, const llvm::Twine &Name="")
CharUnits getTypeAlignInChars(QualType T) const
Return the ABI-specified alignment of a (complete) type T, in characters.
Assigning into this object requires the old value to be released and the new value to be retained...
bool mayInsertExtraPadding(bool EmitRemark=false) const
Whether we are allowed to insert extra padding between fields.
llvm::Value * EmitCXXTypeidExpr(const CXXTypeidExpr *E)
llvm::Constant * EmitConstantExpr(const Expr *E, QualType DestType, CodeGenFunction *CGF=nullptr)
Try to emit the given expression as a constant; returns 0 if the expression cannot be emitted as a co...
ASTContext & getContext() const
Encodes a location in the source.
CharUnits getPointerAlign() const
A helper class that allows the use of isa/cast/dyncast to detect TagType objects of enums...
void EmitARCRelease(llvm::Value *value, ARCPreciseLifetime_t precise)
Release the given object.
virtual llvm::Value * EmitTypeid(CodeGenFunction &CGF, QualType SrcRecordTy, Address ThisPtr, llvm::Type *StdTypeInfoPtrTy)=0
A saved depth on the scope stack.
static CXXRecordDecl * getCXXRecord(const Expr *E)
Represents a new-expression for memory allocation and constructor calls, e.g: "new CXXNewExpr(foo)"...
Represents a call to a member function that may be written either with member call syntax (e...
void DeactivateCleanupBlock(EHScopeStack::stable_iterator Cleanup, llvm::Instruction *DominatingIP)
DeactivateCleanupBlock - Deactivates the given cleanup block.
A scoped helper to set the current debug location to the specified location or preferred location of ...
static void EmitArrayDelete(CodeGenFunction &CGF, const CXXDeleteExpr *E, Address deletedPtr, QualType elementType)
Emit the code for deleting an array of objects.
Represents a static or instance method of a struct/union/class.
const CXXRecordDecl * getBestDynamicClassType() const
For an expression of class type or pointer to class type, return the most derived class decl the expr...
Represents a C++ nested name specifier, such as "\::std::vector<int>::".
llvm::Constant * EmitNullConstantForBase(const CXXRecordDecl *Record)
Return a null constant appropriate for zero-initializing a base class with the given type...
SanitizerSet SanOpts
Sanitizers enabled for this function.
const ConstantArrayType * getAsConstantArrayType(QualType T) const
llvm::Constant * GetAddrOfRTTIDescriptor(QualType Ty, bool ForEH=false)
Get the address of the RTTI descriptor for the given type.
bool hasInitializer() const
Whether this new-expression has any initializer at all.
CharUnits alignmentOfArrayElement(CharUnits elementSize) const
Given that this is the alignment of the first element of an array, return the minimum alignment of an...
const CodeGenOptions & getCodeGenOpts() const
virtual void emitVirtualObjectDelete(CodeGenFunction &CGF, const CXXDeleteExpr *DE, Address Ptr, QualType ElementType, const CXXDestructorDecl *Dtor)=0
const T * castAs() const
Member-template castAs<specific type>.
lookup_result lookup(DeclarationName Name) const
lookup - Find the declarations (if any) with the given Name in this context.
All available information about a concrete callee.
RValue EmitCXXMemberPointerCallExpr(const CXXMemberCallExpr *E, ReturnValueSlot ReturnValue)
Assigning into this object requires a lifetime extension.
bool isVolatileQualified() const
Determine whether this type is volatile-qualified.
RValue EmitBuiltinNewDeleteCall(const FunctionProtoType *Type, const Expr *Arg, bool IsDelete)
bool passAlignment() const
Indicates whether the required alignment should be implicitly passed to the allocation function...
bool isDynamicClass() const
CXXCtorType
C++ constructor types.
SourceLocation getExprLoc() const LLVM_READONLY
getExprLoc - Return the preferred location for the arrow when diagnosing a problem with a generic exp...
QualType getPointeeType() const
virtual Address InitializeArrayCookie(CodeGenFunction &CGF, Address NewPtr, llvm::Value *NumElements, const CXXNewExpr *expr, QualType ElementType)
Initialize the array cookie for the given allocation.
llvm::Value * EmitScalarExpr(const Expr *E, bool IgnoreResultAssign=false)
EmitScalarExpr - Emit the computation of the specified expression of LLVM scalar type, returning the result.
! Language semantics require right-to-left evaluation.
static CharUnits CalculateCookiePadding(CodeGenFunction &CGF, const CXXNewExpr *E)
CGFunctionInfo - Class to encapsulate the information about a function definition.
CharUnits getAlignment() const
Return the alignment of this pointer.
void EmitCXXDestructorCall(const CXXDestructorDecl *D, CXXDtorType Type, bool ForVirtualBase, bool Delegating, Address This)
QualType getTypeOperand(ASTContext &Context) const
Retrieves the type operand of this typeid() expression after various required adjustments (removing r...
Represents a delete expression for memory deallocation and destructor calls, e.g. ...
bool isZero() const
isZero - Test whether the quantity equals zero.
FunctionDecl * getDirectCallee()
If the callee is a FunctionDecl, return it. Otherwise return 0.
CXXDestructorDecl * getDestructor() const
Returns the destructor decl for this class.
const internal::VariadicAllOfMatcher< Type > type
Matches Types in the clang AST.
bool isTemporaryObject(ASTContext &Ctx, const CXXRecordDecl *TempTy) const
Determine whether the result of this expression is a temporary object of the given class type...
llvm::LoadInst * CreateLoad(Address Addr, const llvm::Twine &Name="")
QualType getPointerType(QualType T) const
Return the uniqued reference to the type for a pointer to the specified type.
DeclarationName - The name of a declaration.
param_type_iterator param_type_end() const
unsigned getNumPlacementArgs() const
detail::InMemoryDirectory::const_iterator E
A pointer to member type per C++ 8.3.3 - Pointers to members.
void EmitAggregateCopy(Address DestPtr, Address SrcPtr, QualType EltTy, bool isVolatile=false, bool isAssignment=false)
EmitAggregateCopy - Emit an aggregate copy.
llvm::StoreInst * CreateStore(llvm::Value *Val, Address Addr, bool IsVolatile=false)
unsigned getNumArgs() const
getNumArgs - Return the number of actual arguments to this call.
specific_decl_iterator - Iterates over a subrange of declarations stored in a DeclContext, providing only those that are of type SpecificDecl (or a class derived from it).
void EmitAggExpr(const Expr *E, AggValueSlot AS)
EmitAggExpr - Emit the computation of the specified expression of aggregate type. ...
void EmitExplicitCastExprType(const ExplicitCastExpr *E, CodeGenFunction *CGF=nullptr)
Emit type info if type of an expression is a variably modified type.
static llvm::Value * EmitDynamicCastToNull(CodeGenFunction &CGF, QualType DestTy)
llvm::PointerType * getType() const
Return the type of the pointer value.
A helper class that allows the use of isa/cast/dyncast to detect TagType objects of structs/unions/cl...
FunctionDecl * getOperatorNew() const
const T * getAs() const
Member-template getAs<specific type>'.
CXXMethodDecl * getDevirtualizedMethod(const Expr *Base, bool IsAppleKext)
If it's possible to devirtualize a call to this method, return the called function.
QualType getCanonicalType() const
Represents a call to a CUDA kernel function.
QualType getIntegerType() const
getIntegerType - Return the integer type this enum decl corresponds to.
llvm::PointerType * Int8PtrTy
const TargetInfo & Target
SourceLocation getLocStart() const LLVM_READONLY
bool has(SanitizerMask K) const
Check if a certain (single) sanitizer is enabled.
void EmitScalarInit(const Expr *init, const ValueDecl *D, LValue lvalue, bool capturedByInit)
Address getAddress() const
Expr * getArg(unsigned Arg)
Return the specified argument.
Base for LValueReferenceType and RValueReferenceType.
void EmitSynthesizedCXXCopyCtor(Address Dest, Address Src, const Expr *Exp)
CXXConstructorDecl * getConstructor() const
Get the constructor that this expression will (ultimately) call.
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.
bool isTrivial() const
Whether this function is "trivial" in some specialized C++ senses.
void EmitBlock(llvm::BasicBlock *BB, bool IsFinished=false)
EmitBlock - Emit the given block.
CharUnits getNonVirtualSize() const
getNonVirtualSize - Get the non-virtual size (in chars) of an object, which is the size of the object...
char __ovld __cnfn max(char x, char y)
Returns y if x < y, otherwise it returns x.
static bool isGLValueFromPointerDeref(const Expr *E)
llvm::ConstantInt * getSize(CharUnits numChars)
Emit the given number of characters as a value of type size_t.
const Type * getClass() const
Reading or writing from this object requires a barrier call.
MemberExpr - [C99 6.5.2.3] Structure and Union Members.
Represents a C++ struct/union/class.
virtual const CXXRecordDecl * getThisArgumentTypeForMethod(const CXXMethodDecl *MD)
Get the type of the implicit "this" parameter used by a method.
void EmitBranch(llvm::BasicBlock *Block)
EmitBranch - Emit a branch to the specified basic block from the current insert block, taking care to avoid creation of branches from dummy blocks.
CharUnits alignmentAtOffset(CharUnits offset) const
Given that this is a non-zero alignment value, what is the alignment at the given offset...
static void EmitNewInitializer(CodeGenFunction &CGF, const CXXNewExpr *E, QualType ElementType, llvm::Type *ElementTy, Address NewPtr, llvm::Value *NumElements, llvm::Value *AllocSizeWithoutCookie)
llvm::Type * ConvertType(QualType T)
bool hasQualifier() const
Determines whether this member expression actually had a C++ nested-name-specifier prior to the name ...
LValue MakeAddrLValue(Address Addr, QualType T, LValueBaseInfo BaseInfo=LValueBaseInfo(AlignmentSource::Type))
void EmitCXXDeleteExpr(const CXXDeleteExpr *E)
LValue EmitLValue(const Expr *E)
EmitLValue - Emit code to compute a designator that specifies the location of the expression...
bool isReservedGlobalPlacementOperator() const
Determines whether this operator new or delete is one of the reserved global placement operators: voi...
Address ReturnValue
ReturnValue - The temporary alloca to hold the return value.
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.
void EmitVTablePtrCheckForCall(const CXXRecordDecl *RD, llvm::Value *VTable, CFITypeCheckKind TCK, SourceLocation Loc)
EmitVTablePtrCheckForCall - Virtual method MD is being called via VTable.
CallExpr - Represents a function call (C99 6.5.2.2, C++ [expr.call]).
static bool IsWrappedCXXThis(const Expr *E)
Check if E is a C++ "this" pointer wrapped in value-preserving casts.
bool isStringLiteralInit() const
capture_init_iterator capture_init_end()
Retrieve the iterator pointing one past the last initialization argument for this lambda expression...
static RValue get(llvm::Value *V)
static RequiredArgs forPrototypePlus(const FunctionProtoType *prototype, unsigned additional, const FunctionDecl *FD)
Compute the arguments required by the given formal prototype, given that there may be some additional...
uint64_t getConstantArrayElementCount(const ConstantArrayType *CA) const
Return number of constant array elements.
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...
virtual std::vector< CharUnits > getVBPtrOffsets(const CXXRecordDecl *RD)
Gets the offsets of all the virtual base pointers in a given class.
LValue - This represents an lvalue references.
An abstract representation of regular/ObjC call/message targets.
Information for lazily generating a cleanup.
virtual CGCallee getVirtualFunctionPointer(CodeGenFunction &CGF, GlobalDecl GD, Address This, llvm::Type *Ty, SourceLocation Loc)=0
Build a virtual function pointer in the ABI-specific way.
QualType getDestroyedType() const
Retrieve the type being destroyed.
bool isTypeOperand() const
RValue EmitCXXOperatorMemberCallExpr(const CXXOperatorCallExpr *E, const CXXMethodDecl *MD, ReturnValueSlot ReturnValue)
TranslationUnitDecl * getTranslationUnitDecl()
CallArgList - Type for representing both the value and type of arguments in a call.
const CGFunctionInfo & arrangeCXXMethodCall(const CallArgList &args, const FunctionProtoType *type, RequiredArgs required, unsigned numPrefixArgs)
Arrange a call to a C++ method, passing the given arguments.
void PopCleanupBlock(bool FallThroughIsBranchThrough=false)
PopCleanupBlock - Will pop the cleanup entry on the stack and process all branch fixups.
Represents the canonical version of C arrays with a specified constant size.
QualType getBaseElementType(const ArrayType *VAT) const
Return the innermost element type of an array type.
bool isZeroInitializable(QualType T)
IsZeroInitializable - Return whether a type can be zero-initialized (in the C++ sense) with an LLVM z...
Represents an implicitly-generated value initialization of an object of a given type.
CXXRecordDecl * getLambdaClass() const
Retrieve the class that corresponds to the lambda.
void pushIrregularPartialArrayCleanup(llvm::Value *arrayBegin, Address arrayEndPointer, QualType elementType, CharUnits elementAlignment, Destroyer *destroyer)
pushIrregularPartialArrayCleanup - Push an EH cleanup to destroy already-constructed elements of the ...
void EmitNullInitialization(Address DestPtr, QualType Ty)
EmitNullInitialization - Generate code to set a value of the given type to null, If the type contains...
RValue EmitCall(const CGFunctionInfo &CallInfo, const CGCallee &Callee, ReturnValueSlot ReturnValue, const CallArgList &Args, llvm::Instruction **callOrInvoke=nullptr)
EmitCall - Generate a call of the given function, expecting the given result type, and using the given argument list which specifies both the LLVM arguments and the types they were derived from.
Expr * IgnoreParens() LLVM_READONLY
IgnoreParens - Ignore parentheses.
Qualifiers getQualifiers() const
Retrieve the set of qualifiers applied to this type.
bool isPointerType() const
OverloadedOperatorKind getOverloadedOperator() const
getOverloadedOperator - Which C++ overloaded operator this function represents, if any...
llvm::FunctionType * GetFunctionType(const CGFunctionInfo &Info)
GetFunctionType - Get the LLVM function type for.