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;
169 unsigned Align = CGM.getContext().getTargetInfo().getExnObjectAlignment();
170 return CGM.getContext().toCharUnitsFromBits(Align);
182 void EmitFundamentalRTTIDescriptor(
QualType Type,
bool DLLExport);
183 void EmitFundamentalRTTIDescriptors(
bool DLLExport);
184 llvm::Constant *getAddrOfRTTIDescriptor(
QualType Ty)
override;
186 getAddrOfCXXCatchHandlerType(
QualType Ty,
187 QualType CatchHandlerType)
override {
191 bool shouldTypeidBeNullChecked(
bool IsDeref,
QualType SrcRecordTy)
override;
197 bool shouldDynamicCastCallBeNullChecked(
bool SrcIsPtr,
203 llvm::BasicBlock *CastEnd)
override;
244 bool Delegating,
Address This)
override;
252 bool doStructorsInitializeVPtrs(
const CXXRecordDecl *VTableClass)
override {
264 llvm::Value *getVTableAddressPointInStructorWithVTT(
272 llvm::GlobalVariable *getAddrOfVTable(
const CXXRecordDecl *RD,
285 void emitVirtualInheritanceTables(
const CXXRecordDecl *RD)
override;
287 bool canSpeculativelyEmitVTable(
const CXXRecordDecl *RD)
const override;
289 void setThunkLinkage(llvm::Function *Thunk,
bool ForVTable,
GlobalDecl GD,
293 if (ForVTable && !Thunk->hasLocalLinkage())
294 Thunk->setLinkage(llvm::GlobalValue::AvailableExternallyLinkage);
301 const ReturnAdjustment &RA)
override;
305 assert(!Args.empty() &&
"expected the arglist to not be empty!");
306 return Args.size() - 1;
309 StringRef GetPureVirtualCallName()
override {
return "__cxa_pure_virtual"; }
310 StringRef GetDeletedVirtualCallName()
override
311 {
return "__cxa_deleted_virtual"; }
324 llvm::GlobalVariable *DeclPtr,
325 bool PerformInit)
override;
327 llvm::Constant *dtor, llvm::Constant *addr)
override;
329 llvm::Function *getOrCreateThreadLocalWrapper(
const VarDecl *VD,
331 void EmitThreadLocalInitFuncs(
337 bool usesThreadWrapperFunction()
const override {
return true; }
341 bool NeedsVTTParameter(
GlobalDecl GD)
override;
348 virtual bool shouldRTTIBeUnique()
const {
return true; }
352 enum RTTIUniquenessKind {
370 classifyRTTIUniqueness(
QualType CanTy,
371 llvm::GlobalValue::LinkageTypes
Linkage)
const;
372 friend class ItaniumRTTIBuilder;
377 bool hasAnyUnusedVirtualInlineFunction(
const CXXRecordDecl *RD)
const {
378 const auto &VtableLayout =
379 CGM.getItaniumVTableContext().getVTableLayout(RD);
381 for (
const auto &VtableComponent : VtableLayout.vtable_components()) {
383 if (!VtableComponent.isUsedFunctionPointerKind())
386 const CXXMethodDecl *Method = VtableComponent.getFunctionDecl();
390 StringRef
Name = CGM.getMangledName(VtableComponent.getGlobalDecl());
391 auto *Entry = CGM.GetGlobalValue(Name);
397 if (!Entry || Entry->isDeclaration())
404 const auto &VtableLayout =
405 CGM.getItaniumVTableContext().getVTableLayout(RD);
407 for (
const auto &VtableComponent : VtableLayout.vtable_components()) {
408 if (VtableComponent.isRTTIKind()) {
409 const CXXRecordDecl *RTTIDecl = VtableComponent.getRTTIDecl();
412 }
else if (VtableComponent.isUsedFunctionPointerKind()) {
413 const CXXMethodDecl *Method = VtableComponent.getFunctionDecl();
423 class ARMCXXABI :
public ItaniumCXXABI {
426 ItaniumCXXABI(CGM,
true,
429 bool HasThisReturn(
GlobalDecl GD)
const override {
430 return (isa<CXXConstructorDecl>(GD.
getDecl()) || (
431 isa<CXXDestructorDecl>(GD.
getDecl()) &&
448 class iOS64CXXABI :
public ARMCXXABI {
451 Use32BitVTableOffsetABI =
true;
455 bool shouldRTTIBeUnique()
const override {
return false; }
458 class WebAssemblyCXXABI final :
public ItaniumCXXABI {
461 : ItaniumCXXABI(CGM,
true,
465 bool HasThisReturn(
GlobalDecl GD)
const override {
466 return isa<CXXConstructorDecl>(GD.
getDecl()) ||
467 (isa<CXXDestructorDecl>(GD.
getDecl()) &&
470 bool canCallMismatchedFunctionType()
const override {
return false; }
481 return new ARMCXXABI(CGM);
484 return new iOS64CXXABI(CGM);
490 return new ItaniumCXXABI(CGM,
true,
494 return new ItaniumCXXABI(CGM,
true);
497 return new WebAssemblyCXXABI(CGM);
501 == llvm::Triple::le32) {
505 return new ItaniumCXXABI(CGM,
true,
508 return new ItaniumCXXABI(CGM);
511 llvm_unreachable(
"Microsoft ABI is not Itanium-based");
513 llvm_unreachable(
"bad ABI kind");
519 return CGM.PtrDiffTy;
520 return llvm::StructType::get(CGM.PtrDiffTy, CGM.PtrDiffTy);
543 CGCallee ItaniumCXXABI::EmitLoadOfMemberFunctionPointer(
554 llvm::FunctionType *FTy = CGM.getTypes().GetFunctionType(
555 CGM.getTypes().arrangeCXXMethodType(RD, FPT,
nullptr));
557 llvm::Constant *ptrdiff_1 = llvm::ConstantInt::get(CGM.PtrDiffTy, 1);
564 llvm::Value *RawAdj = Builder.CreateExtractValue(MemFnPtr, 1,
"memptr.adj");
568 if (UseARMMethodPtrABI)
569 Adj = Builder.CreateAShr(Adj, ptrdiff_1,
"memptr.adj.shifted");
575 Ptr = Builder.CreateInBoundsGEP(Ptr, Adj);
576 This = Builder.
CreateBitCast(Ptr, This->getType(),
"this.adjusted");
577 ThisPtrForCall = This;
580 llvm::Value *FnAsInt = Builder.CreateExtractValue(MemFnPtr, 0,
"memptr.ptr");
585 if (UseARMMethodPtrABI)
586 IsVirtual = Builder.CreateAnd(RawAdj, ptrdiff_1);
588 IsVirtual = Builder.CreateAnd(FnAsInt, ptrdiff_1);
589 IsVirtual = Builder.CreateIsNotNull(IsVirtual,
"memptr.isvirtual");
590 Builder.CreateCondBr(IsVirtual, FnVirtual, FnNonVirtual);
598 llvm::Type *VTableTy = Builder.getInt8PtrTy();
609 if (!UseARMMethodPtrABI)
610 VTableOffset = Builder.CreateSub(VTableOffset, ptrdiff_1);
611 if (Use32BitVTableOffsetABI) {
612 VTableOffset = Builder.CreateTrunc(VTableOffset, CGF.
Int32Ty);
613 VTableOffset = Builder.CreateZExt(VTableOffset, CGM.PtrDiffTy);
615 VTable = Builder.CreateGEP(VTable, VTableOffset);
618 VTable = Builder.
CreateBitCast(VTable, FTy->getPointerTo()->getPointerTo());
628 Builder.CreateIntToPtr(FnAsInt, FTy->getPointerTo(),
"memptr.nonvirtualfn");
632 llvm::PHINode *CalleePtr = Builder.CreatePHI(FTy->getPointerTo(), 2);
633 CalleePtr->addIncoming(VirtualFn, FnVirtual);
634 CalleePtr->addIncoming(NonVirtualFn, FnNonVirtual);
642 llvm::Value *ItaniumCXXABI::EmitMemberDataPointerAddress(
645 assert(MemPtr->getType() == CGM.PtrDiffTy);
650 Base = Builder.CreateElementBitCast(Base, CGF.
Int8Ty);
654 Builder.CreateInBoundsGEP(Base.
getPointer(), MemPtr,
"memptr.offset");
660 return Builder.CreateBitCast(Addr, PType);
690 assert(E->
getCastKind() == CK_DerivedToBaseMemberPointer ||
691 E->
getCastKind() == CK_BaseToDerivedMemberPointer ||
695 if (E->
getCastKind() == CK_ReinterpretMemberPointer)
return src;
698 if (isa<llvm::Constant>(src))
699 return EmitMemberPointerConversion(E, cast<llvm::Constant>(src));
701 llvm::Constant *adj = getMemberPointerAdjustment(E);
702 if (!adj)
return src;
705 bool isDerivedToBase = (E->
getCastKind() == CK_DerivedToBaseMemberPointer);
715 dst = Builder.CreateNSWSub(src, adj,
"adj");
717 dst = Builder.CreateNSWAdd(src, adj,
"adj");
720 llvm::Value *null = llvm::Constant::getAllOnesValue(src->getType());
721 llvm::Value *isNull = Builder.CreateICmpEQ(src, null,
"memptr.isnull");
722 return Builder.CreateSelect(isNull, src, dst);
726 if (UseARMMethodPtrABI) {
727 uint64_t offset = cast<llvm::ConstantInt>(adj)->getZExtValue();
729 adj = llvm::ConstantInt::get(adj->getType(), offset);
732 llvm::Value *srcAdj = Builder.CreateExtractValue(src, 1,
"src.adj");
735 dstAdj = Builder.CreateNSWSub(srcAdj, adj,
"adj");
737 dstAdj = Builder.CreateNSWAdd(srcAdj, adj,
"adj");
739 return Builder.CreateInsertValue(src, dstAdj, 1);
743 ItaniumCXXABI::EmitMemberPointerConversion(
const CastExpr *E,
744 llvm::Constant *src) {
745 assert(E->
getCastKind() == CK_DerivedToBaseMemberPointer ||
746 E->
getCastKind() == CK_BaseToDerivedMemberPointer ||
750 if (E->
getCastKind() == CK_ReinterpretMemberPointer)
return src;
753 llvm::Constant *adj = getMemberPointerAdjustment(E);
754 if (!adj)
return src;
756 bool isDerivedToBase = (E->
getCastKind() == CK_DerivedToBaseMemberPointer);
765 if (src->isAllOnesValue())
return src;
768 return llvm::ConstantExpr::getNSWSub(src, adj);
770 return llvm::ConstantExpr::getNSWAdd(src, adj);
774 if (UseARMMethodPtrABI) {
775 uint64_t offset = cast<llvm::ConstantInt>(adj)->getZExtValue();
777 adj = llvm::ConstantInt::get(adj->getType(), offset);
780 llvm::Constant *srcAdj = llvm::ConstantExpr::getExtractValue(src, 1);
781 llvm::Constant *dstAdj;
783 dstAdj = llvm::ConstantExpr::getNSWSub(srcAdj, adj);
785 dstAdj = llvm::ConstantExpr::getNSWAdd(srcAdj, adj);
787 return llvm::ConstantExpr::getInsertValue(src, dstAdj, 1);
795 return llvm::ConstantInt::get(CGM.PtrDiffTy, -1ULL,
true);
797 llvm::Constant *Zero = llvm::ConstantInt::get(CGM.PtrDiffTy, 0);
798 llvm::Constant *Values[2] = { Zero, Zero };
799 return llvm::ConstantStruct::getAnon(Values);
808 return llvm::ConstantInt::get(CGM.PtrDiffTy, offset.
getQuantity());
812 ItaniumCXXABI::EmitMemberFunctionPointer(
const CXXMethodDecl *MD) {
816 llvm::Constant *ItaniumCXXABI::BuildMemberPointer(
const CXXMethodDecl *MD,
818 assert(MD->
isInstance() &&
"Member function must not be static!");
824 llvm::Constant *MemPtr[2];
825 if (MD->isVirtual()) {
826 uint64_t Index = CGM.getItaniumVTableContext().getMethodVTableIndex(MD);
831 uint64_t VTableOffset = (Index * PointerWidth.
getQuantity());
833 if (UseARMMethodPtrABI) {
840 MemPtr[0] = llvm::ConstantInt::get(CGM.PtrDiffTy, VTableOffset);
841 MemPtr[1] = llvm::ConstantInt::get(CGM.PtrDiffTy,
848 MemPtr[0] = llvm::ConstantInt::get(CGM.PtrDiffTy, VTableOffset + 1);
849 MemPtr[1] = llvm::ConstantInt::get(CGM.PtrDiffTy,
864 llvm::Constant *addr = CGM.GetAddrOfFunction(MD, Ty);
866 MemPtr[0] = llvm::ConstantExpr::getPtrToInt(addr, CGM.PtrDiffTy);
867 MemPtr[1] = llvm::ConstantInt::get(CGM.PtrDiffTy,
868 (UseARMMethodPtrABI ? 2 : 1) *
872 return llvm::ConstantStruct::getAnon(MemPtr);
875 llvm::Constant *ItaniumCXXABI::EmitMemberPointer(
const APValue &MP,
880 return EmitNullMemberPointer(MPT);
882 CharUnits ThisAdjustment = getMemberPointerPathAdjustment(MP);
885 return BuildMemberPointer(MD, ThisAdjustment);
888 getContext().toCharUnitsFromBits(getContext().
getFieldOffset(MPD));
889 return EmitMemberDataPointer(MPT, ThisAdjustment + FieldOffset);
904 llvm::ICmpInst::Predicate Eq;
905 llvm::Instruction::BinaryOps
And, Or;
907 Eq = llvm::ICmpInst::ICMP_NE;
908 And = llvm::Instruction::Or;
911 Eq = llvm::ICmpInst::ICMP_EQ;
913 Or = llvm::Instruction::Or;
919 return Builder.CreateICmp(Eq, L, R);
931 llvm::Value *LPtr = Builder.CreateExtractValue(L, 0,
"lhs.memptr.ptr");
932 llvm::Value *RPtr = Builder.CreateExtractValue(R, 0,
"rhs.memptr.ptr");
936 llvm::Value *PtrEq = Builder.CreateICmp(Eq, LPtr, RPtr,
"cmp.ptr");
941 llvm::Value *Zero = llvm::Constant::getNullValue(LPtr->getType());
942 llvm::Value *EqZero = Builder.CreateICmp(Eq, LPtr, Zero,
"cmp.ptr.null");
946 llvm::Value *LAdj = Builder.CreateExtractValue(L, 1,
"lhs.memptr.adj");
947 llvm::Value *RAdj = Builder.CreateExtractValue(R, 1,
"rhs.memptr.adj");
948 llvm::Value *AdjEq = Builder.CreateICmp(Eq, LAdj, RAdj,
"cmp.adj");
952 if (UseARMMethodPtrABI) {
953 llvm::Value *One = llvm::ConstantInt::get(LPtr->getType(), 1);
956 llvm::Value *OrAdj = Builder.CreateOr(LAdj, RAdj,
"or.adj");
957 llvm::Value *OrAdjAnd1 = Builder.CreateAnd(OrAdj, One);
958 llvm::Value *OrAdjAnd1EqZero = Builder.CreateICmp(Eq, OrAdjAnd1, Zero,
960 EqZero = Builder.CreateBinOp(And, EqZero, OrAdjAnd1EqZero);
965 Result = Builder.CreateBinOp(And, PtrEq, Result,
966 Inequality ?
"memptr.ne" :
"memptr.eq");
978 assert(MemPtr->getType() == CGM.PtrDiffTy);
980 llvm::Constant::getAllOnesValue(MemPtr->getType());
981 return Builder.CreateICmpNE(MemPtr, NegativeOne,
"memptr.tobool");
985 llvm::Value *Ptr = Builder.CreateExtractValue(MemPtr, 0,
"memptr.ptr");
987 llvm::Constant *Zero = llvm::ConstantInt::get(Ptr->getType(), 0);
988 llvm::Value *Result = Builder.CreateICmpNE(Ptr, Zero,
"memptr.tobool");
992 if (UseARMMethodPtrABI) {
993 llvm::Constant *One = llvm::ConstantInt::get(Ptr->getType(), 1);
994 llvm::Value *Adj = Builder.CreateExtractValue(MemPtr, 1,
"memptr.adj");
995 llvm::Value *VirtualBit = Builder.CreateAnd(Adj, One,
"memptr.virtualbit");
996 llvm::Value *IsVirtual = Builder.CreateICmpNE(VirtualBit, Zero,
998 Result = Builder.CreateOr(Result, IsVirtual);
1010 if (passClassIndirect(RD)) {
1011 auto Align = CGM.getContext().getTypeAlignInChars(FI.
getReturnType());
1032 if (UseGlobalDelete) {
1044 VTable, -2,
"complete-offset.ptr");
1051 CompletePtr = CGF.
Builder.CreateInBoundsGEP(CompletePtr, Offset);
1062 EmitVirtualDestructorCall(CGF, Dtor, DtorType, Ptr,
nullptr);
1064 if (UseGlobalDelete)
1068 void ItaniumCXXABI::emitRethrow(
CodeGenFunction &CGF,
bool isNoReturn) {
1071 llvm::FunctionType *FTy =
1072 llvm::FunctionType::get(CGM.VoidTy,
false);
1074 llvm::Constant *Fn = CGM.CreateRuntimeFunction(FTy,
"__cxa_rethrow");
1085 llvm::FunctionType *FTy =
1096 llvm::FunctionType *FTy =
1097 llvm::FunctionType::get(CGM.
VoidTy, Args,
false);
1106 uint64_t TypeSize = getContext().getTypeSizeInChars(ThrowType).getQuantity();
1110 AllocExceptionFn, llvm::ConstantInt::get(SizeTy, TypeSize),
"exception");
1112 CharUnits ExnAlign = getAlignmentOfExnObject();
1116 llvm::Constant *
TypeInfo = CGM.GetAddrOfRTTIDescriptor(ThrowType,
1121 llvm::Constant *Dtor =
nullptr;
1123 CXXRecordDecl *Record = cast<CXXRecordDecl>(RecordTy->getDecl());
1127 Dtor = llvm::ConstantExpr::getBitCast(Dtor, CGM.Int8PtrTy);
1130 if (!Dtor) Dtor = llvm::Constant::getNullValue(CGM.Int8PtrTy);
1132 llvm::Value *args[] = { ExceptionPtr, TypeInfo, Dtor };
1146 llvm::Type *Args[4] = { Int8PtrTy, Int8PtrTy, Int8PtrTy, PtrDiffTy };
1148 llvm::FunctionType *FTy = llvm::FunctionType::get(Int8PtrTy, Args,
false);
1151 llvm::Attribute::AttrKind FuncAttrs[] = { llvm::Attribute::NoUnwind,
1152 llvm::Attribute::ReadOnly };
1153 llvm::AttributeList Attrs = llvm::AttributeList::get(
1154 CGF.
getLLVMContext(), llvm::AttributeList::FunctionIndex, FuncAttrs);
1161 llvm::FunctionType *FTy = llvm::FunctionType::get(CGF.
VoidTy,
false);
1178 unsigned NumPublicPaths = 0;
1191 if (PathElement.Base->isVirtual())
1194 if (NumPublicPaths > 1)
1200 PathElement.Base->getType()->getAsCXXRecordDecl());
1205 if (NumPublicPaths == 0)
1209 if (NumPublicPaths > 1)
1219 llvm::FunctionType *FTy = llvm::FunctionType::get(CGF.
VoidTy,
false);
1224 bool ItaniumCXXABI::shouldTypeidBeNullChecked(
bool IsDeref,
1232 CGF.
Builder.CreateUnreachable();
1242 CGF.
GetVTablePtr(ThisPtr, StdTypeInfoPtrTy->getPointerTo(), ClassDecl);
1245 Value = CGF.
Builder.CreateConstInBoundsGEP1_64(Value, -1ULL);
1249 bool ItaniumCXXABI::shouldDynamicCastCallBeNullChecked(
bool SrcIsPtr,
1284 llvm::BasicBlock *BadCastBlock =
1288 CGF.
Builder.CreateCondBr(IsNull, BadCastBlock, CastEnd);
1291 EmitBadCastCall(CGF);
1313 CGF.
Builder.CreateConstInBoundsGEP1_64(VTable, -2ULL);
1321 Value = CGF.
Builder.CreateInBoundsGEP(Value, OffsetToTop);
1329 CGF.
Builder.CreateUnreachable();
1340 CGM.getItaniumVTableContext().getVirtualBaseOffsetOffset(ClassDecl,
1345 "vbase.offset.ptr");
1347 CGM.PtrDiffTy->getPointerTo());
1358 assert(CGM.getTarget().getCXXABI().hasConstructorVariants());
1382 ArgTys.insert(ArgTys.begin() + 1,
1384 return AddedStructorArgs::prefix(1);
1386 return AddedStructorArgs{};
1409 assert(isa<CXXConstructorDecl>(MD) || isa<CXXDestructorDecl>(MD));
1412 if (NeedsVTTParameter(CGF.
CurGD)) {
1420 Params.insert(Params.begin() + 1, VTTDecl);
1421 getStructorImplicitParamDecl(CGF) = VTTDecl;
1425 void ItaniumCXXABI::EmitInstanceFunctionProlog(
CodeGenFunction &CGF) {
1434 if (getStructorImplicitParamDecl(CGF)) {
1447 if (HasThisReturn(CGF.
CurGD))
1453 bool ForVirtualBase,
bool Delegating,
CallArgList &Args) {
1455 return AddedStructorArgs{};
1460 QualType VTTTy = getContext().getPointerType(getContext().VoidPtrTy);
1461 Args.insert(Args.begin() + 1,
1463 return AddedStructorArgs::prefix(1);
1469 bool Delegating,
Address This) {
1472 QualType VTTTy = getContext().getPointerType(getContext().VoidPtrTy);
1475 if (getContext().getLangOpts().AppleKext &&
1490 llvm::GlobalVariable *VTable = getAddrOfVTable(RD,
CharUnits());
1491 if (VTable->hasInitializer())
1496 llvm::GlobalVariable::LinkageTypes
Linkage = CGM.getVTableLinkage(RD);
1497 llvm::Constant *RTTI =
1498 CGM.GetAddrOfRTTIDescriptor(CGM.getContext().getTagDeclType(RD));
1502 auto Components = Builder.beginStruct();
1504 Components.finishAndSetAsInitializer(VTable);
1507 VTable->setLinkage(Linkage);
1509 if (CGM.supportsCOMDAT() && VTable->isWeakForLinker())
1510 VTable->setComdat(CGM.getModule().getOrInsertComdat(VTable->getName()));
1513 CGM.setGlobalVisibility(VTable, RD);
1518 unsigned PAlign = CGM.getTarget().getPointerAlign(0);
1519 VTable->setAlignment(getContext().toCharUnitsFromBits(PAlign).getQuantity());
1527 isa<NamespaceDecl>(DC) && cast<NamespaceDecl>(DC)->getIdentifier() &&
1528 cast<NamespaceDecl>(DC)->
getIdentifier()->isStr(
"__cxxabiv1") &&
1530 EmitFundamentalRTTIDescriptors(RD->
hasAttr<DLLExportAttr>());
1532 if (!VTable->isDeclarationForLinker())
1533 CGM.EmitVTableTypeMetadata(VTable, VTLayout);
1536 bool ItaniumCXXABI::isVirtualOffsetNeededForVTableField(
1540 return NeedsVTTParameter(CGF.
CurGD);
1543 llvm::Value *ItaniumCXXABI::getVTableAddressPointInStructor(
1548 NeedsVTTParameter(CGF.
CurGD)) {
1549 return getVTableAddressPointInStructorWithVTT(CGF, VTableClass, Base,
1552 return getVTableAddressPoint(Base, VTableClass);
1558 llvm::GlobalValue *VTable = getAddrOfVTable(VTableClass,
CharUnits());
1563 CGM.getItaniumVTableContext()
1564 .getVTableLayout(VTableClass)
1565 .getAddressPoint(Base);
1567 llvm::ConstantInt::get(CGM.Int32Ty, 0),
1568 llvm::ConstantInt::get(CGM.Int32Ty, AddressPoint.
VTableIndex),
1572 return llvm::ConstantExpr::getGetElementPtr(VTable->getValueType(), VTable,
1577 llvm::Value *ItaniumCXXABI::getVTableAddressPointInStructorWithVTT(
1581 NeedsVTTParameter(CGF.
CurGD) &&
"This class doesn't have VTT");
1584 uint64_t VirtualPointerIndex =
1585 CGM.getVTables().getSecondaryVirtualPointerIndex(VTableClass, Base);
1589 if (VirtualPointerIndex)
1590 VTT = CGF.
Builder.CreateConstInBoundsGEP1_64(VTT, VirtualPointerIndex);
1596 llvm::Constant *ItaniumCXXABI::getVTableAddressPointForConstExpr(
1598 return getVTableAddressPoint(Base, VTableClass);
1601 llvm::GlobalVariable *ItaniumCXXABI::getAddrOfVTable(
const CXXRecordDecl *RD,
1603 assert(VPtrOffset.
isZero() &&
"Itanium ABI only supports zero vptr offsets");
1605 llvm::GlobalVariable *&VTable = VTables[RD];
1610 CGM.addDeferredVTable(RD);
1613 llvm::raw_svector_ostream Out(Name);
1614 getMangleContext().mangleCXXVTable(RD, Out);
1617 CGM.getItaniumVTableContext().getVTableLayout(RD);
1618 llvm::Type *VTableType = CGM.getVTables().getVTableType(VTLayout);
1620 VTable = CGM.CreateOrReplaceCXXRuntimeVariable(
1622 VTable->setUnnamedAddr(llvm::GlobalValue::UnnamedAddr::Global);
1624 if (RD->
hasAttr<DLLImportAttr>())
1625 VTable->setDLLStorageClass(llvm::GlobalValue::DLLImportStorageClass);
1626 else if (RD->
hasAttr<DLLExportAttr>())
1627 VTable->setDLLStorageClass(llvm::GlobalValue::DLLExportStorageClass);
1638 Ty = Ty->getPointerTo()->getPointerTo();
1639 auto *MethodDecl = cast<CXXMethodDecl>(GD.
getDecl());
1642 uint64_t VTableIndex = CGM.getItaniumVTableContext().getMethodVTableIndex(GD);
1646 MethodDecl->getParent(), VTable,
1647 VTableIndex * CGM.getContext().getTargetInfo().getPointerWidth(0) / 8);
1652 CGF.
Builder.CreateConstInBoundsGEP1_64(VTable, VTableIndex,
"vfn");
1662 if (CGM.getCodeGenOpts().OptimizationLevel > 0 &&
1663 CGM.getCodeGenOpts().StrictVTablePointers)
1664 VFuncLoad->setMetadata(
1665 llvm::LLVMContext::MD_invariant_load,
1666 llvm::MDNode::get(CGM.getLLVMContext(),
1671 CGCallee Callee(MethodDecl, VFunc);
1675 llvm::Value *ItaniumCXXABI::EmitVirtualDestructorCall(
1681 const CGFunctionInfo *FInfo = &CGM.getTypes().arrangeCXXStructorDeclaration(
1685 getVirtualFunctionPointer(CGF,
GlobalDecl(Dtor, DtorType), This, Ty,
1694 void ItaniumCXXABI::emitVirtualInheritanceTables(
const CXXRecordDecl *RD) {
1700 bool ItaniumCXXABI::canSpeculativelyEmitVTable(
const CXXRecordDecl *RD)
const {
1703 if (CGM.getLangOpts().AppleKext)
1710 return !hasAnyUnusedVirtualInlineFunction(RD) && !isVTableHidden(RD);
1714 int64_t NonVirtualAdjustment,
1715 int64_t VirtualAdjustment,
1716 bool IsReturnAdjustment) {
1717 if (!NonVirtualAdjustment && !VirtualAdjustment)
1723 if (NonVirtualAdjustment && !IsReturnAdjustment) {
1730 if (VirtualAdjustment) {
1738 CGF.
Builder.CreateConstInBoundsGEP1_64(VTablePtr, VirtualAdjustment);
1754 if (NonVirtualAdjustment && IsReturnAdjustment) {
1755 ResultPtr = CGF.
Builder.CreateConstInBoundsGEP1_64(ResultPtr,
1756 NonVirtualAdjustment);
1765 const ThisAdjustment &TA) {
1773 const ReturnAdjustment &RA) {
1782 return ItaniumCXXABI::EmitReturnFromThunk(CGF, RV, ResultType);
1787 return ItaniumCXXABI::EmitReturnFromThunk(CGF, Undef, ResultType);
1796 CGM.getContext().getTypeAlignInChars(elementType));
1804 assert(requiresArrayCookie(expr));
1814 assert(CookieSize == getArrayCookieSizeImpl(ElementType));
1818 CharUnits CookieOffset = CookieSize - SizeSize;
1819 if (!CookieOffset.
isZero())
1828 if (CGM.getLangOpts().Sanitize.has(SanitizerKind::Address) && AS == 0 &&
1831 CGM.getSanitizerMetadata()->disableSanitizerForInstruction(SI);
1832 llvm::FunctionType *FTy =
1833 llvm::FunctionType::get(CGM.VoidTy, NumElementsPtr.
getType(),
false);
1835 CGM.CreateRuntimeFunction(FTy,
"__asan_poison_cxx_array_cookie");
1848 Address numElementsPtr = allocPtr;
1850 if (!numElementsOffset.
isZero())
1856 if (!CGM.getLangOpts().Sanitize.has(SanitizerKind::Address) || AS != 0)
1863 llvm::FunctionType *FTy =
1864 llvm::FunctionType::get(CGF.
SizeTy, CGF.
SizeTy->getPointerTo(0),
false);
1866 CGM.CreateRuntimeFunction(FTy,
"__asan_load_cxx_array_cookie");
1880 CGM.getContext().getTypeAlignInChars(elementType));
1888 assert(requiresArrayCookie(expr));
1896 getContext().getTypeSizeInChars(elementType).getQuantity());
1905 CharUnits cookieSize = ARMCXXABI::getArrayCookieSizeImpl(elementType);
1924 llvm::PointerType *GuardPtrTy) {
1926 llvm::FunctionType *FTy =
1930 FTy,
"__cxa_guard_acquire",
1932 llvm::AttributeList::FunctionIndex,
1933 llvm::Attribute::NoUnwind));
1937 llvm::PointerType *GuardPtrTy) {
1939 llvm::FunctionType *FTy =
1940 llvm::FunctionType::get(CGM.
VoidTy, GuardPtrTy,
false);
1942 FTy,
"__cxa_guard_release",
1944 llvm::AttributeList::FunctionIndex,
1945 llvm::Attribute::NoUnwind));
1949 llvm::PointerType *GuardPtrTy) {
1951 llvm::FunctionType *FTy =
1952 llvm::FunctionType::get(CGM.
VoidTy, GuardPtrTy,
false);
1954 FTy,
"__cxa_guard_abort",
1956 llvm::AttributeList::FunctionIndex,
1957 llvm::Attribute::NoUnwind));
1962 llvm::GlobalVariable *Guard;
1963 CallGuardAbort(llvm::GlobalVariable *Guard) : Guard(Guard) {}
1976 llvm::GlobalVariable *var,
1977 bool shouldPerformInit) {
1982 bool NonTemplateInline =
1989 bool threadsafe = getContext().getLangOpts().ThreadsafeStatics &&
1995 bool useInt8GuardVariable = !threadsafe && var->hasInternalLinkage();
1997 llvm::IntegerType *guardTy;
1999 if (useInt8GuardVariable) {
2005 if (UseARMGuardVarABI) {
2011 CGM.getDataLayout().getABITypeAlignment(guardTy));
2014 llvm::PointerType *guardPtrTy = guardTy->getPointerTo();
2018 llvm::GlobalVariable *guard = CGM.getStaticLocalDeclGuardAddress(&D);
2023 llvm::raw_svector_ostream out(guardName);
2024 getMangleContext().mangleStaticGuardVariable(&D, out);
2029 guard =
new llvm::GlobalVariable(CGM.getModule(), guardTy,
2030 false, var->getLinkage(),
2031 llvm::ConstantInt::get(guardTy, 0),
2033 guard->setVisibility(var->getVisibility());
2035 guard->setThreadLocalMode(var->getThreadLocalMode());
2036 guard->setAlignment(guardAlignment.
getQuantity());
2041 llvm::Comdat *
C = var->getComdat();
2043 (CGM.getTarget().getTriple().isOSBinFormatELF() ||
2044 CGM.getTarget().getTriple().isOSBinFormatWasm())) {
2045 guard->setComdat(C);
2049 if (!NonTemplateInline)
2050 CGF.
CurFn->setComdat(C);
2051 }
else if (CGM.supportsCOMDAT() && guard->isWeakForLinker()) {
2052 guard->setComdat(CGM.getModule().getOrInsertComdat(guard->getName()));
2055 CGM.setStaticLocalDeclGuardAddress(&D, guard);
2078 llvm::LoadInst *LI =
2088 LI->setAtomic(llvm::AtomicOrdering::Acquire);
2111 (UseARMGuardVarABI && !useInt8GuardVariable)
2112 ? Builder.CreateAnd(LI, llvm::ConstantInt::get(CGM.Int8Ty, 1))
2114 llvm::Value *isInitialized = Builder.CreateIsNull(V,
"guard.uninitialized");
2120 Builder.CreateCondBr(isInitialized, InitCheckBlock, EndBlock);
2132 Builder.CreateCondBr(Builder.CreateIsNotNull(V,
"tobool"),
2133 InitBlock, EndBlock);
2152 Builder.
CreateStore(llvm::ConstantInt::get(guardTy, 1), guardAddr);
2160 llvm::Constant *dtor,
2161 llvm::Constant *addr,
2163 const char *Name =
"__cxa_atexit";
2166 Name = T.isOSDarwin() ?
"_tlv_atexit" :
"__cxa_thread_atexit";
2173 llvm::FunctionType::get(CGF.
VoidTy, CGF.
Int8PtrTy,
false)->getPointerTo();
2177 llvm::FunctionType *atexitTy =
2178 llvm::FunctionType::get(CGF.
IntTy, paramTys,
false);
2182 if (llvm::Function *fn = dyn_cast<llvm::Function>(atexit))
2183 fn->setDoesNotThrow();
2186 llvm::Constant *handle =
2188 auto *GV = cast<llvm::GlobalValue>(handle->stripPointerCasts());
2192 llvm::ConstantExpr::getBitCast(dtor, dtorTy),
2193 llvm::ConstantExpr::getBitCast(addr, CGF.
Int8PtrTy),
2202 llvm::Constant *dtor,
2203 llvm::Constant *addr) {
2205 if (CGM.getCodeGenOpts().CXAAtExit)
2209 CGM.ErrorUnsupported(&D,
"non-trivial TLS destruction");
2213 if (CGM.getLangOpts().AppleKext) {
2215 return CGM.AddCXXDtorEntry(dtor, addr);
2223 assert(!VD->
isStaticLocal() &&
"static local VarDecls don't need wrappers!");
2233 static llvm::GlobalValue::LinkageTypes
2235 llvm::GlobalValue::LinkageTypes VarLinkage =
2239 if (llvm::GlobalValue::isLocalLinkage(VarLinkage))
2244 if (!llvm::GlobalVariable::isLinkOnceLinkage(VarLinkage) &&
2245 !llvm::GlobalVariable::isWeakODRLinkage(VarLinkage))
2247 return llvm::GlobalValue::WeakODRLinkage;
2251 ItaniumCXXABI::getOrCreateThreadLocalWrapper(
const VarDecl *VD,
2256 llvm::raw_svector_ostream Out(WrapperName);
2257 getMangleContext().mangleItaniumThreadLocalWrapper(VD, Out);
2262 if (
llvm::Value *V = CGM.getModule().getNamedValue(WrapperName))
2263 return cast<llvm::Function>(V);
2269 const CGFunctionInfo &FI = CGM.getTypes().arrangeBuiltinFunctionDeclaration(
2272 llvm::FunctionType *FnTy = CGM.getTypes().GetFunctionType(FI);
2273 llvm::Function *Wrapper =
2275 WrapperName.str(), &CGM.getModule());
2277 CGM.SetLLVMFunctionAttributes(
nullptr, FI, Wrapper);
2280 CGM.SetLLVMFunctionAttributesForDefinition(
nullptr, Wrapper);
2284 !llvm::GlobalVariable::isLinkOnceLinkage(Wrapper->getLinkage()) &&
2285 !llvm::GlobalVariable::isWeakODRLinkage(Wrapper->getLinkage())))
2289 Wrapper->setCallingConv(llvm::CallingConv::CXX_FAST_TLS);
2290 Wrapper->addFnAttr(llvm::Attribute::NoUnwind);
2295 void ItaniumCXXABI::EmitThreadLocalInitFuncs(
2299 llvm::Function *InitFunc =
nullptr;
2304 llvm::SmallDenseMap<const VarDecl *, llvm::Function *> UnorderedInits;
2305 for (
unsigned I = 0;
I != CXXThreadLocalInits.size(); ++
I) {
2309 CXXThreadLocalInits[
I];
2311 OrderedInits.push_back(CXXThreadLocalInits[
I]);
2314 if (!OrderedInits.empty()) {
2316 llvm::FunctionType *FTy =
2317 llvm::FunctionType::get(CGM.
VoidTy,
false);
2322 llvm::GlobalVariable *Guard =
new llvm::GlobalVariable(
2325 llvm::ConstantInt::get(CGM.
Int8Ty, 0),
"__tls_guard");
2326 Guard->setThreadLocal(
true);
2335 InitFunc->setCallingConv(llvm::CallingConv::CXX_FAST_TLS);
2336 InitFunc->addFnAttr(llvm::Attribute::NoUnwind);
2341 for (
const VarDecl *VD : CXXThreadLocals) {
2342 llvm::GlobalVariable *Var =
2344 llvm::Function *Wrapper = getOrCreateThreadLocalWrapper(VD, Var);
2357 llvm::raw_svector_ostream Out(InitFnName);
2358 getMangleContext().mangleItaniumThreadLocalInit(VD, Out);
2364 llvm::GlobalValue *Init =
nullptr;
2365 bool InitIsInitFunc =
false;
2367 InitIsInitFunc =
true;
2368 llvm::Function *InitFuncToUse = InitFunc;
2379 llvm::FunctionType *FnTy = llvm::FunctionType::get(CGM.
VoidTy,
false);
2381 llvm::GlobalVariable::ExternalWeakLinkage,
2388 Init->setVisibility(Var->getVisibility());
2390 llvm::LLVMContext &Context = CGM.
getModule().getContext();
2393 if (InitIsInitFunc) {
2395 llvm::CallInst *CallVal = Builder.CreateCall(Init);
2397 CallVal->setCallingConv(llvm::CallingConv::CXX_FAST_TLS);
2401 llvm::Value *Have = Builder.CreateIsNotNull(Init);
2404 Builder.CreateCondBr(Have, InitBB, ExitBB);
2406 Builder.SetInsertPoint(InitBB);
2407 Builder.CreateCall(Init);
2408 Builder.CreateBr(ExitBB);
2410 Builder.SetInsertPoint(ExitBB);
2420 if (Val->getType() != Wrapper->getReturnType())
2422 Val, Wrapper->getReturnType(),
"");
2423 Builder.CreateRet(Val);
2431 llvm::Function *Wrapper = getOrCreateThreadLocalWrapper(VD, Val);
2433 llvm::CallInst *CallVal = CGF.
Builder.CreateCall(Wrapper);
2434 CallVal->setCallingConv(Wrapper->getCallingConv());
2448 bool ItaniumCXXABI::NeedsVTTParameter(
GlobalDecl GD) {
2467 class ItaniumRTTIBuilder {
2469 llvm::LLVMContext &VMContext;
2470 const ItaniumCXXABI &
CXXABI;
2476 llvm::GlobalVariable *
2477 GetAddrOfTypeName(
QualType Ty, llvm::GlobalVariable::LinkageTypes Linkage);
2481 llvm::Constant *GetAddrOfExternalRTTIDescriptor(
QualType Ty);
2484 void BuildVTablePointer(
const Type *Ty);
2497 void BuildPointerTypeInfo(
QualType PointeeTy);
2508 ItaniumRTTIBuilder(
const ItaniumCXXABI &ABI)
2509 : CGM(ABI.CGM), VMContext(CGM.getModule().getContext()),
CXXABI(ABI) {}
2523 PTI_Incomplete = 0x8,
2527 PTI_ContainingClassIncomplete = 0x10,
2533 PTI_Noexcept = 0x40,
2539 VMI_NonDiamondRepeat = 0x1,
2542 VMI_DiamondShaped = 0x2
2558 llvm::Constant *BuildTypeInfo(
QualType Ty,
bool Force =
false,
2559 bool DLLExport =
false);
2563 llvm::GlobalVariable *ItaniumRTTIBuilder::GetAddrOfTypeName(
2564 QualType Ty, llvm::GlobalVariable::LinkageTypes Linkage) {
2566 llvm::raw_svector_ostream Out(Name);
2572 llvm::Constant *Init = llvm::ConstantDataArray::getString(VMContext,
2575 llvm::GlobalVariable *GV =
2578 GV->setInitializer(Init);
2584 ItaniumRTTIBuilder::GetAddrOfExternalRTTIDescriptor(
QualType Ty) {
2587 llvm::raw_svector_ostream Out(Name);
2591 llvm::GlobalVariable *GV = CGM.
getModule().getNamedGlobal(Name);
2602 if (
const RecordType *RecordTy = dyn_cast<RecordType>(Ty)) {
2603 const CXXRecordDecl *RD = cast<CXXRecordDecl>(RecordTy->getDecl());
2604 if (RD->
hasAttr<DLLImportAttr>())
2605 GV->setDLLStorageClass(llvm::GlobalVariable::DLLImportStorageClass);
2609 return llvm::ConstantExpr::getBitCast(GV, CGM.
Int8PtrTy);
2630 case BuiltinType::Void:
2631 case BuiltinType::NullPtr:
2632 case BuiltinType::Bool:
2633 case BuiltinType::WChar_S:
2634 case BuiltinType::WChar_U:
2635 case BuiltinType::Char_U:
2636 case BuiltinType::Char_S:
2637 case BuiltinType::UChar:
2638 case BuiltinType::SChar:
2639 case BuiltinType::Short:
2640 case BuiltinType::UShort:
2641 case BuiltinType::Int:
2642 case BuiltinType::UInt:
2643 case BuiltinType::Long:
2644 case BuiltinType::ULong:
2645 case BuiltinType::LongLong:
2646 case BuiltinType::ULongLong:
2647 case BuiltinType::Half:
2648 case BuiltinType::Float:
2649 case BuiltinType::Double:
2650 case BuiltinType::LongDouble:
2651 case BuiltinType::Float128:
2652 case BuiltinType::Char16:
2653 case BuiltinType::Char32:
2654 case BuiltinType::Int128:
2655 case BuiltinType::UInt128:
2658 #define IMAGE_TYPE(ImgType, Id, SingletonId, Access, Suffix) \
2659 case BuiltinType::Id:
2660 #include "clang/Basic/OpenCLImageTypes.def"
2661 case BuiltinType::OCLSampler:
2662 case BuiltinType::OCLEvent:
2663 case BuiltinType::OCLClkEvent:
2664 case BuiltinType::OCLQueue:
2665 case BuiltinType::OCLReserveID:
2668 case BuiltinType::Dependent:
2669 #define BUILTIN_TYPE(Id, SingletonId)
2670 #define PLACEHOLDER_TYPE(Id, SingletonId) \
2671 case BuiltinType::Id:
2672 #include "clang/AST/BuiltinTypes.def"
2673 llvm_unreachable(
"asking for RRTI for a placeholder type!");
2675 case BuiltinType::ObjCId:
2676 case BuiltinType::ObjCClass:
2677 case BuiltinType::ObjCSel:
2678 llvm_unreachable(
"FIXME: Objective-C types are unsupported!");
2681 llvm_unreachable(
"Invalid BuiltinType Kind!");
2704 if (
const BuiltinType *BuiltinTy = dyn_cast<BuiltinType>(Ty))
2709 if (
const PointerType *PointerTy = dyn_cast<PointerType>(Ty))
2727 if (
const RecordType *RecordTy = dyn_cast<RecordType>(Ty)) {
2728 const CXXRecordDecl *RD = cast<CXXRecordDecl>(RecordTy->getDecl());
2739 bool IsDLLImport = RD->
hasAttr<DLLImportAttr>();
2741 return IsDLLImport && !CGM.
getTriple().isWindowsItaniumEnvironment()
2769 if (
const RecordType *RecordTy = dyn_cast<RecordType>(Ty)) {
2774 if (
const PointerType *PointerTy = dyn_cast<PointerType>(Ty))
2778 dyn_cast<MemberPointerType>(Ty)) {
2780 const RecordType *ClassType = cast<RecordType>(MemberPointerTy->getClass());
2819 void ItaniumRTTIBuilder::BuildVTablePointer(
const Type *Ty) {
2821 static const char *
const ClassTypeInfo =
2822 "_ZTVN10__cxxabiv117__class_type_infoE";
2824 static const char *
const SIClassTypeInfo =
2825 "_ZTVN10__cxxabiv120__si_class_type_infoE";
2827 static const char *
const VMIClassTypeInfo =
2828 "_ZTVN10__cxxabiv121__vmi_class_type_infoE";
2830 const char *VTableName =
nullptr;
2833 #define TYPE(Class, Base)
2834 #define ABSTRACT_TYPE(Class, Base)
2835 #define NON_CANONICAL_UNLESS_DEPENDENT_TYPE(Class, Base) case Type::Class:
2836 #define NON_CANONICAL_TYPE(Class, Base) case Type::Class:
2837 #define DEPENDENT_TYPE(Class, Base) case Type::Class:
2838 #include "clang/AST/TypeNodes.def"
2839 llvm_unreachable(
"Non-canonical and dependent types shouldn't get here");
2841 case Type::LValueReference:
2842 case Type::RValueReference:
2843 llvm_unreachable(
"References shouldn't get here");
2846 case Type::DeducedTemplateSpecialization:
2847 llvm_unreachable(
"Undeduced type shouldn't get here");
2850 llvm_unreachable(
"Pipe types shouldn't get here");
2855 case Type::ExtVector:
2859 case Type::BlockPointer:
2861 VTableName =
"_ZTVN10__cxxabiv123__fundamental_type_infoE";
2864 case Type::ConstantArray:
2865 case Type::IncompleteArray:
2866 case Type::VariableArray:
2868 VTableName =
"_ZTVN10__cxxabiv117__array_type_infoE";
2871 case Type::FunctionNoProto:
2872 case Type::FunctionProto:
2874 VTableName =
"_ZTVN10__cxxabiv120__function_type_infoE";
2879 VTableName =
"_ZTVN10__cxxabiv116__enum_type_infoE";
2882 case Type::Record: {
2884 cast<CXXRecordDecl>(cast<RecordType>(Ty)->getDecl());
2887 VTableName = ClassTypeInfo;
2889 VTableName = SIClassTypeInfo;
2891 VTableName = VMIClassTypeInfo;
2897 case Type::ObjCObject:
2899 Ty = cast<ObjCObjectType>(Ty)->getBaseType().getTypePtr();
2902 if (isa<BuiltinType>(Ty)) {
2903 VTableName = ClassTypeInfo;
2907 assert(isa<ObjCInterfaceType>(Ty));
2910 case Type::ObjCInterface:
2911 if (cast<ObjCInterfaceType>(Ty)->getDecl()->getSuperClass()) {
2912 VTableName = SIClassTypeInfo;
2914 VTableName = ClassTypeInfo;
2918 case Type::ObjCObjectPointer:
2921 VTableName =
"_ZTVN10__cxxabiv119__pointer_type_infoE";
2924 case Type::MemberPointer:
2926 VTableName =
"_ZTVN10__cxxabiv129__pointer_to_member_type_infoE";
2930 llvm::Constant *VTable =
2937 llvm::Constant *Two = llvm::ConstantInt::get(PtrDiffTy, 2);
2939 llvm::ConstantExpr::getInBoundsGetElementPtr(CGM.
Int8PtrTy, VTable, Two);
2940 VTable = llvm::ConstantExpr::getBitCast(VTable, CGM.
Int8PtrTy);
2942 Fields.push_back(VTable);
2974 return llvm::GlobalValue::LinkOnceODRLinkage;
2976 if (
const RecordType *Record = dyn_cast<RecordType>(Ty)) {
2977 const CXXRecordDecl *RD = cast<CXXRecordDecl>(Record->getDecl());
2979 return llvm::GlobalValue::WeakODRLinkage;
2980 if (CGM.
getTriple().isWindowsItaniumEnvironment())
2981 if (RD->
hasAttr<DLLImportAttr>() &&
2988 if (RD->
hasAttr<DLLImportAttr>() &&
2989 llvm::GlobalValue::isAvailableExternallyLinkage(LT))
2990 LT = llvm::GlobalValue::LinkOnceODRLinkage;
2995 return llvm::GlobalValue::LinkOnceODRLinkage;
2998 llvm_unreachable(
"Invalid linkage!");
3001 llvm::Constant *ItaniumRTTIBuilder::BuildTypeInfo(
QualType Ty,
bool Force,
3008 llvm::raw_svector_ostream Out(Name);
3011 llvm::GlobalVariable *OldGV = CGM.
getModule().getNamedGlobal(Name);
3012 if (OldGV && !OldGV->isDeclaration()) {
3013 assert(!OldGV->hasAvailableExternallyLinkage() &&
3014 "available_externally typeinfos not yet implemented");
3016 return llvm::ConstantExpr::getBitCast(OldGV, CGM.
Int8PtrTy);
3022 return GetAddrOfExternalRTTIDescriptor(Ty);
3025 llvm::GlobalVariable::LinkageTypes
Linkage;
3032 BuildVTablePointer(cast<Type>(Ty));
3035 llvm::GlobalVariable *TypeName = GetAddrOfTypeName(Ty, Linkage);
3036 llvm::Constant *TypeNameField;
3040 ItaniumCXXABI::RTTIUniquenessKind RTTIUniqueness =
3041 CXXABI.classifyRTTIUniqueness(Ty, Linkage);
3042 if (RTTIUniqueness != ItaniumCXXABI::RUK_Unique) {
3045 TypeNameField = llvm::ConstantExpr::getPtrToInt(TypeName, CGM.
Int64Ty);
3046 llvm::Constant *flag =
3047 llvm::ConstantInt::get(CGM.
Int64Ty, ((uint64_t)1) << 63);
3048 TypeNameField = llvm::ConstantExpr::getAdd(TypeNameField, flag);
3050 llvm::ConstantExpr::getIntToPtr(TypeNameField, CGM.
Int8PtrTy);
3052 TypeNameField = llvm::ConstantExpr::getBitCast(TypeName, CGM.
Int8PtrTy);
3054 Fields.push_back(TypeNameField);
3057 #define TYPE(Class, Base)
3058 #define ABSTRACT_TYPE(Class, Base)
3059 #define NON_CANONICAL_UNLESS_DEPENDENT_TYPE(Class, Base) case Type::Class:
3060 #define NON_CANONICAL_TYPE(Class, Base) case Type::Class:
3061 #define DEPENDENT_TYPE(Class, Base) case Type::Class:
3062 #include "clang/AST/TypeNodes.def"
3063 llvm_unreachable(
"Non-canonical and dependent types shouldn't get here");
3068 case Type::ExtVector:
3070 case Type::BlockPointer:
3075 case Type::LValueReference:
3076 case Type::RValueReference:
3077 llvm_unreachable(
"References shouldn't get here");
3080 case Type::DeducedTemplateSpecialization:
3081 llvm_unreachable(
"Undeduced type shouldn't get here");
3084 llvm_unreachable(
"Pipe type shouldn't get here");
3086 case Type::ConstantArray:
3087 case Type::IncompleteArray:
3088 case Type::VariableArray:
3093 case Type::FunctionNoProto:
3094 case Type::FunctionProto:
3104 case Type::Record: {
3106 cast<CXXRecordDecl>(cast<RecordType>(Ty)->getDecl());
3113 BuildSIClassTypeInfo(RD);
3115 BuildVMIClassTypeInfo(RD);
3120 case Type::ObjCObject:
3121 case Type::ObjCInterface:
3122 BuildObjCObjectTypeInfo(cast<ObjCObjectType>(Ty));
3125 case Type::ObjCObjectPointer:
3126 BuildPointerTypeInfo(cast<ObjCObjectPointerType>(Ty)->getPointeeType());
3130 BuildPointerTypeInfo(cast<PointerType>(Ty)->getPointeeType());
3133 case Type::MemberPointer:
3134 BuildPointerToMemberTypeInfo(cast<MemberPointerType>(Ty));
3142 llvm::Constant *Init = llvm::ConstantStruct::getAnon(Fields);
3145 llvm::GlobalVariable *GV =
3146 new llvm::GlobalVariable(M, Init->getType(),
3151 GV->takeName(OldGV);
3152 llvm::Constant *NewPtr =
3153 llvm::ConstantExpr::getBitCast(GV, OldGV->getType());
3154 OldGV->replaceAllUsesWith(NewPtr);
3155 OldGV->eraseFromParent();
3159 GV->setComdat(M.getOrInsertComdat(GV->getName()));
3178 llvm::GlobalValue::VisibilityTypes llvmVisibility;
3179 if (llvm::GlobalValue::isLocalLinkage(Linkage))
3182 else if (RTTIUniqueness == ItaniumCXXABI::RUK_NonUniqueHidden)
3187 TypeName->setVisibility(llvmVisibility);
3188 GV->setVisibility(llvmVisibility);
3190 if (CGM.
getTriple().isWindowsItaniumEnvironment()) {
3192 if (DLLExport || (RD && RD->
hasAttr<DLLExportAttr>())) {
3193 TypeName->setDLLStorageClass(llvm::GlobalValue::DLLExportStorageClass);
3194 GV->setDLLStorageClass(llvm::GlobalValue::DLLExportStorageClass);
3195 }
else if (RD && RD->
hasAttr<DLLImportAttr>() &&
3197 TypeName->setDLLStorageClass(llvm::GlobalValue::DLLImportStorageClass);
3198 GV->setDLLStorageClass(llvm::GlobalValue::DLLImportStorageClass);
3203 TypeName->setInitializer(
nullptr);
3204 GV->setInitializer(
nullptr);
3208 return llvm::ConstantExpr::getBitCast(GV, CGM.
Int8PtrTy);
3213 void ItaniumRTTIBuilder::BuildObjCObjectTypeInfo(
const ObjCObjectType *OT) {
3216 assert(isa<BuiltinType>(T) || isa<ObjCInterfaceType>(T));
3220 if (isa<BuiltinType>(T))
return;
3231 llvm::Constant *BaseTypeInfo =
3232 ItaniumRTTIBuilder(
CXXABI).BuildTypeInfo(SuperTy);
3233 Fields.push_back(BaseTypeInfo);
3238 void ItaniumRTTIBuilder::BuildSIClassTypeInfo(
const CXXRecordDecl *RD) {
3242 llvm::Constant *BaseTypeInfo =
3244 Fields.push_back(BaseTypeInfo);
3251 llvm::SmallPtrSet<const CXXRecordDecl *, 16> NonVirtualBases;
3252 llvm::SmallPtrSet<const CXXRecordDecl *, 16> VirtualBases;
3269 if (!Bases.VirtualBases.insert(BaseDecl).second) {
3272 Flags |= ItaniumRTTIBuilder::VMI_DiamondShaped;
3274 if (Bases.NonVirtualBases.count(BaseDecl))
3275 Flags |= ItaniumRTTIBuilder::VMI_NonDiamondRepeat;
3279 if (!Bases.NonVirtualBases.insert(BaseDecl).second) {
3282 Flags |= ItaniumRTTIBuilder::VMI_NonDiamondRepeat;
3284 if (Bases.VirtualBases.count(BaseDecl))
3285 Flags |= ItaniumRTTIBuilder::VMI_NonDiamondRepeat;
3290 for (
const auto &
I : BaseDecl->
bases())
3301 for (
const auto &
I : RD->
bases())
3310 void ItaniumRTTIBuilder::BuildVMIClassTypeInfo(
const CXXRecordDecl *RD) {
3319 Fields.push_back(llvm::ConstantInt::get(UnsignedIntLTy, Flags));
3324 Fields.push_back(llvm::ConstantInt::get(UnsignedIntLTy, RD->
getNumBases()));
3359 for (
const auto &Base : RD->
bases()) {
3361 Fields.push_back(ItaniumRTTIBuilder(
CXXABI).BuildTypeInfo(Base.getType()));
3364 cast<CXXRecordDecl>(Base.getType()->getAs<
RecordType>()->getDecl());
3366 int64_t OffsetFlags = 0;
3373 if (Base.isVirtual())
3381 OffsetFlags = uint64_t(Offset.
getQuantity()) << 8;
3385 if (Base.isVirtual())
3386 OffsetFlags |= BCTI_Virtual;
3387 if (Base.getAccessSpecifier() ==
AS_public)
3388 OffsetFlags |= BCTI_Public;
3390 Fields.push_back(llvm::ConstantInt::get(OffsetFlagsLTy, OffsetFlags));
3400 Flags |= ItaniumRTTIBuilder::PTI_Const;
3402 Flags |= ItaniumRTTIBuilder::PTI_Volatile;
3404 Flags |= ItaniumRTTIBuilder::PTI_Restrict;
3411 Flags |= ItaniumRTTIBuilder::PTI_Incomplete;
3414 if (Proto->isNothrow(Ctx)) {
3415 Flags |= ItaniumRTTIBuilder::PTI_Noexcept;
3417 Proto->getReturnType(), Proto->getParamTypes(),
3418 Proto->getExtProtoInfo().withExceptionSpec(
EST_None));
3427 void ItaniumRTTIBuilder::BuildPointerTypeInfo(
QualType PointeeTy) {
3435 Fields.push_back(llvm::ConstantInt::get(UnsignedIntLTy, Flags));
3440 llvm::Constant *PointeeTypeInfo =
3441 ItaniumRTTIBuilder(
CXXABI).BuildTypeInfo(PointeeTy);
3442 Fields.push_back(PointeeTypeInfo);
3458 Flags |= PTI_ContainingClassIncomplete;
3462 Fields.push_back(llvm::ConstantInt::get(UnsignedIntLTy, Flags));
3467 llvm::Constant *PointeeTypeInfo =
3468 ItaniumRTTIBuilder(
CXXABI).BuildTypeInfo(PointeeTy);
3469 Fields.push_back(PointeeTypeInfo);
3476 ItaniumRTTIBuilder(
CXXABI).BuildTypeInfo(
QualType(ClassType, 0)));
3479 llvm::Constant *ItaniumCXXABI::getAddrOfRTTIDescriptor(
QualType Ty) {
3480 return ItaniumRTTIBuilder(*this).BuildTypeInfo(Ty);
3483 void ItaniumCXXABI::EmitFundamentalRTTIDescriptor(
QualType Type,
3487 ItaniumRTTIBuilder(*this).BuildTypeInfo(Type,
true, DLLExport);
3488 ItaniumRTTIBuilder(*this).BuildTypeInfo(PointerType,
true,
3490 ItaniumRTTIBuilder(*this).BuildTypeInfo(PointerTypeConst,
true,
3494 void ItaniumCXXABI::EmitFundamentalRTTIDescriptors(
bool DLLExport) {
3497 getContext().VoidTy, getContext().NullPtrTy,
3498 getContext().BoolTy, getContext().WCharTy,
3499 getContext().CharTy, getContext().UnsignedCharTy,
3500 getContext().SignedCharTy, getContext().ShortTy,
3501 getContext().UnsignedShortTy, getContext().IntTy,
3502 getContext().UnsignedIntTy, getContext().LongTy,
3503 getContext().UnsignedLongTy, getContext().LongLongTy,
3504 getContext().UnsignedLongLongTy, getContext().Int128Ty,
3505 getContext().UnsignedInt128Ty, getContext().HalfTy,
3506 getContext().FloatTy, getContext().DoubleTy,
3507 getContext().LongDoubleTy, getContext().Float128Ty,
3508 getContext().Char16Ty, getContext().Char32Ty
3510 for (
const QualType &FundamentalType : FundamentalTypes)
3511 EmitFundamentalRTTIDescriptor(FundamentalType, DLLExport);
3516 ItaniumCXXABI::RTTIUniquenessKind ItaniumCXXABI::classifyRTTIUniqueness(
3517 QualType CanTy, llvm::GlobalValue::LinkageTypes Linkage)
const {
3518 if (shouldRTTIBeUnique())
3522 if (Linkage != llvm::GlobalValue::LinkOnceODRLinkage &&
3523 Linkage != llvm::GlobalValue::WeakODRLinkage)
3531 if (Linkage == llvm::GlobalValue::LinkOnceODRLinkage)
3532 return RUK_NonUniqueHidden;
3537 assert(Linkage == llvm::GlobalValue::WeakODRLinkage);
3538 return RUK_NonUniqueVisible;
3548 return StructorCodegen::Emit;
3553 return StructorCodegen::Emit;
3556 if (
const auto *DD = dyn_cast<CXXDestructorDecl>(MD)) {
3559 const auto *CD = cast<CXXConstructorDecl>(MD);
3564 if (llvm::GlobalValue::isDiscardableIfUnused(Linkage))
3565 return StructorCodegen::RAUW;
3568 if (!llvm::GlobalAlias::isValidLinkage(Linkage))
3569 return StructorCodegen::RAUW;
3571 if (llvm::GlobalValue::isWeakForLinker(Linkage)) {
3575 return StructorCodegen::COMDAT;
3576 return StructorCodegen::Emit;
3579 return StructorCodegen::Alias;
3589 if (Entry && !Entry->isDeclaration())
3592 auto *Aliasee = cast<llvm::GlobalValue>(CGM.
GetAddrOfGlobal(TargetDecl));
3599 assert(Entry->getType() == Aliasee->getType() &&
3600 "declaration exists with different type");
3601 Alias->takeName(Entry);
3602 Entry->replaceAllUsesWith(Alias);
3603 Entry->eraseFromParent();
3605 Alias->setName(MangledName);
3612 void ItaniumCXXABI::emitCXXStructor(
const CXXMethodDecl *MD,
3630 if (CGType == StructorCodegen::Alias || CGType == StructorCodegen::COMDAT) {
3635 if (CGType == StructorCodegen::RAUW) {
3653 if (CGType == StructorCodegen::COMDAT) {
3655 llvm::raw_svector_ostream Out(Buffer);
3657 getMangleContext().mangleCXXDtorComdat(DD, Out);
3659 getMangleContext().mangleCXXCtorComdat(CD, Out);
3660 llvm::Comdat *C = CGM.
getModule().getOrInsertComdat(Out.str());
3669 llvm::FunctionType *FTy = llvm::FunctionType::get(
3677 llvm::FunctionType *FTy =
3678 llvm::FunctionType::get(CGM.
VoidTy,
false);
3685 llvm::FunctionType *FTy = llvm::FunctionType::get(
3705 CallEndCatch(
bool MightThrow) : MightThrow(MightThrow) {}
3725 bool EndMightThrow) {
3726 llvm::CallInst *call =
3749 if (isa<ReferenceType>(CatchType)) {
3750 QualType CaughtType = cast<ReferenceType>(CatchType)->getPointeeType();
3759 if (
const PointerType *PT = dyn_cast<PointerType>(CaughtType)) {
3768 unsigned HeaderSize =
3770 AdjustedExn = CGF.
Builder.CreateConstGEP1_32(Exn, HeaderSize);
3789 cast<llvm::PointerType>(LLVMCatchTy)->getElementType();
3815 if (CatchType->hasPointerRepresentation()) {
3834 llvm_unreachable(
"bad ownership qualifier!");
3839 llvm::Type *PtrTy = LLVMCatchTy->getPointerTo(0);
3855 llvm_unreachable(
"evaluation kind filtered out!");
3857 llvm_unreachable(
"bad evaluation kind");
3860 assert(isa<RecordType>(CatchType) &&
"unexpected catch type!");
3861 auto catchRD = CatchType->getAsCXXRecordDecl();
3864 llvm::Type *PtrTy = LLVMCatchTy->getPointerTo(0);
3872 caughtExnAlignment);
3879 llvm::CallInst *rawAdjustedExn =
3884 caughtExnAlignment);
3956 llvm::FunctionType *fnTy =
3959 fnTy,
"__clang_call_terminate", llvm::AttributeList(),
true);
3961 llvm::Function *fn = dyn_cast<llvm::Function>(fnRef);
3962 if (fn && fn->empty()) {
3963 fn->setDoesNotThrow();
3964 fn->setDoesNotReturn();
3969 fn->addFnAttr(llvm::Attribute::NoInline);
3973 fn->setLinkage(llvm::Function::LinkOnceODRLinkage);
3976 fn->setComdat(CGM.
getModule().getOrInsertComdat(fn->getName()));
3979 llvm::BasicBlock *entry =
3987 llvm::CallInst *catchCall = builder.CreateCall(
getBeginCatchFn(CGM), exn);
3988 catchCall->setDoesNotThrow();
3992 llvm::CallInst *termCall = builder.CreateCall(CGM.
getTerminateFn());
3993 termCall->setDoesNotThrow();
3994 termCall->setDoesNotReturn();
3998 builder.CreateUnreachable();
4005 ItaniumCXXABI::emitTerminateForUnexpectedException(
CodeGenFunction &CGF,
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...
CastKind getCastKind() const
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
bool isDerivedFrom(const CXXRecordDecl *Base) const
Determine whether this class is derived from the class Base.
void GenerateCXXGlobalInitFunc(llvm::Function *Fn, ArrayRef< llvm::Function * > CXXThreadLocals, Address Guard=Address::invalid())
GenerateCXXGlobalInitFunc - Generates code for initializing global variables.
const internal::VariadicDynCastAllOfMatcher< Stmt, Expr > expr
Matches expressions.
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.
TemplateSpecializationKind getTemplateSpecializationKind() const
If this variable is an instantiation of a variable template or a static data member of a class templa...
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...
bool isVirtual() const
Determines whether the base class is a virtual base class (or not).
static llvm::Constant * getAllocateExceptionFn(CodeGenModule &CGM)
CodeGenTypes & getTypes()
llvm::Type * ConvertTypeForMem(QualType T)
CanQualType getReturnType() const
CharUnits getDeclAlign(const Decl *D, bool ForAlignof=false) const
Return a conservative estimate of the alignment of the specified decl D.
bool hasTrivialDestructor() const
Determine whether this class has a trivial destructor (C++ [class.dtor]p3)
Internal linkage according to the Modules TS, but can be referred to from other translation units ind...
QualType getType() const
Retrieves the type of the base class.
CXXCtorType getCtorType() const
llvm::Module & getModule() const
llvm::LLVMContext & getLLVMContext()
The COMDAT used for ctors.
IdentifierInfo * getIdentifier() const
getIdentifier - Get the identifier that names this declaration, if there is one.
The standard implementation of ConstantInitBuilder used in Clang.
CharUnits getClassPointerAlignment(const CXXRecordDecl *CD)
Returns the assumed alignment of an opaque pointer to the given class.
const TargetInfo & getTarget() const
bool isGlobalDelete() const
No linkage, which means that the entity is unique and can only be referred to from within its scope...
C Language Family Type Representation.
QuantityType getQuantity() const
getQuantity - Get the raw integer representation of this quantity.
static TemplateSpecializationKind getTemplateSpecializationKind(Decl *D)
Determine what kind of template specialization the given declaration is.
bool isRecordType() const
void setAliasAttributes(const Decl *D, llvm::GlobalValue *GV)
Set attributes which must be preserved by an alias.
bool hasNonTrivialDestructor() const
Determine whether this class has a non-trivial destructor (C++ [class.dtor]p3)
llvm::CallingConv::ID getRuntimeCC() const
bool hasDefinition() const
QualType getPointeeType() const
The base class of the type hierarchy.
int64_t NonVirtual
The non-virtual adjustment from the derived object to its nearest virtual base.
std::unique_ptr< llvm::MemoryBuffer > Buffer
const Expr * getInit() const
bool isFuncTypeConvertible(const FunctionType *FT)
isFuncTypeConvertible - Utility to check whether a function type can be converted to an LLVM type (i...
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.
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...
Objects with "hidden" visibility are not seen by the dynamic linker.
llvm::Type * getElementType() const
Return the type of the values stored in this address.
unsigned AddressPointIndex
TLSKind getTLSKind() const
ObjCLifetime getObjCLifetime() const
SourceLocation getLocStart() const LLVM_READONLY
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.
Visibility getVisibility() const
Determines the visibility of this entity.
Attempt to be ABI-compatible with code generated by Clang 4.0.x (SVN r291814).
A C++ throw-expression (C++ [except.throw]).
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)
The collection of all-type qualifiers we support.
GlobalDecl getCanonicalDecl() const
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 isEmpty() const
Determine whether this is an empty class in the sense of (C++11 [meta.unary.prop]).
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.
bool hasNonTrivialCopyConstructor() const
Determine whether this class has a non-trivial copy constructor (C++ [class.copy]p6, C++11 [class.copy]p12)
bool isReferenceType() const
The generic Mips ABI is a modified version of the Itanium ABI.
bool isCompleteDefinition() const
isCompleteDefinition - Return true if this decl has its body fully specified.
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++ 'this' argument.
llvm::IntegerType * SizeTy
An RAII object to set (and then clear) a mapping for an OpaqueValueExpr.
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 isTranslationUnit() 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)
const Decl * getDecl() const
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...
void EmitNoreturnRuntimeCallOrInvoke(llvm::Value *callee, ArrayRef< llvm::Value * > args)
Emits a call or invoke to the given noreturn runtime function.
llvm::Value * EmitLoadOfScalar(Address Addr, bool Volatile, QualType Ty, SourceLocation Loc, LValueBaseInfo BaseInfo=LValueBaseInfo(AlignmentSource::Type), llvm::MDNode *TBAAInfo=nullptr, QualType TBAABaseTy=QualType(), uint64_t TBAAOffset=0, bool isNontemporal=false)
EmitLoadOfScalar - Load a scalar value from an address, taking care to appropriately convert from the...
static unsigned extractPBaseFlags(ASTContext &Ctx, QualType &Type)
Compute the flags for a __pbase_type_info, and remove the corresponding pieces from Type...
const TargetInfo & getTargetInfo() const
static unsigned ComputeVMIClassTypeInfoFlags(const CXXBaseSpecifier *Base, SeenBases &Bases)
ComputeVMIClassTypeInfoFlags - Compute the value of the flags member in abi::__vmi_class_type_info.
const LangOptions & getLangOpts() const
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...
QualType getBaseType() const
Gets the base type of this object type.
The Microsoft ABI is the ABI used by Microsoft Visual Studio (and compatible compilers).
const ValueDecl * getMemberPointerDecl() const
const CXXRecordDecl * getParent() const
Returns the parent of this method declaration, which is the class in which this method is defined...
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].
RecordDecl * getDecl() 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.
llvm::Constant * getTerminateFn()
Get the declaration of std::terminate for the platform.
static StructorCodegen getCodegenToUse(CodeGenModule &CGM, const CXXMethodDecl *MD)
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.
CastExpr - Base class for type casts, including both implicit casts (ImplicitCastExpr) and explicit c...
TypeClass getTypeClass() const
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 isStaticLocal() const
isStaticLocal - Returns true if a variable with function scope is a static local variable.
GlobalDecl CurGD
CurGD - The GlobalDecl for the current function being compiled.
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.
detail::InMemoryDirectory::const_iterator I
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
bool isMemberFunctionPointer() const
Returns true if the member type (i.e.
This object can be modified without requiring retains or releases.
bool isDefined(const FunctionDecl *&Definition) const
isDefined - Returns true if the function is defined at all, including a deleted definition.
CharUnits getSizeSize() const
bool isAbstract() const
Determine whether this class has a pure virtual function.
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.
static ImplicitParamDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation IdLoc, IdentifierInfo *Id, QualType T, ImplicitParamKind ParamKind)
Create implicit parameter.
llvm::CallSite EmitRuntimeCallOrInvoke(llvm::Value *callee, ArrayRef< llvm::Value * > args, const Twine &name="")
Emits a call or invoke instruction to the given runtime function.
FunctionDecl * getOperatorDelete() const
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.
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="")
const TargetCodeGenInfo & getTargetCodeGenInfo()
const TargetInfo & getTarget() const
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...
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...
QualType getPointeeType() const
If this is a pointer, ObjC object pointer, or block pointer, this returns the respective pointee...
QualType getObjCInterfaceType(const ObjCInterfaceDecl *Decl, ObjCInterfaceDecl *PrevDecl=nullptr) const
getObjCInterfaceType - Return the unique reference to the type for the specified ObjC interface decl...
const CXXRecordDecl * getBase() const
getBase - Returns the base class declaration.
ASTRecordLayout - This class contains layout information for one RecordDecl, which is a struct/union/...
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)
hasAggregateLLVMType - Return true if the specified AST type will map into an aggregate LLVM type or ...
void SetLLVMFunctionAttributes(const Decl *D, const CGFunctionInfo &Info, llvm::Function *F)
Set the LLVM function attributes (sext, zext, etc).
CXXDtorType
C++ destructor types.
llvm::Value * getPointer() const
ValueDecl - Represent the declaration of a variable (in which case it is an lvalue) a function (in wh...
Expr - This represents one expression.
CXXDtorType getDtorType() const
Qualifiers getQualifiers() const
Retrieve all qualifiers.
static llvm::Constant * getBadTypeidFn(CodeGenFunction &CGF)
CGCXXABI & getCXXABI() const
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.
static CGCallee forDirect(llvm::Constant *functionPtr, const CGCalleeInfo &abstractInfo=CGCalleeInfo())
Represents a C++ destructor within a class.
DeclContext * getDeclContext()
CharUnits getBaseClassOffset(const CXXRecordDecl *Base) const
getBaseClassOffset - Get the offset, in chars, for the given base class.
ASTContext & getContext() const
static bool IsIncompleteClassType(const RecordType *RecordTy)
IsIncompleteClassType - Returns whether the given record type is incomplete.
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.
void EmitStoreOfScalar(llvm::Value *Value, Address Addr, bool Volatile, QualType Ty, LValueBaseInfo BaseInfo=LValueBaseInfo(AlignmentSource::Type), llvm::MDNode *TBAAInfo=nullptr, bool isInit=false, QualType TBAABaseTy=QualType(), uint64_t TBAAOffset=0, bool isNontemporal=false)
EmitStoreOfScalar - Store a scalar value to an address, taking care to appropriately convert from the...
bool isInlined() const
Determine whether this function should be inlined, because it is either marked "inline" or "constexpr...
llvm::LLVMContext & getLLVMContext()
CharUnits toCharUnitsFromBits(int64_t BitSize) const
Convert a size in bits to a size in characters.
llvm::IntegerType * Int32Ty
bool isReplaceableGlobalAllocationFunction(bool *IsAligned=nullptr) const
Determines whether this function is one of the replaceable global allocation functions: void *operato...
static llvm::Constant * getGetExceptionPtrFn(CodeGenModule &CGM)
llvm::GlobalValue::LinkageTypes getLLVMLinkageVarDefinition(const VarDecl *VD, bool IsConstant)
Returns LLVM linkage for a declarator.
DeclContext * getParent()
getParent - Returns the containing DeclContext.
LValue MakeNaturalAlignAddrLValue(llvm::Value *V, QualType T)
llvm::GlobalVariable::LinkageTypes getFunctionLinkage(GlobalDecl GD)
llvm::Value * EmitCastToVoidPtr(llvm::Value *value)
Emit a cast to void* in the appropriate address space.
struct clang::ThisAdjustment::VirtualAdjustment::@118 Itanium
Implements C++ ABI-specific semantic analysis functions.
CharUnits getSizeAlign() const
unsigned getNumBases() const
Retrieves the number of base classes of this class.
void EmitCXXGlobalVarDeclInit(const VarDecl &D, llvm::Constant *DeclPtr, bool PerformInit)
EmitCXXGlobalVarDeclInit - Create the initializer for a C++ variable with global storage.
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...
The l-value was considered opaque, so the alignment was determined from a type.
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="")
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...
virtual void mangleCXXRTTIName(QualType T, raw_ostream &)=0
ASTContext & getContext() const
Encodes a location in the source.
CharUnits getPointerAlign() const
IdentifierInfo & get(StringRef Name)
Return the identifier token info for the specified named identifier.
const Type * getTypePtr() const
Retrieves a pointer to the underlying (unqualified) type.
Visibility getVisibility() const
Determine the visibility of this type.
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...
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.
bool isLocalVarDecl() const
isLocalVarDecl - Returns true for local variable declarations other than parameters.
llvm::GlobalVariable * GetAddrOfVTT(const CXXRecordDecl *RD)
GetAddrOfVTT - Get the address of the VTT for the given record decl.
QualType withConst() const
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.
const CodeGenOptions & getCodeGenOpts() const
bool isMemberDataPointer() const
Returns true if the member type (i.e.
const LangOptions & getLangOpts() const
The generic Itanium ABI is the standard ABI of most open-source and Unix-like platforms.
const T * castAs() const
Member-template castAs<specific type>.
All available information about a concrete callee.
int64_t VCallOffsetOffset
The offset (in bytes), relative to the address point, of the virtual call offset. ...
MangleContext & getMangleContext()
Gets the mangle context.
unsigned getAddressSpace() const
Return the address space that this address resides in.
ItaniumVTableContext & getItaniumVTableContext()
Assigning into this object requires a lifetime extension.
bool isVolatileQualified() const
Determine whether this type is volatile-qualified.
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...
bool isDynamicClass() const
CXXCtorType
C++ constructor types.
The WebAssembly ABI is a modified version of the Itanium ABI.
QualType getPointeeType() const
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...
bool isStr(const char(&Str)[StrLen]) const
Return true if this is the identifier for the specified string.
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.
CharUnits getAlignment() const
Return the alignment of this pointer.
This class organizes the cross-function state that is used while generating LLVM code.
llvm::GlobalValue * GetGlobalValue(StringRef Ref)
const Expr * getSubExpr() const
Address getObjectAddress(CodeGenFunction &CGF) const
Returns the address of the object within this declaration.
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. ...
AccessSpecifier getAccessSpecifier() const
Returns the access specifier for this base specifier.
bool isZero() const
isZero - Test whether the quantity equals zero.
CXXDestructorDecl * getDestructor() const
Returns the destructor decl for this class.
void EmitAnyExprToExn(const Expr *E, Address Addr)
llvm::LoadInst * CreateAlignedLoad(llvm::Value *Addr, CharUnits Align, const llvm::Twine &Name="")
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.
QualType getPointerType(QualType T) const
Return the uniqued reference to the type for a pointer to the specified type.
const llvm::Triple & getTriple() const
Returns the target triple of the primary target.
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* ...
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)
CanQualType getCanonicalType(QualType T) const
Return the canonical (structural) type corresponding to the specified potentially non-canonical type ...
void maybeSetTrivialComdat(const Decl &D, llvm::GlobalObject &GO)
union clang::ThisAdjustment::VirtualAdjustment Virtual
void EmitAggExpr(const Expr *E, AggValueSlot AS)
EmitAggExpr - Emit the computation of the specified expression of aggregate type. ...
QualType getNonReferenceType() const
If Type is a reference type (e.g., const int&), returns the type that the reference refers to ("const...
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)
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...
QualType getPointerDiffType() const
Return the unique type for "ptrdiff_t" (C99 7.17) defined in <stddef.h>.
FunctionDecl * getOperatorNew() const
const T * getAs() const
Member-template getAs<specific type>'.
QualType getCanonicalType() const
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.
QualType getFunctionType(QualType ResultTy, ArrayRef< QualType > Args, const FunctionProtoType::ExtProtoInfo &EPI) const
Return a normal function type with a typed argument list.
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
SourceLocation getLocStart() const LLVM_READONLY
CXXRecordDecl * getAsCXXRecordDecl() const
Retrieves the CXXRecordDecl that this type refers to, either because the type is a RecordType or beca...
StringRef getMangledName(GlobalDecl GD)
bool isRestrictQualified() const
Determine whether this type is restrict-qualified.
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.
Linkage getLinkage() const
Determine the linkage of this type.
uint64_t getPointerWidth(unsigned AddrSpace) const
Return the width of pointers on this target, for the specified address space.
static CGCXXABI::RecordArgABI getRecordArgABI(const RecordType *RT, CGCXXABI &CXXABI)
const Decl * CurFuncDecl
CurFuncDecl - Holds the Decl for the current outermost non-closure context.
const Type * getClass() const
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.
BoundNodesTreeBuilder *const Builder
TargetCXXABI getCXXABI() const
Get the C++ ABI currently in use.
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.
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)
LValue MakeAddrLValue(Address Addr, QualType T, LValueBaseInfo BaseInfo=LValueBaseInfo(AlignmentSource::Type))
Address ReturnValue
ReturnValue - The temporary alloca to hold the return value.
bool isInline() const
Whether this variable is (C++1z) inline.
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...
This class is used for builtin types like 'int'.
unsigned getLongWidth() const
getLongWidth/Align - Return the size of 'signed long' and 'unsigned long' for this target...
static llvm::Constant * getItaniumDynamicCastFn(CodeGenFunction &CGF)
Copying closure variant of a ctor.
ObjCInterfaceDecl * getSuperClass() 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.
virtual unsigned getSizeOfUnwindException() const
Determines the size of struct _Unwind_Exception on this platform, in 8-bit units. ...
VarDecl * getExceptionDecl() const
static RValue get(llvm::Value *V)
const llvm::Triple & getTriple() const
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...
CodeGenVTables & getVTables()
static void emitConstructorDestructorAlias(CodeGenModule &CGM, GlobalDecl AliasDecl, GlobalDecl TargetDecl)
SourceLocation getLocation() const
LValue - This represents an lvalue references.
unsigned getNumVBases() const
Retrieves the number of virtual base classes of this class.
Information for lazily generating a cleanup.
static llvm::Constant * getBadCastFn(CodeGenFunction &CGF)
DefinitionKind hasDefinition(ASTContext &) const
Check whether this variable is defined in this translation unit.
Notes how many arguments were added to the beginning (Prefix) and ending (Suffix) of an arg list...
bool isConstQualified() const
Determine whether this type is const-qualified.
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.
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.
bool supportsCOMDAT() const
CanQualType UnsignedIntTy
Qualifiers getQualifiers() const
Retrieve the set of qualifiers applied to this type.
static llvm::Constant * getThrowFn(CodeGenModule &CGM)
llvm::FunctionType * GetFunctionType(const CGFunctionInfo &Info)
GetFunctionType - Get the LLVM function type for.