32 #include "llvm/IR/CallSite.h" 33 #include "llvm/IR/DataLayout.h" 34 #include "llvm/IR/Instructions.h" 35 #include "llvm/IR/Intrinsics.h" 36 #include "llvm/IR/Value.h" 38 using namespace clang;
39 using namespace CodeGen;
44 llvm::DenseMap<const CXXRecordDecl *, llvm::GlobalVariable *> VTables;
47 bool UseARMMethodPtrABI;
48 bool UseARMGuardVarABI;
49 bool Use32BitVTableOffsetABI;
57 bool UseARMMethodPtrABI =
false,
58 bool UseARMGuardVarABI =
false) :
59 CGCXXABI(CGM), UseARMMethodPtrABI(UseARMMethodPtrABI),
60 UseARMGuardVarABI(UseARMGuardVarABI),
61 Use32BitVTableOffsetABI(
false) { }
68 if (CGM.getCodeGenOpts().getClangABICompat() <=
70 CGM.getTriple().getOS() == llvm::Triple::PS4)
73 return !canCopyArgument(RD);
78 if (passClassIndirect(RD))
83 bool isThisCompleteObject(
GlobalDecl GD)
const override {
86 if (isa<CXXDestructorDecl>(GD.
getDecl())) {
96 llvm_unreachable(
"emitting dtor comdat as function?");
98 llvm_unreachable(
"bad dtor kind");
100 if (isa<CXXConstructorDecl>(GD.
getDecl())) {
110 llvm_unreachable(
"closure ctors in Itanium ABI?");
113 llvm_unreachable(
"emitting ctor comdat as function?");
115 llvm_unreachable(
"bad dtor kind");
143 llvm::Constant *EmitMemberPointerConversion(
const CastExpr *E,
144 llvm::Constant *Src)
override;
148 llvm::Constant *EmitMemberFunctionPointer(
const CXXMethodDecl *MD)
override;
151 llvm::Constant *EmitMemberPointer(
const APValue &MP,
QualType MPT)
override;
158 bool Inequality)
override;
177 auto align = CGM.getContext().getTargetDefaultAlignForAttributeAligned();
178 return CGM.getContext().toCharUnitsFromBits(align);
190 void EmitFundamentalRTTIDescriptor(
QualType Type,
bool DLLExport);
191 void EmitFundamentalRTTIDescriptors(
bool DLLExport);
192 llvm::Constant *getAddrOfRTTIDescriptor(
QualType Ty)
override;
194 getAddrOfCXXCatchHandlerType(
QualType Ty,
195 QualType CatchHandlerType)
override {
199 bool shouldTypeidBeNullChecked(
bool IsDeref,
QualType SrcRecordTy)
override;
205 bool shouldDynamicCastCallBeNullChecked(
bool SrcIsPtr,
211 llvm::BasicBlock *CastEnd)
override;
252 bool Delegating,
Address This)
override;
260 bool doStructorsInitializeVPtrs(
const CXXRecordDecl *VTableClass)
override {
272 llvm::Value *getVTableAddressPointInStructorWithVTT(
280 llvm::GlobalVariable *getAddrOfVTable(
const CXXRecordDecl *RD,
293 void emitVirtualInheritanceTables(
const CXXRecordDecl *RD)
override;
295 bool canSpeculativelyEmitVTable(
const CXXRecordDecl *RD)
const override;
297 void setThunkLinkage(llvm::Function *Thunk,
bool ForVTable,
GlobalDecl GD,
301 if (ForVTable && !Thunk->hasLocalLinkage())
302 Thunk->setLinkage(llvm::GlobalValue::AvailableExternallyLinkage);
309 if (MD->
hasAttr<DLLExportAttr>())
310 Thunk->setDLLStorageClass(llvm::GlobalValue::DLLExportStorageClass);
317 const ReturnAdjustment &RA)
override;
321 assert(!Args.empty() &&
"expected the arglist to not be empty!");
322 return Args.size() - 1;
325 StringRef GetPureVirtualCallName()
override {
return "__cxa_pure_virtual"; }
326 StringRef GetDeletedVirtualCallName()
override 327 {
return "__cxa_deleted_virtual"; }
340 llvm::GlobalVariable *DeclPtr,
341 bool PerformInit)
override;
343 llvm::Constant *dtor, llvm::Constant *addr)
override;
345 llvm::Function *getOrCreateThreadLocalWrapper(
const VarDecl *VD,
347 void EmitThreadLocalInitFuncs(
353 bool usesThreadWrapperFunction()
const override {
return true; }
357 bool NeedsVTTParameter(
GlobalDecl GD)
override;
364 virtual bool shouldRTTIBeUnique()
const {
return true; }
368 enum RTTIUniquenessKind {
386 classifyRTTIUniqueness(
QualType CanTy,
387 llvm::GlobalValue::LinkageTypes
Linkage)
const;
388 friend class ItaniumRTTIBuilder;
392 std::pair<llvm::Value *, const CXXRecordDecl *>
397 bool hasAnyUnusedVirtualInlineFunction(
const CXXRecordDecl *RD)
const {
398 const auto &VtableLayout =
399 CGM.getItaniumVTableContext().getVTableLayout(RD);
401 for (
const auto &VtableComponent : VtableLayout.vtable_components()) {
403 if (!VtableComponent.isUsedFunctionPointerKind())
406 const CXXMethodDecl *Method = VtableComponent.getFunctionDecl();
410 StringRef Name = CGM.getMangledName(VtableComponent.getGlobalDecl());
411 auto *Entry = CGM.GetGlobalValue(Name);
417 if (!Entry || Entry->isDeclaration())
424 const auto &VtableLayout =
425 CGM.getItaniumVTableContext().getVTableLayout(RD);
427 for (
const auto &VtableComponent : VtableLayout.vtable_components()) {
428 if (VtableComponent.isRTTIKind()) {
429 const CXXRecordDecl *RTTIDecl = VtableComponent.getRTTIDecl();
432 }
else if (VtableComponent.isUsedFunctionPointerKind()) {
433 const CXXMethodDecl *Method = VtableComponent.getFunctionDecl();
443 class ARMCXXABI :
public ItaniumCXXABI {
446 ItaniumCXXABI(CGM,
true,
449 bool HasThisReturn(
GlobalDecl GD)
const override {
450 return (isa<CXXConstructorDecl>(GD.
getDecl()) || (
451 isa<CXXDestructorDecl>(GD.
getDecl()) &&
468 class iOS64CXXABI :
public ARMCXXABI {
471 Use32BitVTableOffsetABI =
true;
475 bool shouldRTTIBeUnique()
const override {
return false; }
478 class WebAssemblyCXXABI final :
public ItaniumCXXABI {
481 : ItaniumCXXABI(CGM,
true,
485 bool HasThisReturn(
GlobalDecl GD)
const override {
486 return isa<CXXConstructorDecl>(GD.
getDecl()) ||
487 (isa<CXXDestructorDecl>(GD.
getDecl()) &&
490 bool canCallMismatchedFunctionType()
const override {
return false; }
501 return new ARMCXXABI(CGM);
504 return new iOS64CXXABI(CGM);
510 return new ItaniumCXXABI(CGM,
true,
514 return new ItaniumCXXABI(CGM,
true);
517 return new WebAssemblyCXXABI(CGM);
521 == llvm::Triple::le32) {
525 return new ItaniumCXXABI(CGM,
true,
528 return new ItaniumCXXABI(CGM);
531 llvm_unreachable(
"Microsoft ABI is not Itanium-based");
533 llvm_unreachable(
"bad ABI kind");
539 return CGM.PtrDiffTy;
540 return llvm::StructType::get(CGM.PtrDiffTy, CGM.PtrDiffTy);
563 CGCallee ItaniumCXXABI::EmitLoadOfMemberFunctionPointer(
574 llvm::FunctionType *FTy = CGM.getTypes().GetFunctionType(
575 CGM.getTypes().arrangeCXXMethodType(RD, FPT,
nullptr));
577 llvm::Constant *ptrdiff_1 = llvm::ConstantInt::get(CGM.PtrDiffTy, 1);
584 llvm::Value *RawAdj = Builder.CreateExtractValue(MemFnPtr, 1,
"memptr.adj");
588 if (UseARMMethodPtrABI)
589 Adj = Builder.CreateAShr(Adj, ptrdiff_1,
"memptr.adj.shifted");
595 Ptr = Builder.CreateInBoundsGEP(Ptr, Adj);
596 This = Builder.
CreateBitCast(Ptr, This->getType(),
"this.adjusted");
597 ThisPtrForCall = This;
600 llvm::Value *FnAsInt = Builder.CreateExtractValue(MemFnPtr, 0,
"memptr.ptr");
605 if (UseARMMethodPtrABI)
606 IsVirtual = Builder.CreateAnd(RawAdj, ptrdiff_1);
608 IsVirtual = Builder.CreateAnd(FnAsInt, ptrdiff_1);
609 IsVirtual = Builder.CreateIsNotNull(IsVirtual,
"memptr.isvirtual");
610 Builder.CreateCondBr(IsVirtual, FnVirtual, FnNonVirtual);
618 llvm::Type *VTableTy = Builder.getInt8PtrTy();
629 if (!UseARMMethodPtrABI)
630 VTableOffset = Builder.CreateSub(VTableOffset, ptrdiff_1);
631 if (Use32BitVTableOffsetABI) {
632 VTableOffset = Builder.CreateTrunc(VTableOffset, CGF.
Int32Ty);
633 VTableOffset = Builder.CreateZExt(VTableOffset, CGM.PtrDiffTy);
635 VTable = Builder.CreateGEP(VTable, VTableOffset);
638 VTable = Builder.
CreateBitCast(VTable, FTy->getPointerTo()->getPointerTo());
648 Builder.CreateIntToPtr(FnAsInt, FTy->getPointerTo(),
"memptr.nonvirtualfn");
652 llvm::PHINode *CalleePtr = Builder.CreatePHI(FTy->getPointerTo(), 2);
653 CalleePtr->addIncoming(VirtualFn, FnVirtual);
654 CalleePtr->addIncoming(NonVirtualFn, FnNonVirtual);
662 llvm::Value *ItaniumCXXABI::EmitMemberDataPointerAddress(
665 assert(MemPtr->getType() == CGM.PtrDiffTy);
670 Base = Builder.CreateElementBitCast(Base, CGF.
Int8Ty);
674 Builder.CreateInBoundsGEP(Base.
getPointer(), MemPtr,
"memptr.offset");
680 return Builder.CreateBitCast(Addr, PType);
710 assert(E->
getCastKind() == CK_DerivedToBaseMemberPointer ||
711 E->
getCastKind() == CK_BaseToDerivedMemberPointer ||
715 if (E->
getCastKind() == CK_ReinterpretMemberPointer)
return src;
718 if (isa<llvm::Constant>(src))
719 return EmitMemberPointerConversion(E, cast<llvm::Constant>(src));
721 llvm::Constant *adj = getMemberPointerAdjustment(E);
722 if (!adj)
return src;
725 bool isDerivedToBase = (E->
getCastKind() == CK_DerivedToBaseMemberPointer);
735 dst = Builder.CreateNSWSub(src, adj,
"adj");
737 dst = Builder.CreateNSWAdd(src, adj,
"adj");
740 llvm::Value *null = llvm::Constant::getAllOnesValue(src->getType());
741 llvm::Value *isNull = Builder.CreateICmpEQ(src, null,
"memptr.isnull");
742 return Builder.CreateSelect(isNull, src, dst);
746 if (UseARMMethodPtrABI) {
747 uint64_t offset = cast<llvm::ConstantInt>(adj)->getZExtValue();
749 adj = llvm::ConstantInt::get(adj->getType(), offset);
752 llvm::Value *srcAdj = Builder.CreateExtractValue(src, 1,
"src.adj");
755 dstAdj = Builder.CreateNSWSub(srcAdj, adj,
"adj");
757 dstAdj = Builder.CreateNSWAdd(srcAdj, adj,
"adj");
759 return Builder.CreateInsertValue(src, dstAdj, 1);
763 ItaniumCXXABI::EmitMemberPointerConversion(
const CastExpr *E,
764 llvm::Constant *src) {
765 assert(E->
getCastKind() == CK_DerivedToBaseMemberPointer ||
766 E->
getCastKind() == CK_BaseToDerivedMemberPointer ||
770 if (E->
getCastKind() == CK_ReinterpretMemberPointer)
return src;
773 llvm::Constant *adj = getMemberPointerAdjustment(E);
774 if (!adj)
return src;
776 bool isDerivedToBase = (E->
getCastKind() == CK_DerivedToBaseMemberPointer);
785 if (src->isAllOnesValue())
return src;
788 return llvm::ConstantExpr::getNSWSub(src, adj);
790 return llvm::ConstantExpr::getNSWAdd(src, adj);
794 if (UseARMMethodPtrABI) {
795 uint64_t offset = cast<llvm::ConstantInt>(adj)->getZExtValue();
797 adj = llvm::ConstantInt::get(adj->getType(), offset);
800 llvm::Constant *srcAdj = llvm::ConstantExpr::getExtractValue(src, 1);
801 llvm::Constant *dstAdj;
803 dstAdj = llvm::ConstantExpr::getNSWSub(srcAdj, adj);
805 dstAdj = llvm::ConstantExpr::getNSWAdd(srcAdj, adj);
807 return llvm::ConstantExpr::getInsertValue(src, dstAdj, 1);
815 return llvm::ConstantInt::get(CGM.PtrDiffTy, -1ULL,
true);
817 llvm::Constant *Zero = llvm::ConstantInt::get(CGM.PtrDiffTy, 0);
818 llvm::Constant *Values[2] = { Zero, Zero };
819 return llvm::ConstantStruct::getAnon(Values);
828 return llvm::ConstantInt::get(CGM.PtrDiffTy, offset.
getQuantity());
832 ItaniumCXXABI::EmitMemberFunctionPointer(
const CXXMethodDecl *MD) {
836 llvm::Constant *ItaniumCXXABI::BuildMemberPointer(
const CXXMethodDecl *MD,
838 assert(MD->
isInstance() &&
"Member function must not be static!");
844 llvm::Constant *MemPtr[2];
845 if (MD->isVirtual()) {
846 uint64_t Index = CGM.getItaniumVTableContext().getMethodVTableIndex(MD);
851 uint64_t VTableOffset = (Index * PointerWidth.
getQuantity());
853 if (UseARMMethodPtrABI) {
860 MemPtr[0] = llvm::ConstantInt::get(CGM.PtrDiffTy, VTableOffset);
861 MemPtr[1] = llvm::ConstantInt::get(CGM.PtrDiffTy,
868 MemPtr[0] = llvm::ConstantInt::get(CGM.PtrDiffTy, VTableOffset + 1);
869 MemPtr[1] = llvm::ConstantInt::get(CGM.PtrDiffTy,
884 llvm::Constant *addr = CGM.GetAddrOfFunction(MD, Ty);
886 MemPtr[0] = llvm::ConstantExpr::getPtrToInt(addr, CGM.PtrDiffTy);
887 MemPtr[1] = llvm::ConstantInt::get(CGM.PtrDiffTy,
888 (UseARMMethodPtrABI ? 2 : 1) *
892 return llvm::ConstantStruct::getAnon(MemPtr);
895 llvm::Constant *ItaniumCXXABI::EmitMemberPointer(
const APValue &MP,
900 return EmitNullMemberPointer(MPT);
902 CharUnits ThisAdjustment = getMemberPointerPathAdjustment(MP);
905 return BuildMemberPointer(MD, ThisAdjustment);
908 getContext().toCharUnitsFromBits(getContext().
getFieldOffset(MPD));
909 return EmitMemberDataPointer(MPT, ThisAdjustment + FieldOffset);
924 llvm::ICmpInst::Predicate Eq;
925 llvm::Instruction::BinaryOps
And, Or;
927 Eq = llvm::ICmpInst::ICMP_NE;
928 And = llvm::Instruction::Or;
931 Eq = llvm::ICmpInst::ICMP_EQ;
933 Or = llvm::Instruction::Or;
939 return Builder.CreateICmp(Eq, L, R);
951 llvm::Value *LPtr = Builder.CreateExtractValue(L, 0,
"lhs.memptr.ptr");
952 llvm::Value *RPtr = Builder.CreateExtractValue(R, 0,
"rhs.memptr.ptr");
956 llvm::Value *PtrEq = Builder.CreateICmp(Eq, LPtr, RPtr,
"cmp.ptr");
961 llvm::Value *Zero = llvm::Constant::getNullValue(LPtr->getType());
962 llvm::Value *EqZero = Builder.CreateICmp(Eq, LPtr, Zero,
"cmp.ptr.null");
966 llvm::Value *LAdj = Builder.CreateExtractValue(L, 1,
"lhs.memptr.adj");
967 llvm::Value *RAdj = Builder.CreateExtractValue(R, 1,
"rhs.memptr.adj");
968 llvm::Value *AdjEq = Builder.CreateICmp(Eq, LAdj, RAdj,
"cmp.adj");
972 if (UseARMMethodPtrABI) {
973 llvm::Value *One = llvm::ConstantInt::get(LPtr->getType(), 1);
976 llvm::Value *OrAdj = Builder.CreateOr(LAdj, RAdj,
"or.adj");
977 llvm::Value *OrAdjAnd1 = Builder.CreateAnd(OrAdj, One);
978 llvm::Value *OrAdjAnd1EqZero = Builder.CreateICmp(Eq, OrAdjAnd1, Zero,
980 EqZero = Builder.CreateBinOp(And, EqZero, OrAdjAnd1EqZero);
984 llvm::Value *Result = Builder.CreateBinOp(Or, EqZero, AdjEq);
985 Result = Builder.CreateBinOp(And, PtrEq, Result,
986 Inequality ?
"memptr.ne" :
"memptr.eq");
998 assert(MemPtr->getType() == CGM.PtrDiffTy);
1000 llvm::Constant::getAllOnesValue(MemPtr->getType());
1001 return Builder.CreateICmpNE(MemPtr, NegativeOne,
"memptr.tobool");
1005 llvm::Value *Ptr = Builder.CreateExtractValue(MemPtr, 0,
"memptr.ptr");
1007 llvm::Constant *Zero = llvm::ConstantInt::get(Ptr->getType(), 0);
1008 llvm::Value *Result = Builder.CreateICmpNE(Ptr, Zero,
"memptr.tobool");
1012 if (UseARMMethodPtrABI) {
1013 llvm::Constant *One = llvm::ConstantInt::get(Ptr->getType(), 1);
1014 llvm::Value *Adj = Builder.CreateExtractValue(MemPtr, 1,
"memptr.adj");
1015 llvm::Value *VirtualBit = Builder.CreateAnd(Adj, One,
"memptr.virtualbit");
1016 llvm::Value *IsVirtual = Builder.CreateICmpNE(VirtualBit, Zero,
1017 "memptr.isvirtual");
1018 Result = Builder.CreateOr(Result, IsVirtual);
1030 if (passClassIndirect(RD)) {
1031 auto Align = CGM.getContext().getTypeAlignInChars(FI.
getReturnType());
1052 if (UseGlobalDelete) {
1064 VTable, -2,
"complete-offset.ptr");
1071 CompletePtr = CGF.
Builder.CreateInBoundsGEP(CompletePtr, Offset);
1082 EmitVirtualDestructorCall(CGF, Dtor, DtorType, Ptr,
nullptr);
1084 if (UseGlobalDelete)
1088 void ItaniumCXXABI::emitRethrow(
CodeGenFunction &CGF,
bool isNoReturn) {
1091 llvm::FunctionType *FTy =
1092 llvm::FunctionType::get(CGM.VoidTy,
false);
1094 llvm::Constant *Fn = CGM.CreateRuntimeFunction(FTy,
"__cxa_rethrow");
1105 llvm::FunctionType *FTy =
1116 llvm::FunctionType *FTy =
1117 llvm::FunctionType::get(CGM.
VoidTy, Args,
false);
1126 uint64_t TypeSize = getContext().getTypeSizeInChars(ThrowType).getQuantity();
1130 AllocExceptionFn, llvm::ConstantInt::get(SizeTy, TypeSize),
"exception");
1132 CharUnits ExnAlign = getAlignmentOfExnObject();
1136 llvm::Constant *
TypeInfo = CGM.GetAddrOfRTTIDescriptor(ThrowType,
1141 llvm::Constant *Dtor =
nullptr;
1143 CXXRecordDecl *Record = cast<CXXRecordDecl>(RecordTy->getDecl());
1147 Dtor = llvm::ConstantExpr::getBitCast(Dtor, CGM.Int8PtrTy);
1150 if (!Dtor) Dtor = llvm::Constant::getNullValue(CGM.Int8PtrTy);
1152 llvm::Value *args[] = { ExceptionPtr, TypeInfo, Dtor };
1166 llvm::Type *Args[4] = { Int8PtrTy, Int8PtrTy, Int8PtrTy, PtrDiffTy };
1168 llvm::FunctionType *FTy = llvm::FunctionType::get(Int8PtrTy, Args,
false);
1171 llvm::Attribute::AttrKind FuncAttrs[] = { llvm::Attribute::NoUnwind,
1172 llvm::Attribute::ReadOnly };
1173 llvm::AttributeList Attrs = llvm::AttributeList::get(
1174 CGF.
getLLVMContext(), llvm::AttributeList::FunctionIndex, FuncAttrs);
1181 llvm::FunctionType *FTy = llvm::FunctionType::get(CGF.
VoidTy,
false);
1198 unsigned NumPublicPaths = 0;
1211 if (PathElement.Base->isVirtual())
1214 if (NumPublicPaths > 1)
1220 PathElement.Base->getType()->getAsCXXRecordDecl());
1225 if (NumPublicPaths == 0)
1229 if (NumPublicPaths > 1)
1239 llvm::FunctionType *FTy = llvm::FunctionType::get(CGF.
VoidTy,
false);
1244 bool ItaniumCXXABI::shouldTypeidBeNullChecked(
bool IsDeref,
1252 CGF.
Builder.CreateUnreachable();
1262 CGF.
GetVTablePtr(ThisPtr, StdTypeInfoPtrTy->getPointerTo(), ClassDecl);
1265 Value = CGF.
Builder.CreateConstInBoundsGEP1_64(Value, -1ULL);
1269 bool ItaniumCXXABI::shouldDynamicCastCallBeNullChecked(
bool SrcIsPtr,
1304 llvm::BasicBlock *BadCastBlock =
1308 CGF.
Builder.CreateCondBr(IsNull, BadCastBlock, CastEnd);
1311 EmitBadCastCall(CGF);
1333 CGF.
Builder.CreateConstInBoundsGEP1_64(VTable, -2ULL);
1341 Value = CGF.
Builder.CreateInBoundsGEP(Value, OffsetToTop);
1349 CGF.
Builder.CreateUnreachable();
1360 CGM.getItaniumVTableContext().getVirtualBaseOffsetOffset(ClassDecl,
1365 "vbase.offset.ptr");
1367 CGM.PtrDiffTy->getPointerTo());
1378 assert(CGM.getTarget().getCXXABI().hasConstructorVariants());
1402 ArgTys.insert(ArgTys.begin() + 1,
1404 return AddedStructorArgs::prefix(1);
1406 return AddedStructorArgs{};
1429 assert(isa<CXXConstructorDecl>(MD) || isa<CXXDestructorDecl>(MD));
1432 if (NeedsVTTParameter(CGF.
CurGD)) {
1440 Params.insert(Params.begin() + 1, VTTDecl);
1441 getStructorImplicitParamDecl(CGF) = VTTDecl;
1445 void ItaniumCXXABI::EmitInstanceFunctionProlog(
CodeGenFunction &CGF) {
1452 setCXXABIThisValue(CGF, loadIncomingCXXThis(CGF));
1455 if (getStructorImplicitParamDecl(CGF)) {
1468 if (HasThisReturn(CGF.
CurGD))
1474 bool ForVirtualBase,
bool Delegating,
CallArgList &Args) {
1476 return AddedStructorArgs{};
1481 QualType VTTTy = getContext().getPointerType(getContext().VoidPtrTy);
1482 Args.insert(Args.begin() + 1,
1484 return AddedStructorArgs::prefix(1);
1490 bool Delegating,
Address This) {
1493 QualType VTTTy = getContext().getPointerType(getContext().VoidPtrTy);
1496 if (getContext().getLangOpts().AppleKext &&
1511 llvm::GlobalVariable *VTable = getAddrOfVTable(RD,
CharUnits());
1512 if (VTable->hasInitializer())
1517 llvm::GlobalVariable::LinkageTypes
Linkage = CGM.getVTableLinkage(RD);
1518 llvm::Constant *RTTI =
1519 CGM.GetAddrOfRTTIDescriptor(CGM.getContext().getTagDeclType(RD));
1525 Components.finishAndSetAsInitializer(VTable);
1528 VTable->setLinkage(Linkage);
1530 if (CGM.supportsCOMDAT() && VTable->isWeakForLinker())
1531 VTable->setComdat(CGM.getModule().getOrInsertComdat(VTable->getName()));
1539 unsigned PAlign = CGM.getTarget().getPointerAlign(0);
1540 VTable->setAlignment(getContext().toCharUnitsFromBits(PAlign).getQuantity());
1548 isa<NamespaceDecl>(DC) && cast<NamespaceDecl>(DC)->getIdentifier() &&
1549 cast<NamespaceDecl>(DC)->
getIdentifier()->isStr(
"__cxxabiv1") &&
1551 EmitFundamentalRTTIDescriptors(RD->
hasAttr<DLLExportAttr>());
1553 if (!VTable->isDeclarationForLinker())
1554 CGM.EmitVTableTypeMetadata(VTable, VTLayout);
1557 bool ItaniumCXXABI::isVirtualOffsetNeededForVTableField(
1561 return NeedsVTTParameter(CGF.
CurGD);
1564 llvm::Value *ItaniumCXXABI::getVTableAddressPointInStructor(
1569 NeedsVTTParameter(CGF.
CurGD)) {
1570 return getVTableAddressPointInStructorWithVTT(CGF, VTableClass, Base,
1573 return getVTableAddressPoint(Base, VTableClass);
1579 llvm::GlobalValue *VTable = getAddrOfVTable(VTableClass,
CharUnits());
1584 CGM.getItaniumVTableContext()
1585 .getVTableLayout(VTableClass)
1586 .getAddressPoint(Base);
1588 llvm::ConstantInt::get(CGM.Int32Ty, 0),
1589 llvm::ConstantInt::get(CGM.Int32Ty, AddressPoint.
VTableIndex),
1593 return llvm::ConstantExpr::getGetElementPtr(VTable->getValueType(), VTable,
1598 llvm::Value *ItaniumCXXABI::getVTableAddressPointInStructorWithVTT(
1602 NeedsVTTParameter(CGF.
CurGD) &&
"This class doesn't have VTT");
1605 uint64_t VirtualPointerIndex =
1606 CGM.getVTables().getSecondaryVirtualPointerIndex(VTableClass, Base);
1610 if (VirtualPointerIndex)
1611 VTT = CGF.
Builder.CreateConstInBoundsGEP1_64(VTT, VirtualPointerIndex);
1617 llvm::Constant *ItaniumCXXABI::getVTableAddressPointForConstExpr(
1619 return getVTableAddressPoint(Base, VTableClass);
1622 llvm::GlobalVariable *ItaniumCXXABI::getAddrOfVTable(
const CXXRecordDecl *RD,
1624 assert(VPtrOffset.
isZero() &&
"Itanium ABI only supports zero vptr offsets");
1626 llvm::GlobalVariable *&VTable = VTables[RD];
1631 CGM.addDeferredVTable(RD);
1634 llvm::raw_svector_ostream Out(Name);
1635 getMangleContext().mangleCXXVTable(RD, Out);
1638 CGM.getItaniumVTableContext().getVTableLayout(RD);
1639 llvm::Type *VTableType = CGM.getVTables().getVTableType(VTLayout);
1641 VTable = CGM.CreateOrReplaceCXXRuntimeVariable(
1643 VTable->setUnnamedAddr(llvm::GlobalValue::UnnamedAddr::Global);
1646 if (RD->
hasAttr<DLLImportAttr>())
1647 VTable->setDLLStorageClass(llvm::GlobalValue::DLLImportStorageClass);
1648 else if (RD->
hasAttr<DLLExportAttr>())
1649 VTable->setDLLStorageClass(llvm::GlobalValue::DLLExportStorageClass);
1660 Ty = Ty->getPointerTo()->getPointerTo();
1661 auto *MethodDecl = cast<CXXMethodDecl>(GD.
getDecl());
1664 uint64_t VTableIndex = CGM.getItaniumVTableContext().getMethodVTableIndex(GD);
1668 MethodDecl->getParent(), VTable,
1669 VTableIndex * CGM.getContext().getTargetInfo().getPointerWidth(0) / 8);
1674 CGF.
Builder.CreateConstInBoundsGEP1_64(VTable, VTableIndex,
"vfn");
1684 if (CGM.getCodeGenOpts().OptimizationLevel > 0 &&
1685 CGM.getCodeGenOpts().StrictVTablePointers)
1686 VFuncLoad->setMetadata(
1687 llvm::LLVMContext::MD_invariant_load,
1688 llvm::MDNode::get(CGM.getLLVMContext(),
1693 CGCallee Callee(MethodDecl, VFunc);
1697 llvm::Value *ItaniumCXXABI::EmitVirtualDestructorCall(
1703 const CGFunctionInfo *FInfo = &CGM.getTypes().arrangeCXXStructorDeclaration(
1707 getVirtualFunctionPointer(CGF,
GlobalDecl(Dtor, DtorType), This, Ty,
1716 void ItaniumCXXABI::emitVirtualInheritanceTables(
const CXXRecordDecl *RD) {
1722 bool ItaniumCXXABI::canSpeculativelyEmitVTable(
const CXXRecordDecl *RD)
const {
1725 if (CGM.getLangOpts().AppleKext)
1732 return !hasAnyUnusedVirtualInlineFunction(RD) && !isVTableHidden(RD);
1736 int64_t NonVirtualAdjustment,
1737 int64_t VirtualAdjustment,
1738 bool IsReturnAdjustment) {
1739 if (!NonVirtualAdjustment && !VirtualAdjustment)
1745 if (NonVirtualAdjustment && !IsReturnAdjustment) {
1752 if (VirtualAdjustment) {
1760 CGF.
Builder.CreateConstInBoundsGEP1_64(VTablePtr, VirtualAdjustment);
1776 if (NonVirtualAdjustment && IsReturnAdjustment) {
1777 ResultPtr = CGF.
Builder.CreateConstInBoundsGEP1_64(ResultPtr,
1778 NonVirtualAdjustment);
1787 const ThisAdjustment &TA) {
1795 const ReturnAdjustment &RA) {
1804 return ItaniumCXXABI::EmitReturnFromThunk(CGF, RV, ResultType);
1809 return ItaniumCXXABI::EmitReturnFromThunk(CGF, Undef, ResultType);
1818 CGM.getContext().getTypeAlignInChars(elementType));
1826 assert(requiresArrayCookie(expr));
1836 assert(CookieSize == getArrayCookieSizeImpl(ElementType));
1840 CharUnits CookieOffset = CookieSize - SizeSize;
1841 if (!CookieOffset.
isZero())
1850 if (CGM.getLangOpts().Sanitize.has(SanitizerKind::Address) && AS == 0 &&
1853 CGM.getSanitizerMetadata()->disableSanitizerForInstruction(SI);
1854 llvm::FunctionType *FTy =
1855 llvm::FunctionType::get(CGM.VoidTy, NumElementsPtr.
getType(),
false);
1857 CGM.CreateRuntimeFunction(FTy,
"__asan_poison_cxx_array_cookie");
1870 Address numElementsPtr = allocPtr;
1872 if (!numElementsOffset.
isZero())
1878 if (!CGM.getLangOpts().Sanitize.has(SanitizerKind::Address) || AS != 0)
1885 llvm::FunctionType *FTy =
1886 llvm::FunctionType::get(CGF.
SizeTy, CGF.
SizeTy->getPointerTo(0),
false);
1888 CGM.CreateRuntimeFunction(FTy,
"__asan_load_cxx_array_cookie");
1902 CGM.getContext().getTypeAlignInChars(elementType));
1910 assert(requiresArrayCookie(expr));
1918 getContext().getTypeSizeInChars(elementType).getQuantity());
1927 CharUnits cookieSize = ARMCXXABI::getArrayCookieSizeImpl(elementType);
1946 llvm::PointerType *GuardPtrTy) {
1948 llvm::FunctionType *FTy =
1952 FTy,
"__cxa_guard_acquire",
1954 llvm::AttributeList::FunctionIndex,
1955 llvm::Attribute::NoUnwind));
1959 llvm::PointerType *GuardPtrTy) {
1961 llvm::FunctionType *FTy =
1962 llvm::FunctionType::get(CGM.
VoidTy, GuardPtrTy,
false);
1964 FTy,
"__cxa_guard_release",
1966 llvm::AttributeList::FunctionIndex,
1967 llvm::Attribute::NoUnwind));
1971 llvm::PointerType *GuardPtrTy) {
1973 llvm::FunctionType *FTy =
1974 llvm::FunctionType::get(CGM.
VoidTy, GuardPtrTy,
false);
1976 FTy,
"__cxa_guard_abort",
1978 llvm::AttributeList::FunctionIndex,
1979 llvm::Attribute::NoUnwind));
1984 llvm::GlobalVariable *Guard;
1985 CallGuardAbort(llvm::GlobalVariable *Guard) : Guard(Guard) {}
1998 llvm::GlobalVariable *var,
1999 bool shouldPerformInit) {
2004 bool NonTemplateInline =
2011 bool threadsafe = getContext().getLangOpts().ThreadsafeStatics &&
2017 bool useInt8GuardVariable = !threadsafe && var->hasInternalLinkage();
2019 llvm::IntegerType *guardTy;
2021 if (useInt8GuardVariable) {
2027 if (UseARMGuardVarABI) {
2033 CGM.getDataLayout().getABITypeAlignment(guardTy));
2036 llvm::PointerType *guardPtrTy = guardTy->getPointerTo();
2040 llvm::GlobalVariable *guard = CGM.getStaticLocalDeclGuardAddress(&D);
2045 llvm::raw_svector_ostream out(guardName);
2046 getMangleContext().mangleStaticGuardVariable(&D, out);
2051 guard =
new llvm::GlobalVariable(CGM.getModule(), guardTy,
2052 false, var->getLinkage(),
2053 llvm::ConstantInt::get(guardTy, 0),
2055 guard->setVisibility(var->getVisibility());
2057 guard->setThreadLocalMode(var->getThreadLocalMode());
2058 guard->setAlignment(guardAlignment.
getQuantity());
2063 llvm::Comdat *C = var->getComdat();
2065 (CGM.getTarget().getTriple().isOSBinFormatELF() ||
2066 CGM.getTarget().getTriple().isOSBinFormatWasm())) {
2067 guard->setComdat(C);
2071 if (!NonTemplateInline)
2072 CGF.
CurFn->setComdat(C);
2073 }
else if (CGM.supportsCOMDAT() && guard->isWeakForLinker()) {
2074 guard->setComdat(CGM.getModule().getOrInsertComdat(guard->getName()));
2077 CGM.setStaticLocalDeclGuardAddress(&D, guard);
2100 llvm::LoadInst *LI =
2110 LI->setAtomic(llvm::AtomicOrdering::Acquire);
2133 (UseARMGuardVarABI && !useInt8GuardVariable)
2134 ? Builder.CreateAnd(LI, llvm::ConstantInt::get(CGM.Int8Ty, 1))
2136 llvm::Value *NeedsInit = Builder.CreateIsNull(V,
"guard.uninitialized");
2155 Builder.CreateCondBr(Builder.CreateIsNotNull(V,
"tobool"),
2156 InitBlock, EndBlock);
2175 Builder.
CreateStore(llvm::ConstantInt::get(guardTy, 1), guardAddr);
2183 llvm::Constant *dtor,
2184 llvm::Constant *addr,
2186 const char *Name =
"__cxa_atexit";
2189 Name = T.isOSDarwin() ?
"_tlv_atexit" :
"__cxa_thread_atexit";
2196 llvm::FunctionType::get(CGF.
VoidTy, CGF.
Int8PtrTy,
false)->getPointerTo();
2200 llvm::FunctionType *atexitTy =
2201 llvm::FunctionType::get(CGF.
IntTy, paramTys,
false);
2205 if (llvm::Function *fn = dyn_cast<llvm::Function>(atexit))
2206 fn->setDoesNotThrow();
2209 llvm::Constant *handle =
2211 auto *GV = cast<llvm::GlobalValue>(handle->stripPointerCasts());
2215 llvm::ConstantExpr::getBitCast(dtor, dtorTy),
2216 llvm::ConstantExpr::getBitCast(addr, CGF.
Int8PtrTy),
2225 llvm::Constant *dtor,
2226 llvm::Constant *addr) {
2228 if (CGM.getCodeGenOpts().CXAAtExit)
2232 CGM.ErrorUnsupported(&D,
"non-trivial TLS destruction");
2236 if (CGM.getLangOpts().AppleKext) {
2238 return CGM.AddCXXDtorEntry(dtor, addr);
2246 assert(!VD->
isStaticLocal() &&
"static local VarDecls don't need wrappers!");
2256 static llvm::GlobalValue::LinkageTypes
2258 llvm::GlobalValue::LinkageTypes VarLinkage =
2262 if (llvm::GlobalValue::isLocalLinkage(VarLinkage))
2267 if (!llvm::GlobalVariable::isLinkOnceLinkage(VarLinkage) &&
2268 !llvm::GlobalVariable::isWeakODRLinkage(VarLinkage))
2270 return llvm::GlobalValue::WeakODRLinkage;
2274 ItaniumCXXABI::getOrCreateThreadLocalWrapper(
const VarDecl *VD,
2279 llvm::raw_svector_ostream Out(WrapperName);
2280 getMangleContext().mangleItaniumThreadLocalWrapper(VD, Out);
2285 if (
llvm::Value *V = CGM.getModule().getNamedValue(WrapperName))
2286 return cast<llvm::Function>(V);
2292 const CGFunctionInfo &FI = CGM.getTypes().arrangeBuiltinFunctionDeclaration(
2295 llvm::FunctionType *FnTy = CGM.getTypes().GetFunctionType(FI);
2296 llvm::Function *Wrapper =
2298 WrapperName.str(), &CGM.getModule());
2300 CGM.SetLLVMFunctionAttributes(
nullptr, FI, Wrapper);
2303 CGM.SetLLVMFunctionAttributesForDefinition(
nullptr, Wrapper);
2307 !llvm::GlobalVariable::isLinkOnceLinkage(Wrapper->getLinkage()) &&
2308 !llvm::GlobalVariable::isWeakODRLinkage(Wrapper->getLinkage())))
2312 Wrapper->setCallingConv(llvm::CallingConv::CXX_FAST_TLS);
2313 Wrapper->addFnAttr(llvm::Attribute::NoUnwind);
2318 void ItaniumCXXABI::EmitThreadLocalInitFuncs(
2322 llvm::Function *InitFunc =
nullptr;
2327 llvm::SmallDenseMap<const VarDecl *, llvm::Function *> UnorderedInits;
2328 for (
unsigned I = 0; I != CXXThreadLocalInits.size(); ++I) {
2332 CXXThreadLocalInits[I];
2334 OrderedInits.push_back(CXXThreadLocalInits[I]);
2337 if (!OrderedInits.empty()) {
2339 llvm::FunctionType *FTy =
2340 llvm::FunctionType::get(CGM.
VoidTy,
false);
2345 llvm::GlobalVariable *Guard =
new llvm::GlobalVariable(
2348 llvm::ConstantInt::get(CGM.
Int8Ty, 0),
"__tls_guard");
2349 Guard->setThreadLocal(
true);
2358 InitFunc->setCallingConv(llvm::CallingConv::CXX_FAST_TLS);
2359 InitFunc->addFnAttr(llvm::Attribute::NoUnwind);
2364 for (
const VarDecl *VD : CXXThreadLocals) {
2365 llvm::GlobalVariable *Var =
2367 llvm::Function *Wrapper = getOrCreateThreadLocalWrapper(VD, Var);
2380 llvm::raw_svector_ostream Out(InitFnName);
2381 getMangleContext().mangleItaniumThreadLocalInit(VD, Out);
2387 llvm::GlobalValue *Init =
nullptr;
2388 bool InitIsInitFunc =
false;
2390 InitIsInitFunc =
true;
2391 llvm::Function *InitFuncToUse = InitFunc;
2402 llvm::FunctionType *FnTy = llvm::FunctionType::get(CGM.
VoidTy,
false);
2404 llvm::GlobalVariable::ExternalWeakLinkage,
2411 Init->setVisibility(Var->getVisibility());
2413 llvm::LLVMContext &Context = CGM.
getModule().getContext();
2416 if (InitIsInitFunc) {
2418 llvm::CallInst *CallVal = Builder.CreateCall(Init);
2420 CallVal->setCallingConv(llvm::CallingConv::CXX_FAST_TLS);
2424 llvm::Value *Have = Builder.CreateIsNotNull(Init);
2427 Builder.CreateCondBr(Have, InitBB, ExitBB);
2429 Builder.SetInsertPoint(InitBB);
2430 Builder.CreateCall(Init);
2431 Builder.CreateBr(ExitBB);
2433 Builder.SetInsertPoint(ExitBB);
2443 if (Val->getType() != Wrapper->getReturnType())
2445 Val, Wrapper->getReturnType(),
"");
2446 Builder.CreateRet(Val);
2454 llvm::Function *Wrapper = getOrCreateThreadLocalWrapper(VD, Val);
2456 llvm::CallInst *CallVal = CGF.
Builder.CreateCall(Wrapper);
2457 CallVal->setCallingConv(Wrapper->getCallingConv());
2471 bool ItaniumCXXABI::NeedsVTTParameter(
GlobalDecl GD) {
2490 class ItaniumRTTIBuilder {
2492 llvm::LLVMContext &VMContext;
2493 const ItaniumCXXABI &
CXXABI;
2499 llvm::GlobalVariable *
2500 GetAddrOfTypeName(
QualType Ty, llvm::GlobalVariable::LinkageTypes
Linkage);
2504 llvm::Constant *GetAddrOfExternalRTTIDescriptor(
QualType Ty);
2507 void BuildVTablePointer(
const Type *Ty);
2520 void BuildPointerTypeInfo(
QualType PointeeTy);
2531 ItaniumRTTIBuilder(
const ItaniumCXXABI &ABI)
2532 : CGM(ABI.CGM), VMContext(CGM.
getModule().getContext()), CXXABI(ABI) {}
2546 PTI_Incomplete = 0x8,
2550 PTI_ContainingClassIncomplete = 0x10,
2556 PTI_Noexcept = 0x40,
2562 VMI_NonDiamondRepeat = 0x1,
2565 VMI_DiamondShaped = 0x2
2581 llvm::Constant *BuildTypeInfo(
QualType Ty,
bool Force =
false,
2582 bool DLLExport =
false);
2586 llvm::GlobalVariable *ItaniumRTTIBuilder::GetAddrOfTypeName(
2589 llvm::raw_svector_ostream Out(Name);
2595 llvm::Constant *Init = llvm::ConstantDataArray::getString(VMContext,
2598 llvm::GlobalVariable *GV =
2601 GV->setInitializer(Init);
2607 ItaniumRTTIBuilder::GetAddrOfExternalRTTIDescriptor(
QualType Ty) {
2610 llvm::raw_svector_ostream Out(Name);
2614 llvm::GlobalVariable *GV = CGM.
getModule().getNamedGlobal(Name);
2625 if (
const RecordType *RecordTy = dyn_cast<RecordType>(Ty)) {
2626 const CXXRecordDecl *RD = cast<CXXRecordDecl>(RecordTy->getDecl());
2627 if (RD->
hasAttr<DLLImportAttr>())
2628 GV->setDLLStorageClass(llvm::GlobalVariable::DLLImportStorageClass);
2632 return llvm::ConstantExpr::getBitCast(GV, CGM.
Int8PtrTy);
2653 case BuiltinType::Void:
2654 case BuiltinType::NullPtr:
2655 case BuiltinType::Bool:
2656 case BuiltinType::WChar_S:
2657 case BuiltinType::WChar_U:
2658 case BuiltinType::Char_U:
2659 case BuiltinType::Char_S:
2660 case BuiltinType::UChar:
2661 case BuiltinType::SChar:
2662 case BuiltinType::Short:
2663 case BuiltinType::UShort:
2664 case BuiltinType::Int:
2665 case BuiltinType::UInt:
2666 case BuiltinType::Long:
2667 case BuiltinType::ULong:
2668 case BuiltinType::LongLong:
2669 case BuiltinType::ULongLong:
2670 case BuiltinType::Half:
2671 case BuiltinType::Float:
2672 case BuiltinType::Double:
2673 case BuiltinType::LongDouble:
2674 case BuiltinType::Float16:
2675 case BuiltinType::Float128:
2676 case BuiltinType::Char16:
2677 case BuiltinType::Char32:
2678 case BuiltinType::Int128:
2679 case BuiltinType::UInt128:
2682 #define IMAGE_TYPE(ImgType, Id, SingletonId, Access, Suffix) \ 2683 case BuiltinType::Id: 2684 #include "clang/Basic/OpenCLImageTypes.def" 2685 case BuiltinType::OCLSampler:
2686 case BuiltinType::OCLEvent:
2687 case BuiltinType::OCLClkEvent:
2688 case BuiltinType::OCLQueue:
2689 case BuiltinType::OCLReserveID:
2692 case BuiltinType::Dependent:
2693 #define BUILTIN_TYPE(Id, SingletonId) 2694 #define PLACEHOLDER_TYPE(Id, SingletonId) \ 2695 case BuiltinType::Id: 2696 #include "clang/AST/BuiltinTypes.def" 2697 llvm_unreachable(
"asking for RRTI for a placeholder type!");
2699 case BuiltinType::ObjCId:
2700 case BuiltinType::ObjCClass:
2701 case BuiltinType::ObjCSel:
2702 llvm_unreachable(
"FIXME: Objective-C types are unsupported!");
2705 llvm_unreachable(
"Invalid BuiltinType Kind!");
2728 if (
const BuiltinType *BuiltinTy = dyn_cast<BuiltinType>(Ty))
2733 if (
const PointerType *PointerTy = dyn_cast<PointerType>(Ty))
2751 if (
const RecordType *RecordTy = dyn_cast<RecordType>(Ty)) {
2752 const CXXRecordDecl *RD = cast<CXXRecordDecl>(RecordTy->getDecl());
2763 bool IsDLLImport = RD->
hasAttr<DLLImportAttr>();
2766 if (CGM.
getTriple().isWindowsGNUEnvironment() && IsDLLImport)
2770 return IsDLLImport && !CGM.
getTriple().isWindowsItaniumEnvironment()
2798 if (
const RecordType *RecordTy = dyn_cast<RecordType>(Ty)) {
2803 if (
const PointerType *PointerTy = dyn_cast<PointerType>(Ty))
2807 dyn_cast<MemberPointerType>(Ty)) {
2809 const RecordType *ClassType = cast<RecordType>(MemberPointerTy->getClass());
2848 void ItaniumRTTIBuilder::BuildVTablePointer(
const Type *Ty) {
2850 static const char *
const ClassTypeInfo =
2851 "_ZTVN10__cxxabiv117__class_type_infoE";
2853 static const char *
const SIClassTypeInfo =
2854 "_ZTVN10__cxxabiv120__si_class_type_infoE";
2856 static const char *
const VMIClassTypeInfo =
2857 "_ZTVN10__cxxabiv121__vmi_class_type_infoE";
2859 const char *VTableName =
nullptr;
2862 #define TYPE(Class, Base) 2863 #define ABSTRACT_TYPE(Class, Base) 2864 #define NON_CANONICAL_UNLESS_DEPENDENT_TYPE(Class, Base) case Type::Class: 2865 #define NON_CANONICAL_TYPE(Class, Base) case Type::Class: 2866 #define DEPENDENT_TYPE(Class, Base) case Type::Class: 2867 #include "clang/AST/TypeNodes.def" 2868 llvm_unreachable(
"Non-canonical and dependent types shouldn't get here");
2870 case Type::LValueReference:
2871 case Type::RValueReference:
2872 llvm_unreachable(
"References shouldn't get here");
2875 case Type::DeducedTemplateSpecialization:
2876 llvm_unreachable(
"Undeduced type shouldn't get here");
2879 llvm_unreachable(
"Pipe types shouldn't get here");
2884 case Type::ExtVector:
2888 case Type::BlockPointer:
2890 VTableName =
"_ZTVN10__cxxabiv123__fundamental_type_infoE";
2893 case Type::ConstantArray:
2894 case Type::IncompleteArray:
2895 case Type::VariableArray:
2897 VTableName =
"_ZTVN10__cxxabiv117__array_type_infoE";
2900 case Type::FunctionNoProto:
2901 case Type::FunctionProto:
2903 VTableName =
"_ZTVN10__cxxabiv120__function_type_infoE";
2908 VTableName =
"_ZTVN10__cxxabiv116__enum_type_infoE";
2911 case Type::Record: {
2913 cast<CXXRecordDecl>(cast<RecordType>(Ty)->getDecl());
2916 VTableName = ClassTypeInfo;
2918 VTableName = SIClassTypeInfo;
2920 VTableName = VMIClassTypeInfo;
2926 case Type::ObjCObject:
2928 Ty = cast<ObjCObjectType>(Ty)->getBaseType().getTypePtr();
2931 if (isa<BuiltinType>(Ty)) {
2932 VTableName = ClassTypeInfo;
2936 assert(isa<ObjCInterfaceType>(Ty));
2939 case Type::ObjCInterface:
2940 if (cast<ObjCInterfaceType>(Ty)->getDecl()->getSuperClass()) {
2941 VTableName = SIClassTypeInfo;
2943 VTableName = ClassTypeInfo;
2947 case Type::ObjCObjectPointer:
2950 VTableName =
"_ZTVN10__cxxabiv119__pointer_type_infoE";
2953 case Type::MemberPointer:
2955 VTableName =
"_ZTVN10__cxxabiv129__pointer_to_member_type_infoE";
2959 llvm::Constant *VTable =
2966 llvm::Constant *Two = llvm::ConstantInt::get(PtrDiffTy, 2);
2968 llvm::ConstantExpr::getInBoundsGetElementPtr(CGM.
Int8PtrTy, VTable, Two);
2969 VTable = llvm::ConstantExpr::getBitCast(VTable, CGM.
Int8PtrTy);
2971 Fields.push_back(VTable);
3003 return llvm::GlobalValue::LinkOnceODRLinkage;
3005 if (
const RecordType *Record = dyn_cast<RecordType>(Ty)) {
3006 const CXXRecordDecl *RD = cast<CXXRecordDecl>(Record->getDecl());
3008 return llvm::GlobalValue::WeakODRLinkage;
3009 if (CGM.
getTriple().isWindowsItaniumEnvironment())
3010 if (RD->
hasAttr<DLLImportAttr>() &&
3018 .isWindowsGNUEnvironment())
3022 return llvm::GlobalValue::LinkOnceODRLinkage;
3025 llvm_unreachable(
"Invalid linkage!");
3028 llvm::Constant *ItaniumRTTIBuilder::BuildTypeInfo(
QualType Ty,
bool Force,
3035 llvm::raw_svector_ostream Out(Name);
3038 llvm::GlobalVariable *OldGV = CGM.
getModule().getNamedGlobal(Name);
3039 if (OldGV && !OldGV->isDeclaration()) {
3040 assert(!OldGV->hasAvailableExternallyLinkage() &&
3041 "available_externally typeinfos not yet implemented");
3043 return llvm::ConstantExpr::getBitCast(OldGV, CGM.
Int8PtrTy);
3049 return GetAddrOfExternalRTTIDescriptor(Ty);
3052 llvm::GlobalVariable::LinkageTypes
Linkage;
3059 BuildVTablePointer(cast<Type>(Ty));
3062 llvm::GlobalVariable *TypeName = GetAddrOfTypeName(Ty, Linkage);
3063 llvm::Constant *TypeNameField;
3067 ItaniumCXXABI::RTTIUniquenessKind RTTIUniqueness =
3068 CXXABI.classifyRTTIUniqueness(Ty, Linkage);
3069 if (RTTIUniqueness != ItaniumCXXABI::RUK_Unique) {
3072 TypeNameField = llvm::ConstantExpr::getPtrToInt(TypeName, CGM.
Int64Ty);
3073 llvm::Constant *flag =
3074 llvm::ConstantInt::get(CGM.
Int64Ty, ((uint64_t)1) << 63);
3075 TypeNameField = llvm::ConstantExpr::getAdd(TypeNameField, flag);
3077 llvm::ConstantExpr::getIntToPtr(TypeNameField, CGM.
Int8PtrTy);
3079 TypeNameField = llvm::ConstantExpr::getBitCast(TypeName, CGM.
Int8PtrTy);
3081 Fields.push_back(TypeNameField);
3084 #define TYPE(Class, Base) 3085 #define ABSTRACT_TYPE(Class, Base) 3086 #define NON_CANONICAL_UNLESS_DEPENDENT_TYPE(Class, Base) case Type::Class: 3087 #define NON_CANONICAL_TYPE(Class, Base) case Type::Class: 3088 #define DEPENDENT_TYPE(Class, Base) case Type::Class: 3089 #include "clang/AST/TypeNodes.def" 3090 llvm_unreachable(
"Non-canonical and dependent types shouldn't get here");
3095 case Type::ExtVector:
3097 case Type::BlockPointer:
3102 case Type::LValueReference:
3103 case Type::RValueReference:
3104 llvm_unreachable(
"References shouldn't get here");
3107 case Type::DeducedTemplateSpecialization:
3108 llvm_unreachable(
"Undeduced type shouldn't get here");
3111 llvm_unreachable(
"Pipe type shouldn't get here");
3113 case Type::ConstantArray:
3114 case Type::IncompleteArray:
3115 case Type::VariableArray:
3120 case Type::FunctionNoProto:
3121 case Type::FunctionProto:
3131 case Type::Record: {
3133 cast<CXXRecordDecl>(cast<RecordType>(Ty)->getDecl());
3140 BuildSIClassTypeInfo(RD);
3142 BuildVMIClassTypeInfo(RD);
3147 case Type::ObjCObject:
3148 case Type::ObjCInterface:
3149 BuildObjCObjectTypeInfo(cast<ObjCObjectType>(Ty));
3152 case Type::ObjCObjectPointer:
3153 BuildPointerTypeInfo(cast<ObjCObjectPointerType>(Ty)->getPointeeType());
3157 BuildPointerTypeInfo(cast<PointerType>(Ty)->getPointeeType());
3160 case Type::MemberPointer:
3161 BuildPointerToMemberTypeInfo(cast<MemberPointerType>(Ty));
3169 llvm::Constant *Init = llvm::ConstantStruct::getAnon(Fields);
3172 llvm::GlobalVariable *GV =
3173 new llvm::GlobalVariable(M, Init->getType(),
3178 GV->takeName(OldGV);
3179 llvm::Constant *NewPtr =
3180 llvm::ConstantExpr::getBitCast(GV, OldGV->getType());
3181 OldGV->replaceAllUsesWith(NewPtr);
3182 OldGV->eraseFromParent();
3186 GV->setComdat(M.getOrInsertComdat(GV->getName()));
3205 llvm::GlobalValue::VisibilityTypes llvmVisibility;
3206 if (llvm::GlobalValue::isLocalLinkage(Linkage))
3209 else if (RTTIUniqueness == ItaniumCXXABI::RUK_NonUniqueHidden)
3214 TypeName->setVisibility(llvmVisibility);
3215 GV->setVisibility(llvmVisibility);
3217 if (CGM.
getTriple().isWindowsItaniumEnvironment()) {
3219 if (DLLExport || (RD && RD->
hasAttr<DLLExportAttr>())) {
3220 TypeName->setDLLStorageClass(llvm::GlobalValue::DLLExportStorageClass);
3221 GV->setDLLStorageClass(llvm::GlobalValue::DLLExportStorageClass);
3222 }
else if (RD && RD->
hasAttr<DLLImportAttr>() &&
3224 TypeName->setDLLStorageClass(llvm::GlobalValue::DLLImportStorageClass);
3225 GV->setDLLStorageClass(llvm::GlobalValue::DLLImportStorageClass);
3230 TypeName->setInitializer(
nullptr);
3231 GV->setInitializer(
nullptr);
3235 return llvm::ConstantExpr::getBitCast(GV, CGM.
Int8PtrTy);
3240 void ItaniumRTTIBuilder::BuildObjCObjectTypeInfo(
const ObjCObjectType *OT) {
3243 assert(isa<BuiltinType>(T) || isa<ObjCInterfaceType>(T));
3247 if (isa<BuiltinType>(T))
return;
3258 llvm::Constant *BaseTypeInfo =
3259 ItaniumRTTIBuilder(
CXXABI).BuildTypeInfo(SuperTy);
3260 Fields.push_back(BaseTypeInfo);
3265 void ItaniumRTTIBuilder::BuildSIClassTypeInfo(
const CXXRecordDecl *RD) {
3269 llvm::Constant *BaseTypeInfo =
3271 Fields.push_back(BaseTypeInfo);
3278 llvm::SmallPtrSet<const CXXRecordDecl *, 16> NonVirtualBases;
3279 llvm::SmallPtrSet<const CXXRecordDecl *, 16> VirtualBases;
3296 if (!Bases.VirtualBases.insert(BaseDecl).second) {
3299 Flags |= ItaniumRTTIBuilder::VMI_DiamondShaped;
3301 if (Bases.NonVirtualBases.count(BaseDecl))
3302 Flags |= ItaniumRTTIBuilder::VMI_NonDiamondRepeat;
3306 if (!Bases.NonVirtualBases.insert(BaseDecl).second) {
3309 Flags |= ItaniumRTTIBuilder::VMI_NonDiamondRepeat;
3311 if (Bases.VirtualBases.count(BaseDecl))
3312 Flags |= ItaniumRTTIBuilder::VMI_NonDiamondRepeat;
3317 for (
const auto &I : BaseDecl->
bases())
3328 for (
const auto &I : RD->
bases())
3337 void ItaniumRTTIBuilder::BuildVMIClassTypeInfo(
const CXXRecordDecl *RD) {
3346 Fields.push_back(llvm::ConstantInt::get(UnsignedIntLTy, Flags));
3351 Fields.push_back(llvm::ConstantInt::get(UnsignedIntLTy, RD->
getNumBases()));
3386 for (
const auto &Base : RD->
bases()) {
3388 Fields.push_back(ItaniumRTTIBuilder(
CXXABI).BuildTypeInfo(Base.getType()));
3391 cast<CXXRecordDecl>(Base.getType()->getAs<
RecordType>()->getDecl());
3393 int64_t OffsetFlags = 0;
3400 if (Base.isVirtual())
3408 OffsetFlags = uint64_t(Offset.
getQuantity()) << 8;
3412 if (Base.isVirtual())
3413 OffsetFlags |= BCTI_Virtual;
3414 if (Base.getAccessSpecifier() ==
AS_public)
3415 OffsetFlags |= BCTI_Public;
3417 Fields.push_back(llvm::ConstantInt::get(OffsetFlagsLTy, OffsetFlags));
3427 Flags |= ItaniumRTTIBuilder::PTI_Const;
3429 Flags |= ItaniumRTTIBuilder::PTI_Volatile;
3431 Flags |= ItaniumRTTIBuilder::PTI_Restrict;
3438 Flags |= ItaniumRTTIBuilder::PTI_Incomplete;
3441 if (Proto->isNothrow(Ctx)) {
3442 Flags |= ItaniumRTTIBuilder::PTI_Noexcept;
3444 Proto->getReturnType(), Proto->getParamTypes(),
3445 Proto->getExtProtoInfo().withExceptionSpec(
EST_None));
3454 void ItaniumRTTIBuilder::BuildPointerTypeInfo(
QualType PointeeTy) {
3462 Fields.push_back(llvm::ConstantInt::get(UnsignedIntLTy, Flags));
3467 llvm::Constant *PointeeTypeInfo =
3468 ItaniumRTTIBuilder(
CXXABI).BuildTypeInfo(PointeeTy);
3469 Fields.push_back(PointeeTypeInfo);
3485 Flags |= PTI_ContainingClassIncomplete;
3489 Fields.push_back(llvm::ConstantInt::get(UnsignedIntLTy, Flags));
3494 llvm::Constant *PointeeTypeInfo =
3495 ItaniumRTTIBuilder(
CXXABI).BuildTypeInfo(PointeeTy);
3496 Fields.push_back(PointeeTypeInfo);
3503 ItaniumRTTIBuilder(
CXXABI).BuildTypeInfo(
QualType(ClassType, 0)));
3506 llvm::Constant *ItaniumCXXABI::getAddrOfRTTIDescriptor(
QualType Ty) {
3507 return ItaniumRTTIBuilder(*this).BuildTypeInfo(Ty);
3510 void ItaniumCXXABI::EmitFundamentalRTTIDescriptor(
QualType Type,
3514 ItaniumRTTIBuilder(*this).BuildTypeInfo(Type,
true, DLLExport);
3515 ItaniumRTTIBuilder(*this).BuildTypeInfo(PointerType,
true,
3517 ItaniumRTTIBuilder(*this).BuildTypeInfo(PointerTypeConst,
true,
3521 void ItaniumCXXABI::EmitFundamentalRTTIDescriptors(
bool DLLExport) {
3524 getContext().VoidTy, getContext().NullPtrTy,
3525 getContext().BoolTy, getContext().WCharTy,
3526 getContext().CharTy, getContext().UnsignedCharTy,
3527 getContext().SignedCharTy, getContext().ShortTy,
3528 getContext().UnsignedShortTy, getContext().IntTy,
3529 getContext().UnsignedIntTy, getContext().LongTy,
3530 getContext().UnsignedLongTy, getContext().LongLongTy,
3531 getContext().UnsignedLongLongTy, getContext().Int128Ty,
3532 getContext().UnsignedInt128Ty, getContext().HalfTy,
3533 getContext().FloatTy, getContext().DoubleTy,
3534 getContext().LongDoubleTy, getContext().Float128Ty,
3535 getContext().Char16Ty, getContext().Char32Ty
3537 for (
const QualType &FundamentalType : FundamentalTypes)
3538 EmitFundamentalRTTIDescriptor(FundamentalType, DLLExport);
3543 ItaniumCXXABI::RTTIUniquenessKind ItaniumCXXABI::classifyRTTIUniqueness(
3544 QualType CanTy, llvm::GlobalValue::LinkageTypes Linkage)
const {
3545 if (shouldRTTIBeUnique())
3549 if (Linkage != llvm::GlobalValue::LinkOnceODRLinkage &&
3550 Linkage != llvm::GlobalValue::WeakODRLinkage)
3558 if (Linkage == llvm::GlobalValue::LinkOnceODRLinkage)
3559 return RUK_NonUniqueHidden;
3564 assert(Linkage == llvm::GlobalValue::WeakODRLinkage);
3565 return RUK_NonUniqueVisible;
3575 return StructorCodegen::Emit;
3580 return StructorCodegen::Emit;
3583 if (
const auto *DD = dyn_cast<CXXDestructorDecl>(MD)) {
3586 const auto *CD = cast<CXXConstructorDecl>(MD);
3591 if (llvm::GlobalValue::isDiscardableIfUnused(Linkage))
3592 return StructorCodegen::RAUW;
3595 if (!llvm::GlobalAlias::isValidLinkage(Linkage))
3596 return StructorCodegen::RAUW;
3598 if (llvm::GlobalValue::isWeakForLinker(Linkage)) {
3602 return StructorCodegen::COMDAT;
3603 return StructorCodegen::Emit;
3606 return StructorCodegen::Alias;
3616 if (Entry && !Entry->isDeclaration())
3619 auto *Aliasee = cast<llvm::GlobalValue>(CGM.
GetAddrOfGlobal(TargetDecl));
3626 assert(Entry->getType() == Aliasee->getType() &&
3627 "declaration exists with different type");
3628 Alias->takeName(Entry);
3629 Entry->replaceAllUsesWith(Alias);
3630 Entry->eraseFromParent();
3632 Alias->setName(MangledName);
3639 void ItaniumCXXABI::emitCXXStructor(
const CXXMethodDecl *MD,
3657 if (CGType == StructorCodegen::Alias || CGType == StructorCodegen::COMDAT) {
3662 if (CGType == StructorCodegen::RAUW) {
3692 if (CGType == StructorCodegen::COMDAT) {
3694 llvm::raw_svector_ostream Out(Buffer);
3696 getMangleContext().mangleCXXDtorComdat(DD, Out);
3698 getMangleContext().mangleCXXCtorComdat(CD, Out);
3699 llvm::Comdat *C = CGM.
getModule().getOrInsertComdat(Out.str());
3708 llvm::FunctionType *FTy = llvm::FunctionType::get(
3716 llvm::FunctionType *FTy =
3717 llvm::FunctionType::get(CGM.
VoidTy,
false);
3724 llvm::FunctionType *FTy = llvm::FunctionType::get(
3744 CallEndCatch(
bool MightThrow) : MightThrow(MightThrow) {}
3764 bool EndMightThrow) {
3765 llvm::CallInst *call =
3788 if (isa<ReferenceType>(CatchType)) {
3789 QualType CaughtType = cast<ReferenceType>(CatchType)->getPointeeType();
3798 if (
const PointerType *PT = dyn_cast<PointerType>(CaughtType)) {
3807 unsigned HeaderSize =
3809 AdjustedExn = CGF.
Builder.CreateConstGEP1_32(Exn, HeaderSize);
3828 cast<llvm::PointerType>(LLVMCatchTy)->getElementType();
3854 if (CatchType->hasPointerRepresentation()) {
3873 llvm_unreachable(
"bad ownership qualifier!");
3878 llvm::Type *PtrTy = LLVMCatchTy->getPointerTo(0);
3894 llvm_unreachable(
"evaluation kind filtered out!");
3896 llvm_unreachable(
"bad evaluation kind");
3899 assert(isa<RecordType>(CatchType) &&
"unexpected catch type!");
3900 auto catchRD = CatchType->getAsCXXRecordDecl();
3903 llvm::Type *PtrTy = LLVMCatchTy->getPointerTo(0);
3911 caughtExnAlignment);
3918 llvm::CallInst *rawAdjustedExn =
3923 caughtExnAlignment);
3995 llvm::FunctionType *fnTy =
3998 fnTy,
"__clang_call_terminate", llvm::AttributeList(),
true);
4000 llvm::Function *fn = dyn_cast<llvm::Function>(fnRef);
4001 if (fn && fn->empty()) {
4002 fn->setDoesNotThrow();
4003 fn->setDoesNotReturn();
4008 fn->addFnAttr(llvm::Attribute::NoInline);
4012 fn->setLinkage(llvm::Function::LinkOnceODRLinkage);
4015 fn->setComdat(CGM.
getModule().getOrInsertComdat(fn->getName()));
4018 llvm::BasicBlock *entry =
4026 llvm::CallInst *catchCall = builder.CreateCall(
getBeginCatchFn(CGM), exn);
4027 catchCall->setDoesNotThrow();
4031 llvm::CallInst *termCall = builder.CreateCall(CGM.
getTerminateFn());
4032 termCall->setDoesNotThrow();
4033 termCall->setDoesNotReturn();
4037 builder.CreateUnreachable();
4044 ItaniumCXXABI::emitTerminateForUnexpectedException(
CodeGenFunction &CGF,
4054 std::pair<llvm::Value *, const CXXRecordDecl *>
static uint64_t getFieldOffset(const ASTContext &C, const FieldDecl *FD)
void pushTerminate()
Push a terminate handler on the stack.
ReturnValueSlot - Contains the address where the return value of a function can be stored...
The generic AArch64 ABI is also a modified version of the Itanium ABI, but it has fewer divergences t...
void EmitCXXGuardedInitBranch(llvm::Value *NeedsInit, llvm::BasicBlock *InitBlock, llvm::BasicBlock *NoInitBlock, GuardKind Kind, const VarDecl *D)
Emit a branch to select whether or not to perform guarded initialization.
void EmitVTTDefinition(llvm::GlobalVariable *VTT, llvm::GlobalVariable::LinkageTypes Linkage, const CXXRecordDecl *RD)
EmitVTTDefinition - Emit the definition of the given vtable.
static const Decl * getCanonicalDecl(const Decl *D)
static llvm::GlobalVariable::LinkageTypes getTypeInfoLinkage(CodeGenModule &CGM, QualType Ty)
Return the linkage that the type info and type info name constants should have for the given type...
llvm::IntegerType * IntTy
int
static llvm::GlobalValue::LinkageTypes getThreadLocalWrapperLinkage(const VarDecl *VD, CodeGen::CodeGenModule &CGM)
Get the appropriate linkage for the wrapper function.
External linkage, which indicates that the entity can be referred to from other translation units...
static void InitCatchParam(CodeGenFunction &CGF, const VarDecl &CatchParam, Address ParamAddr, SourceLocation Loc)
A "special initializer" callback for initializing a catch parameter during catch initialization.
no exception specification
PointerType - C99 6.7.5.1 - Pointer Declarators.
QualType getPointeeType() const
A (possibly-)qualified type.
The iOS 64-bit ABI is follows ARM's published 64-bit ABI more closely, but we don't guarantee to foll...
static llvm::Constant * getAllocateExceptionFn(CodeGenModule &CGM)
CodeGenTypes & getTypes()
llvm::Type * ConvertTypeForMem(QualType T)
const CodeGenOptions & getCodeGenOpts() const
unsigned getNumBases() const
Retrieves the number of base classes of this class.
Internal linkage according to the Modules TS, but can be referred to from other translation units ind...
const Expr * getSubExpr() const
unsigned getLongWidth() const
getLongWidth/Align - Return the size of 'signed long' and 'unsigned long' for this target...
llvm::LLVMContext & getLLVMContext()
The COMDAT used for ctors.
CXXDtorType getDtorType() const
QualType getPointerDiffType() const
Return the unique type for "ptrdiff_t" (C99 7.17) defined in <stddef.h>.
The standard implementation of ConstantInitBuilder used in Clang.
void GenerateCXXGlobalInitFunc(llvm::Function *Fn, ArrayRef< llvm::Function *> CXXThreadLocals, Address Guard=Address::invalid())
GenerateCXXGlobalInitFunc - Generates code for initializing global variables.
CharUnits getClassPointerAlignment(const CXXRecordDecl *CD)
Returns the assumed alignment of an opaque pointer to the given class.
const ASTRecordLayout & getASTRecordLayout(const RecordDecl *D) const
Get or compute information about the layout of the specified record (struct/union/class) D...
QualType getPointeeType() const
If this is a pointer, ObjC object pointer, or block pointer, this returns the respective pointee...
const llvm::Triple & getTriple() const
Returns the target triple of the primary target.
CharUnits getBaseClassOffset(const CXXRecordDecl *Base) const
getBaseClassOffset - Get the offset, in chars, for the given base class.
No linkage, which means that the entity is unique and can only be referred to from within its scope...
unsigned getNumVBases() const
Retrieves the number of virtual base classes of this class.
C Language Family Type Representation.
bool hasNonTrivialCopyConstructor() const
Determine whether this class has a non-trivial copy constructor (C++ [class.copy]p6, C++11 [class.copy]p12)
bool isRecordType() const
static TemplateSpecializationKind getTemplateSpecializationKind(Decl *D)
Determine what kind of template specialization the given declaration is.
FunctionDecl * getOperatorNew() const
bool isVirtual() const
Determines whether the base class is a virtual base class (or not).
void setAliasAttributes(const Decl *D, llvm::GlobalValue *GV)
Set attributes which must be preserved by an alias.
GlobalDecl getCanonicalDecl() const
QualType getNonReferenceType() const
If Type is a reference type (e.g., const int&), returns the type that the reference refers to ("const...
The base class of the type hierarchy.
int64_t NonVirtual
The non-virtual adjustment from the derived object to its nearest virtual base.
bool isDerivedFrom(const CXXRecordDecl *Base) const
Determine whether this class is derived from the class Base.
bool isRestrictQualified() const
Determine whether this type is restrict-qualified.
bool isZero() const
isZero - Test whether the quantity equals zero.
QualType withConst() const
const TargetInfo & getTargetInfo() const
bool isFuncTypeConvertible(const FunctionType *FT)
isFuncTypeConvertible - Utility to check whether a function type can be converted to an LLVM type (i...
Linkage getLinkage() const
Determine the linkage of this type.
bool isDefined(const FunctionDecl *&Definition) const
Returns true if the function is defined at all, including a deleted definition.
llvm::Value * EmitARCRetainNonBlock(llvm::Value *value)
Retain the given object, with normal retain semantics.
Represents a path from a specific derived class (which is not represented as part of the path) to a p...
llvm::IntegerType * Int8Ty
i8, i16, i32, and i64
Represents a C++ constructor within a class.
bool TryEmitBaseDestructorAsAlias(const CXXDestructorDecl *D)
Try to emit a base destructor as an alias to its primary base-class destructor.
static llvm::GlobalValue::VisibilityTypes GetLLVMVisibility(Visibility V)
Default closure variant of a ctor.
bool isCompleteDefinition() const
isCompleteDefinition - Return true if this decl has its body fully specified.
Address GetAddrOfLocalVar(const VarDecl *VD)
GetAddrOfLocalVar - Return the address of a local variable.
TypeEvaluationKind
The kind of evaluation to perform on values of a particular type.
static const OpaqueValueExpr * findInCopyConstruct(const Expr *expr)
Given an expression which invokes a copy constructor — i.e.
VarDecl - An instance of this class is created to represent a variable declaration or definition...
Address getObjectAddress(CodeGenFunction &CGF) const
Returns the address of the object within this declaration.
Objects with "hidden" visibility are not seen by the dynamic linker.
unsigned AddressPointIndex
const internal::VariadicDynCastAllOfMatcher< Stmt, Expr > expr
Matches expressions.
const T * getAs() const
Member-template getAs<specific type>'.
SourceLocation getLocStart() const LLVM_READONLY
bool supportsCOMDAT() const
A this pointer adjustment.
llvm::Value * GetVTTParameter(GlobalDecl GD, bool ForVirtualBase, bool Delegating)
GetVTTParameter - Return the VTT parameter that should be passed to a base constructor/destructor wit...
Address CreateConstInBoundsByteGEP(Address Addr, CharUnits Offset, const llvm::Twine &Name="")
Given a pointer to i8, adjust it by a given constant offset.
llvm::Value * getPointer() const
Attempt to be ABI-compatible with code generated by Clang 4.0.x (SVN r291814).
A C++ throw-expression (C++ [except.throw]).
bool hasDefinition() const
Linkage
Describes the different kinds of linkage (C++ [basic.link], C99 6.2.2) that an entity may have...
RValue EmitCXXMemberOrOperatorCall(const CXXMethodDecl *Method, const CGCallee &Callee, ReturnValueSlot ReturnValue, llvm::Value *This, llvm::Value *ImplicitParam, QualType ImplicitParamTy, const CallExpr *E, CallArgList *RtlArgs)
unsigned getAddressSpace() const
Return the address space that this address resides in.
The collection of all-type qualifiers we support.
const ValueDecl * getMemberPointerDecl() const
Qualifiers getQualifiers() const
Retrieve all qualifiers.
IdentifierInfo * getIdentifier() const
getIdentifier - Get the identifier that names this declaration, if there is one.
bool isEmpty() const
Determine whether this is an empty class in the sense of (C++11 [meta.unary.prop]).
uint64_t getPointerWidth(unsigned AddrSpace) const
Return the width of pointers on this target, for the specified address space.
const TargetInfo & getTarget() const
TargetCXXABI getCXXABI() const
Get the C++ ABI currently in use.
static llvm::Constant * getClangCallTerminateFn(CodeGenModule &CGM)
Get or define the following function: void (i8* exn) nounwind noreturn This code is used only in C++...
bool isStr(const char(&Str)[StrLen]) const
Return true if this is the identifier for the specified string.
Represents a class type in Objective C.
CodeGenFunction - This class organizes the per-function state that is used while generating LLVM code...
llvm::Type * ConvertType(QualType T)
ConvertType - Convert type T into a llvm::Type.
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
const CXXRecordDecl * NearestVBase
llvm::IntegerType * Int64Ty
CGCallee BuildAppleKextVirtualDestructorCall(const CXXDestructorDecl *DD, CXXDtorType Type, const CXXRecordDecl *RD)
BuildVirtualCall - This routine makes indirect vtable call for call to virtual destructors.
The generic Mips ABI is a modified version of the Itanium ABI.
bool ShouldEmitVTableTypeCheckedLoad(const CXXRecordDecl *RD)
Returns whether we should perform a type checked load when loading a virtual function for virtual cal...
Parameter for C++ virtual table pointers.
llvm::IntegerType * SizeTy
An RAII object to set (and then clear) a mapping for an OpaqueValueExpr.
CharUnits getSizeAlign() const
StructorType getFromDtorType(CXXDtorType T)
CXXMethodDecl * getCanonicalDecl() override
Retrieves the "canonical" declaration of the given declaration.
ABIArgInfo classifyReturnType(CodeGenModule &CGM, CanQualType type)
Classify the rules for how to return a particular type.
bool isReferenceType() const
Denotes a cleanup that should run when a scope is exited using exceptional control flow (a throw stat...
static CharUnits Zero()
Zero - Construct a CharUnits quantity of zero.
llvm::Function * codegenCXXStructor(const CXXMethodDecl *MD, StructorType Type)
void EmitStoreOfScalar(llvm::Value *Value, Address Addr, bool Volatile, QualType Ty, AlignmentSource Source=AlignmentSource::Type, bool isInit=false, bool isNontemporal=false)
EmitStoreOfScalar - Store a scalar value to an address, taking care to appropriately convert from the...
ComplexPairTy EmitLoadOfComplex(LValue src, SourceLocation loc)
EmitLoadOfComplex - Load a complex number from the specified l-value.
Objects with "default" visibility are seen by the dynamic linker and act like normal objects...
CharUnits getDynamicOffsetAlignment(CharUnits ActualAlign, const CXXRecordDecl *Class, CharUnits ExpectedTargetAlign)
Given a class pointer with an actual known alignment, and the expected alignment of an object at a dy...
bool isReplaceableGlobalAllocationFunction(bool *IsAligned=nullptr) const
Determines whether this function is one of the replaceable global allocation functions: void *operato...
static unsigned extractPBaseFlags(ASTContext &Ctx, QualType &Type)
Compute the flags for a __pbase_type_info, and remove the corresponding pieces from Type...
FunctionDecl * getOperatorDelete() const
static unsigned ComputeVMIClassTypeInfoFlags(const CXXBaseSpecifier *Base, SeenBases &Bases)
ComputeVMIClassTypeInfoFlags - Compute the value of the flags member in abi::__vmi_class_type_info.
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 EmitTypeMetadataCodeForVCall(const CXXRecordDecl *RD, llvm::Value *VTable, SourceLocation Loc)
If whole-program virtual table optimization is enabled, emit an assumption that VTable is a member of...
AccessSpecifier getAccessSpecifier() const
Returns the access specifier for this base specifier.
The Microsoft ABI is the ABI used by Microsoft Visual Studio (and compatible compilers).
CharUnits getAlignment() const
Return the alignment of this pointer.
Visibility getVisibility() const
Determine the visibility of this type.
static CharUnits computeOffsetHint(ASTContext &Context, const CXXRecordDecl *Src, const CXXRecordDecl *Dst)
Compute the src2dst_offset hint as described in the Itanium C++ ABI [2.9.7].
TemplateSpecializationKind getTemplateSpecializationKind() const
If this variable is an instantiation of a variable template or a static data member of a class templa...
bool isVolatileQualified() const
Determine whether this type is volatile-qualified.
CXXCtorType getCtorType() const
void registerGlobalDtorWithAtExit(const VarDecl &D, llvm::Constant *fn, llvm::Constant *addr)
Call atexit() with a function that passes the given argument to the given function.
const Type * getClass() const
llvm::Constant * getTerminateFn()
Get the declaration of std::terminate for the platform.
CharUnits getDeclAlign(const Decl *D, bool ForAlignof=false) const
Return a conservative estimate of the alignment of the specified decl D.
static StructorCodegen getCodegenToUse(CodeGenModule &CGM, const CXXMethodDecl *MD)
const Type * getTypePtr() const
Retrieves a pointer to the underlying (unqualified) type.
llvm::BasicBlock * createBasicBlock(const Twine &name="", llvm::Function *parent=nullptr, llvm::BasicBlock *before=nullptr)
createBasicBlock - Create an LLVM basic block.
CastExpr - Base class for type casts, including both implicit casts (ImplicitCastExpr) and explicit c...
base_class_iterator bases_begin()
llvm::Constant * CreateRuntimeVariable(llvm::Type *Ty, StringRef Name)
Create a new runtime global variable with the specified type and name.
const CGFunctionInfo & arrangeCXXMethodDeclaration(const CXXMethodDecl *MD)
C++ methods have some special rules and also have implicit parameters.
bool hasTrivialDestructor() const
Determine whether this class has a trivial destructor (C++ [class.dtor]p3)
GlobalDecl CurGD
CurGD - The GlobalDecl for the current function being compiled.
CharUnits getPointerAlign() const
CXXDestructorDecl * getDestructor() const
Returns the destructor decl for this class.
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...
Represents an ObjC class declaration.
bool isAbstract() const
Determine whether this class has a pure virtual function.
CharUnits getVirtualBaseOffsetOffset(const CXXRecordDecl *RD, const CXXRecordDecl *VBase)
Return the offset in chars (relative to the vtable address point) where the offset of the virtual bas...
The iOS ABI is a partial implementation of the ARM ABI.
virtual void mangleCXXRTTI(QualType T, raw_ostream &)=0
This object can be modified without requiring retains or releases.
llvm::Constant * CreateRuntimeFunction(llvm::FunctionType *Ty, StringRef Name, llvm::AttributeList ExtraAttrs=llvm::AttributeList(), bool Local=false)
Create a new runtime function with the specified type and name.
llvm::Value * EmitLoadOfScalar(Address Addr, bool Volatile, QualType Ty, SourceLocation Loc, AlignmentSource Source=AlignmentSource::Type, bool isNontemporal=false)
EmitLoadOfScalar - Load a scalar value from an address, taking care to appropriately convert from the...
static ImplicitParamDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation IdLoc, IdentifierInfo *Id, QualType T, ImplicitParamKind ParamKind)
Create implicit parameter.
CanQualType getReturnType() const
QualType getBaseType() const
Gets the base type of this object type.
static bool TypeInfoIsInStandardLibrary(const BuiltinType *Ty)
TypeInfoIsInStandardLibrary - Given a builtin type, returns whether the type info for that type is de...
static bool ShouldUseExternalRTTIDescriptor(CodeGenModule &CGM, QualType Ty)
ShouldUseExternalRTTIDescriptor - Returns whether the type information for the given type exists some...
static CharUnits One()
One - Construct a CharUnits quantity of one.
AutoVarEmission EmitAutoVarAlloca(const VarDecl &var)
EmitAutoVarAlloca - Emit the alloca and debug information for a local variable.
CXXRecordDecl * getAsCXXRecordDecl() const
Retrieves the CXXRecordDecl that this type refers to, either because the type is a RecordType or beca...
ASTContext & getContext() const
Represents a prototype with parameter type info, e.g.
The generic ARM ABI is a modified version of the Itanium ABI proposed by ARM for use on ARM-based pla...
llvm::CallInst * EmitNounwindRuntimeCall(llvm::Value *callee, const Twine &name="")
bool isDynamicClass() const
const TargetCodeGenInfo & getTargetCodeGenInfo()
RValue - This trivial value class is used to represent the result of an expression that is evaluated...
union clang::ReturnAdjustment::VirtualAdjustment Virtual
Module linkage, which indicates that the entity can be referred to from other translation units withi...
QuantityType getQuantity() const
getQuantity - Get the raw integer representation of this quantity.
bool isVTableExternal(const CXXRecordDecl *RD)
At this point in the translation unit, does it appear that can we rely on the vtable being defined el...
ASTRecordLayout - This class contains layout information for one RecordDecl, which is a struct/union/...
llvm::CallingConv::ID getRuntimeCC() const
Exposes information about the current target.
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)
getEvaluationKind - Return the TypeEvaluationKind of QualType T.
void SetLLVMFunctionAttributes(const Decl *D, const CGFunctionInfo &Info, llvm::Function *F)
Set the LLVM function attributes (sext, zext, etc).
CXXDtorType
C++ destructor types.
ValueDecl - Represent the declaration of a variable (in which case it is an lvalue) a function (in wh...
Expr - This represents one expression.
static llvm::Constant * getBadTypeidFn(CodeGenFunction &CGF)
const FunctionProtoType * T
void pushCallObjectDeleteCleanup(const FunctionDecl *OperatorDelete, llvm::Value *CompletePtr, QualType ElementType)
const CGFunctionInfo & arrangeNullaryFunction()
A nullary function is a freestanding function of type 'void ()'.
llvm::Constant * GetAddrOfGlobalVar(const VarDecl *D, llvm::Type *Ty=nullptr, ForDefinition_t IsForDefinition=NotForDefinition)
Return the llvm::Constant for the address of the given global variable.
const T * castAs() const
Member-template castAs<specific type>.
static CGCallee forDirect(llvm::Constant *functionPtr, const CGCalleeInfo &abstractInfo=CGCalleeInfo())
Represents a C++ destructor within a class.
VarDecl * getExceptionDecl() const
llvm::PointerType * getType() const
Return the type of the pointer value.
ObjCLifetime getObjCLifetime() const
CharUnits getTypeAlignInChars(QualType T) const
Return the ABI-specified alignment of a (complete) type T, in characters.
DeclContext * getDeclContext()
static bool IsIncompleteClassType(const RecordType *RecordTy)
IsIncompleteClassType - Returns whether the given record type is incomplete.
ObjCInterfaceDecl * getSuperClass() const
TLSKind getTLSKind() const
static CharUnits fromQuantity(QuantityType Quantity)
fromQuantity - Construct a CharUnits quantity from a raw integer type.
llvm::Value * getExceptionFromSlot()
Returns the contents of the function's exception object and selector slots.
CharUnits getSizeSize() const
llvm::LLVMContext & getLLVMContext()
const CXXRecordDecl * getBase() const
getBase - Returns the base class declaration.
llvm::IntegerType * Int32Ty
static llvm::Constant * getGetExceptionPtrFn(CodeGenModule &CGM)
llvm::GlobalValue::LinkageTypes getLLVMLinkageVarDefinition(const VarDecl *VD, bool IsConstant)
Returns LLVM linkage for a declarator.
DefinitionKind hasDefinition(ASTContext &) const
Check whether this variable is defined in this translation unit.
bool hasNonTrivialDestructor() const
Determine whether this class has a non-trivial destructor (C++ [class.dtor]p3)
DeclContext * getParent()
getParent - Returns the containing DeclContext.
LValue MakeNaturalAlignAddrLValue(llvm::Value *V, QualType T)
llvm::GlobalVariable::LinkageTypes getFunctionLinkage(GlobalDecl GD)
QualType getObjCInterfaceType(const ObjCInterfaceDecl *Decl, ObjCInterfaceDecl *PrevDecl=nullptr) const
getObjCInterfaceType - Return the unique reference to the type for the specified ObjC interface decl...
QualType getFunctionType(QualType ResultTy, ArrayRef< QualType > Args, const FunctionProtoType::ExtProtoInfo &EPI) const
Return a normal function type with a typed argument list.
llvm::Value * EmitCastToVoidPtr(llvm::Value *value)
Emit a cast to void* in the appropriate address space.
virtual unsigned getSizeOfUnwindException() const
Determines the size of struct _Unwind_Exception on this platform, in 8-bit units. ...
struct clang::ThisAdjustment::VirtualAdjustment::@118 Itanium
Implements C++ ABI-specific semantic analysis functions.
const TargetInfo & getTarget() const
void EmitCXXGlobalVarDeclInit(const VarDecl &D, llvm::Constant *DeclPtr, bool PerformInit)
EmitCXXGlobalVarDeclInit - Create the initializer for a C++ variable with global storage.
const LangOptions & getLangOpts() const
ASTContext & getContext() 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.
bool isTemplateInstantiation(TemplateSpecializationKind Kind)
Determine whether this template specialization kind refers to an instantiation of an entity (as oppos...
The COMDAT used for dtors.
static StringRef getIdentifier(const Token &Tok)
VarDecl * getCanonicalDecl() override
Retrieves the "canonical" declaration of the given declaration.
GlobalDecl - represents a global declaration.
llvm::GlobalVariable * CreateOrReplaceCXXRuntimeVariable(StringRef Name, llvm::Type *Ty, llvm::GlobalValue::LinkageTypes Linkage)
Will return a global variable of the given type.
WatchOS is a modernisation of the iOS ABI, which roughly means it's the iOS64 ABI ported to 32-bits...
bool isConstQualified() const
Determine whether this type is const-qualified.
The l-value was considered opaque, so the alignment was determined from a type.
RecordDecl * getDecl() const
int64_t NonVirtual
The non-virtual adjustment from the derived object to its nearest virtual base.
static llvm::Value * performTypeAdjustment(CodeGenFunction &CGF, Address InitialPtr, int64_t NonVirtualAdjustment, int64_t VirtualAdjustment, bool IsReturnAdjustment)
There is no lifetime qualification on this type.
Address CreateBitCast(Address Addr, llvm::Type *Ty, const llvm::Twine &Name="")
Assigning into this object requires the old value to be released and the new value to be retained...
QualType getCanonicalType() const
virtual void mangleCXXRTTIName(QualType T, raw_ostream &)=0
Encodes a location in the source.
IdentifierInfo & get(StringRef Name)
Return the identifier token info for the specified named identifier.
bool isMemberDataPointer() const
Returns true if the member type (i.e.
CastKind getCastKind() const
Represents a new-expression for memory allocation and constructor calls, e.g: "new CXXNewExpr(foo)"...
llvm::CallSite EmitRuntimeCallOrInvoke(llvm::Value *callee, ArrayRef< llvm::Value *> args, const Twine &name="")
Emits a call or invoke instruction to the given runtime function.
Represents a call to a member function that may be written either with member call syntax (e...
const Decl * getDecl() const
llvm::GlobalVariable * GetAddrOfVTT(const CXXRecordDecl *RD)
GetAddrOfVTT - Get the address of the VTT for the given record decl.
Represents a static or instance method of a struct/union/class.
static llvm::Constant * getGuardAbortFn(CodeGenModule &CGM, llvm::PointerType *GuardPtrTy)
llvm::Constant * GetAddrOfRTTIDescriptor(QualType Ty, bool ForEH=false)
Get the address of the RTTI descriptor for the given type.
void createVTableInitializer(ConstantStructBuilder &builder, const VTableLayout &layout, llvm::Constant *rtti)
Add vtable components for the given vtable layout to the given global initializer.
The generic Itanium ABI is the standard ABI of most open-source and Unix-like platforms.
All available information about a concrete callee.
TypeClass getTypeClass() const
int64_t VCallOffsetOffset
The offset (in bytes), relative to the address point, of the virtual call offset. ...
MangleContext & getMangleContext()
Gets the mangle context.
ItaniumVTableContext & getItaniumVTableContext()
Assigning into this object requires a lifetime extension.
static llvm::Constant * getGuardReleaseFn(CodeGenModule &CGM, llvm::PointerType *GuardPtrTy)
The MS C++ ABI needs a pointer to RTTI data plus some flags to describe the type of a catch handler...
CXXCtorType
C++ constructor types.
The WebAssembly ABI is a modified version of the Itanium ABI.
void addReplacement(StringRef Name, llvm::Constant *C)
llvm::Constant * GetAddrOfGlobal(GlobalDecl GD, ForDefinition_t IsForDefinition=NotForDefinition)
FunctionArgList - Type for representing both the decl and type of parameters to a function...
Represents an element in a path from a derived class to a base class.
TLS with a dynamic initializer.
CGFunctionInfo - Class to encapsulate the information about a function definition.
This class organizes the cross-function state that is used while generating LLVM code.
llvm::GlobalValue * GetGlobalValue(StringRef Ref)
Dataflow Directional Tag Classes.
External linkage within a unique namespace.
DeclContext - This is used only as base class of specific decl types that can act as declaration cont...
Represents a delete expression for memory deallocation and destructor calls, e.g. ...
void EmitAnyExprToExn(const Expr *E, Address Addr)
void EmitNoreturnRuntimeCallOrInvoke(llvm::Value *callee, ArrayRef< llvm::Value *> args)
Emits a call or invoke to the given noreturn runtime function.
llvm::LoadInst * CreateAlignedLoad(llvm::Value *Addr, CharUnits Align, const llvm::Twine &Name="")
const Expr * getInit() const
std::unique_ptr< DiagnosticConsumer > create(StringRef OutputFile, DiagnosticOptions *Diags, bool MergeChildRecords=false)
Returns a DiagnosticConsumer that serializes diagnostics to a bitcode file.
llvm::LoadInst * CreateLoad(Address Addr, const llvm::Twine &Name="")
llvm::IntegerType * IntPtrTy
static llvm::Value * CallBeginCatch(CodeGenFunction &CGF, llvm::Value *Exn, bool EndMightThrow)
Emits a call to __cxa_begin_catch and enters a cleanup to call __cxa_end_catch.
const CXXRecordDecl * getParent() const
Returns the parent of this method declaration, which is the class in which this method is defined...
int64_t VBaseOffsetOffset
The offset (in bytes), relative to the address point of the virtual base class offset.
Address CreateConstInBoundsGEP(Address Addr, uint64_t Index, CharUnits EltSize, const llvm::Twine &Name="")
Given addr = T* ...
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)
llvm::Module & getModule() const
void maybeSetTrivialComdat(const Decl &D, llvm::GlobalObject &GO)
LValue MakeAddrLValue(Address Addr, QualType T, AlignmentSource Source=AlignmentSource::Type)
union clang::ThisAdjustment::VirtualAdjustment Virtual
void EmitAggExpr(const Expr *E, AggValueSlot AS)
EmitAggExpr - Emit the computation of the specified expression of aggregate type. ...
llvm::GlobalVariable::LinkageTypes getVTableLinkage(const CXXRecordDecl *RD)
Return the appropriate linkage for the vtable, VTT, and type information of the given class...
void EmitAutoVarCleanups(const AutoVarEmission &emission)
A helper class that allows the use of isa/cast/dyncast to detect TagType objects of structs/unions/cl...
StructBuilder beginStruct(llvm::StructType *structTy=nullptr)
void EmitStoreOfComplex(ComplexPairTy V, LValue dest, bool isInit)
EmitStoreOfComplex - Store a complex number into the specified l-value.
static bool isThreadWrapperReplaceable(const VarDecl *VD, CodeGen::CodeGenModule &CGM)
Implements C++ ABI-specific code generation functions.
llvm::Type * getElementType() const
Return the type of the values stored in this address.
struct clang::ReturnAdjustment::VirtualAdjustment::@116 Itanium
This class organizes the cross-module state that is used while lowering AST types to LLVM types...
llvm::PointerType * Int8PtrTy
bool isStaticLocal() const
isStaticLocal - Returns true if a variable with function scope is a static local variable.
SourceLocation getLocStart() const LLVM_READONLY
StringRef getMangledName(GlobalDecl GD)
Internal linkage, which indicates that the entity can be referred to from within the translation unit...
void EmitBlock(llvm::BasicBlock *BB, bool IsFinished=false)
EmitBlock - Emit the given block.
void EmitARCInitWeak(Address addr, llvm::Value *value)
i8* @objc_initWeak(i8** addr, i8* value) Returns value.
APValue - This class implements a discriminated union of [uninitialized] [APSInt] [APFloat]...
ABIArgInfo & getReturnInfo()
Represents a base class of a C++ class.
llvm::Value * LoadCXXVTT()
LoadCXXVTT - Load the VTT parameter to base constructors/destructors have virtual bases...
char __ovld __cnfn max(char x, char y)
Returns y if x < y, otherwise it returns x.
static CGCXXABI::RecordArgABI getRecordArgABI(const RecordType *RT, CGCXXABI &CXXABI)
bool isInlined() const
Determine whether this function should be inlined, because it is either marked "inline" or "constexpr...
const Decl * CurFuncDecl
CurFuncDecl - Holds the Decl for the current outermost non-closure context.
CanQualType getCanonicalType(QualType T) const
Return the canonical (structural) type corresponding to the specified potentially non-canonical type ...
CharUnits toCharUnitsFromBits(int64_t BitSize) const
Convert a size in bits to a size in characters.
Reading or writing from this object requires a barrier call.
const VTableLayout & getVTableLayout(const CXXRecordDecl *RD)
QualType getUnqualifiedType() const
Retrieve the unqualified variant of the given type, removing as little sugar as possible.
true
A convenience builder class for complex constant initializers, especially for anonymous global struct...
Represents a C++ struct/union/class.
CGCXXABI * CreateItaniumCXXABI(CodeGenModule &CGM)
Creates an Itanium-family ABI.
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.
bool isMemberFunctionPointer() const
Returns true if the member type (i.e.
static bool ContainsIncompleteClassType(QualType Ty)
ContainsIncompleteClassType - Returns whether the given type contains an incomplete class type...
llvm::Function * CreateGlobalInitOrDestructFunction(llvm::FunctionType *ty, const Twine &name, const CGFunctionInfo &FI, SourceLocation Loc=SourceLocation(), bool TLS=false)
CXXCatchStmt - This represents a C++ catch block.
llvm::Type * ConvertType(QualType T)
Qualifiers getQualifiers() const
Retrieve the set of qualifiers applied to this type.
Address ReturnValue
ReturnValue - The temporary alloca to hold the return value.
void popTerminate()
Pops a terminate handler off the stack.
No linkage according to the standard, but is visible from other translation units because of types de...
QualType getPointerType(QualType T) const
Return the uniqued reference to the type for a pointer to the specified type.
This class is used for builtin types like 'int'.
bool isGlobalDelete() const
static llvm::Constant * getItaniumDynamicCastFn(CodeGenFunction &CGF)
Copying closure variant of a ctor.
CGCXXABI & getCXXABI() const
static llvm::Constant * getEndCatchFn(CodeGenModule &CGM)
Struct with all informations about dynamic [sub]class needed to set vptr.
static void emitGlobalDtorWithCXAAtExit(CodeGenFunction &CGF, llvm::Constant *dtor, llvm::Constant *addr, bool TLS)
Register a global destructor using __cxa_atexit.
static RValue get(llvm::Value *V)
Visibility getVisibility() const
Determines the visibility of this entity.
static llvm::Constant * getGuardAcquireFn(CodeGenModule &CGM, llvm::PointerType *GuardPtrTy)
BasePaths - Represents the set of paths from a derived class to one of its (direct or indirect) bases...
bool isLocalVarDecl() const
isLocalVarDecl - Returns true for local variable declarations other than parameters.
CodeGenVTables & getVTables()
static void emitConstructorDestructorAlias(CodeGenModule &CGM, GlobalDecl AliasDecl, GlobalDecl TargetDecl)
LValue - This represents an lvalue references.
Information for lazily generating a cleanup.
bool isTranslationUnit() const
static llvm::Constant * getBadCastFn(CodeGenFunction &CGF)
bool isInline() const
Whether this variable is (C++1z) inline.
Notes how many arguments were added to the beginning (Prefix) and ending (Suffix) of an arg list...
static bool IsStandardLibraryRTTIDescriptor(QualType Ty)
IsStandardLibraryRTTIDescriptor - Returns whether the type information for the given type exists in t...
static bool CanUseSingleInheritance(const CXXRecordDecl *RD)
Address CreatePointerBitCastOrAddrSpaceCast(Address Addr, llvm::Type *Ty, const llvm::Twine &Name="")
static llvm::Constant * getBeginCatchFn(CodeGenModule &CGM)
CallArgList - Type for representing both the value and type of arguments in a call.
const LangOptions & getLangOpts() const
void PopCleanupBlock(bool FallThroughIsBranchThrough=false)
PopCleanupBlock - Will pop the cleanup entry on the stack and process all branch fixups.
static ABIArgInfo getIndirect(CharUnits Alignment, bool ByVal=true, bool Realign=false, llvm::Type *Padding=nullptr)
llvm::Value * EmitVTableTypeCheckedLoad(const CXXRecordDecl *RD, llvm::Value *VTable, uint64_t VTableByteOffset)
Emit a type checked load from the given vtable.
SourceLocation getLocation() const
QualType getPointeeType() const
CanQualType UnsignedIntTy
static OMPLinearClause * Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation LParenLoc, OpenMPLinearClauseKind Modifier, SourceLocation ModifierLoc, SourceLocation ColonLoc, SourceLocation EndLoc, ArrayRef< Expr *> VL, ArrayRef< Expr *> PL, ArrayRef< Expr *> IL, Expr *Step, Expr *CalcStep, Stmt *PreInit, Expr *PostUpdate)
Creates clause with a list of variables VL and a linear step Step.
static llvm::Constant * getThrowFn(CodeGenModule &CGM)
llvm::FunctionType * GetFunctionType(const CGFunctionInfo &Info)
GetFunctionType - Get the LLVM function type for.
QualType getType() const
Retrieves the type of the base class.
const llvm::Triple & getTriple() const