32 #include "llvm/IR/DataLayout.h"
33 #include "llvm/IR/GlobalVariable.h"
34 #include "llvm/IR/Intrinsics.h"
35 #include "llvm/IR/Type.h"
37 using namespace clang;
38 using namespace CodeGen;
42 case Decl::BuiltinTemplate:
43 case Decl::TranslationUnit:
44 case Decl::ExternCContext:
46 case Decl::UnresolvedUsingTypename:
47 case Decl::ClassTemplateSpecialization:
48 case Decl::ClassTemplatePartialSpecialization:
49 case Decl::VarTemplateSpecialization:
50 case Decl::VarTemplatePartialSpecialization:
51 case Decl::TemplateTypeParm:
52 case Decl::UnresolvedUsingValue:
53 case Decl::NonTypeTemplateParm:
54 case Decl::CXXDeductionGuide:
56 case Decl::CXXConstructor:
57 case Decl::CXXDestructor:
58 case Decl::CXXConversion:
60 case Decl::MSProperty:
61 case Decl::IndirectField:
63 case Decl::ObjCAtDefsField:
65 case Decl::ImplicitParam:
66 case Decl::ClassTemplate:
67 case Decl::VarTemplate:
68 case Decl::FunctionTemplate:
69 case Decl::TypeAliasTemplate:
70 case Decl::TemplateTemplateParm:
71 case Decl::ObjCMethod:
72 case Decl::ObjCCategory:
73 case Decl::ObjCProtocol:
74 case Decl::ObjCInterface:
75 case Decl::ObjCCategoryImpl:
76 case Decl::ObjCImplementation:
77 case Decl::ObjCProperty:
78 case Decl::ObjCCompatibleAlias:
79 case Decl::PragmaComment:
80 case Decl::PragmaDetectMismatch:
81 case Decl::AccessSpec:
82 case Decl::LinkageSpec:
84 case Decl::ObjCPropertyImpl:
85 case Decl::FileScopeAsm:
87 case Decl::FriendTemplate:
90 case Decl::ClassScopeFunctionSpecialization:
91 case Decl::UsingShadow:
92 case Decl::ConstructorUsingShadow:
93 case Decl::ObjCTypeParam:
95 llvm_unreachable(
"Declaration should not be in declstmts!");
99 case Decl::EnumConstant:
100 case Decl::CXXRecord:
101 case Decl::StaticAssert:
104 case Decl::OMPThreadPrivate:
105 case Decl::OMPCapturedExpr:
110 case Decl::NamespaceAlias:
112 DI->EmitNamespaceAlias(cast<NamespaceAliasDecl>(D));
116 DI->EmitUsingDecl(cast<UsingDecl>(D));
118 case Decl::UsingPack:
119 for (
auto *Using : cast<UsingPackDecl>(D).expansions())
122 case Decl::UsingDirective:
124 DI->EmitUsingDirective(cast<UsingDirectiveDecl>(D));
127 case Decl::Decomposition: {
128 const VarDecl &VD = cast<VarDecl>(D);
130 "Should not see file-scope variables inside a function!");
132 if (
auto *DD = dyn_cast<DecompositionDecl>(&VD))
133 for (
auto *B : DD->bindings())
134 if (
auto *HD = B->getHoldingVar())
139 case Decl::OMPDeclareReduction:
143 case Decl::TypeAlias: {
147 if (Ty->isVariablyModifiedType())
164 llvm::GlobalValue::LinkageTypes
Linkage =
187 std::string ContextName;
189 if (
auto *CD = dyn_cast<CapturedDecl>(DC))
190 DC = cast<DeclContext>(CD->getNonClosureContext());
191 if (
const auto *FD = dyn_cast<FunctionDecl>(DC))
193 else if (
const auto *BD = dyn_cast<BlockDecl>(DC))
195 else if (
const auto *OMD = dyn_cast<ObjCMethodDecl>(DC))
196 ContextName = OMD->getSelector().getAsString();
198 llvm_unreachable(
"Unknown context for static var decl");
210 if (llvm::Constant *ExistingGV = StaticLocalDeclMap[&D])
218 if (D.hasAttr<AsmLabelAttr>())
228 llvm::Constant *Init =
nullptr;
232 Init = llvm::UndefValue::get(LTy);
234 llvm::GlobalVariable *GV =
new llvm::GlobalVariable(
236 nullptr, llvm::GlobalVariable::NotThreadLocal, TargetAS);
241 GV->setComdat(TheModule.getOrInsertComdat(GV->getName()));
246 if (D.isExternallyVisible()) {
247 if (D.hasAttr<DLLImportAttr>())
248 GV->setDLLStorageClass(llvm::GlobalVariable::DLLImportStorageClass);
249 else if (D.hasAttr<DLLExportAttr>())
250 GV->setDLLStorageClass(llvm::GlobalVariable::DLLExportStorageClass);
255 llvm::Constant *Addr = GV;
256 if (AS != ExpectedAS) {
258 *
this, GV, AS, ExpectedAS,
259 LTy->getPointerTo(
getContext().getTargetAddressSpace(ExpectedAS)));
266 const Decl *DC = cast<Decl>(D.getDeclContext());
270 if (isa<BlockDecl>(DC) || isa<CapturedDecl>(DC)) {
278 if (
const auto *CD = dyn_cast<CXXConstructorDecl>(DC))
280 else if (
const auto *DD = dyn_cast<CXXDestructorDecl>(DC))
282 else if (
const auto *FD = dyn_cast<FunctionDecl>(DC))
287 assert(isa<ObjCMethodDecl>(DC) &&
"unexpected parent code decl");
307 llvm::GlobalVariable *
309 llvm::GlobalVariable *GV) {
320 GV->setConstant(
false);
331 if (GV->getType()->getElementType() != Init->getType()) {
332 llvm::GlobalVariable *OldGV = GV;
334 GV =
new llvm::GlobalVariable(
CGM.
getModule(), Init->getType(),
336 OldGV->getLinkage(), Init,
"",
338 OldGV->getThreadLocalMode(),
340 GV->setVisibility(OldGV->getVisibility());
341 GV->setComdat(OldGV->getComdat());
347 llvm::Constant *NewPtrForOldDecl =
348 llvm::ConstantExpr::getBitCast(GV, OldGV->getType());
349 OldGV->replaceAllUsesWith(NewPtrForOldDecl);
352 OldGV->eraseFromParent();
356 GV->setInitializer(Init);
369 llvm::GlobalValue::LinkageTypes
Linkage) {
378 setAddrOfLocalVar(&D,
Address(addr, alignment));
389 llvm::GlobalVariable *var =
390 cast<llvm::GlobalVariable>(addr->stripPointerCasts());
399 if (D.
getInit() && !isCudaSharedVar)
407 if (
auto *SA = D.
getAttr<PragmaClangBSSSectionAttr>())
408 var->addAttribute(
"bss-section", SA->getName());
409 if (
auto *SA = D.
getAttr<PragmaClangDataSectionAttr>())
410 var->addAttribute(
"data-section", SA->getName());
411 if (
auto *SA = D.
getAttr<PragmaClangRodataSectionAttr>())
412 var->addAttribute(
"rodata-section", SA->getName());
414 if (
const SectionAttr *SA = D.
getAttr<SectionAttr>())
415 var->setSection(SA->getName());
425 llvm::Constant *castedAddr =
426 llvm::ConstantExpr::getPointerBitCastOrAddrSpaceCast(var, expectedType);
427 if (var != castedAddr)
428 LocalDeclMap.find(&D)->second =
Address(castedAddr, alignment);
446 bool useEHCleanupForArray)
447 : addr(addr), type(type), destroyer(destroyer),
448 useEHCleanupForArray(useEHCleanupForArray) {}
453 bool useEHCleanupForArray;
457 bool useEHCleanupForArray =
458 flags.isForNormalCleanup() && this->useEHCleanupForArray;
465 DestroyNRVOVariable(
Address addr,
468 : Dtor(Dtor), NRVOFlag(NRVOFlag), Loc(addr) {}
476 bool NRVO = flags.isForNormalCleanup() && NRVOFlag;
478 llvm::BasicBlock *SkipDtorBB =
nullptr;
485 CGF.
Builder.CreateCondBr(DidNRVO, SkipDtorBB, RunDtorBB);
510 ExtendGCLifetime(
const VarDecl *var) : Var(*var) {}
524 llvm::Constant *CleanupFn;
528 CallCleanupFunction(llvm::Constant *CleanupFn,
const CGFunctionInfo *Info,
530 : CleanupFn(CleanupFn), FnInfo(*Info), Var(*Var) {}
545 QualType ArgTy = FnInfo.arg_begin()->type;
565 llvm_unreachable(
"present but none");
573 (var.
hasAttr<ObjCPreciseLifetimeAttr>()
597 if (
const Expr *e = dyn_cast<Expr>(s)) {
600 s = e = e->IgnoreParenCasts();
602 if (
const DeclRefExpr *ref = dyn_cast<DeclRefExpr>(e))
603 return (ref->getDecl() == &var);
604 if (
const BlockExpr *be = dyn_cast<BlockExpr>(e)) {
605 const BlockDecl *block = be->getBlockDecl();
606 for (
const auto &
I : block->
captures()) {
607 if (
I.getVariable() == &var)
622 if (!decl)
return false;
623 if (!isa<VarDecl>(decl))
return false;
630 bool needsCast =
false;
637 case CK_BlockPointerToObjCPointerCast:
643 case CK_LValueToRValue: {
686 if (!
SanOpts.
has(SanitizerKind::NullabilityAssign))
697 llvm::Constant *StaticData[] = {
699 llvm::ConstantInt::get(
Int8Ty, 0),
701 EmitCheck({{IsNotNull, SanitizerKind::NullabilityAssign}},
702 SanitizerHandler::TypeMismatch, StaticData, RHS);
706 LValue lvalue,
bool capturedByInit) {
718 init = DIE->getExpr();
724 init = ewc->getSubExpr();
732 bool accessedByInit =
false;
734 accessedByInit = (capturedByInit ||
isAccessedBy(D, init));
735 if (accessedByInit) {
738 if (capturedByInit) {
763 llvm_unreachable(
"present but none");
822 if (isa<llvm::ConstantAggregateZero>(Init) ||
823 isa<llvm::ConstantPointerNull>(Init) ||
824 isa<llvm::UndefValue>(Init))
826 if (isa<llvm::ConstantInt>(Init) || isa<llvm::ConstantFP>(Init) ||
827 isa<llvm::ConstantVector>(Init) || isa<llvm::BlockAddress>(Init) ||
828 isa<llvm::ConstantExpr>(Init))
829 return Init->isNullValue() || NumStores--;
832 if (isa<llvm::ConstantArray>(Init) || isa<llvm::ConstantStruct>(Init)) {
833 for (
unsigned i = 0, e = Init->getNumOperands(); i != e; ++i) {
834 llvm::Constant *Elt = cast<llvm::Constant>(Init->getOperand(i));
841 if (llvm::ConstantDataSequential *CDS =
842 dyn_cast<llvm::ConstantDataSequential>(Init)) {
843 for (
unsigned i = 0, e = CDS->getNumElements(); i != e; ++i) {
844 llvm::Constant *Elt = CDS->getElementAsConstant(i);
860 assert(!Init->isNullValue() && !isa<llvm::UndefValue>(Init) &&
861 "called emitStoresForInitAfterMemset for zero or undef value.");
863 if (isa<llvm::ConstantInt>(Init) || isa<llvm::ConstantFP>(Init) ||
864 isa<llvm::ConstantVector>(Init) || isa<llvm::BlockAddress>(Init) ||
865 isa<llvm::ConstantExpr>(Init)) {
870 if (llvm::ConstantDataSequential *CDS =
871 dyn_cast<llvm::ConstantDataSequential>(Init)) {
872 for (
unsigned i = 0, e = CDS->getNumElements(); i != e; ++i) {
873 llvm::Constant *Elt = CDS->getElementAsConstant(i);
876 if (!Elt->isNullValue() && !isa<llvm::UndefValue>(Elt))
878 Elt, Builder.CreateConstGEP2_32(Init->getType(), Loc, 0, i),
879 isVolatile, Builder);
884 assert((isa<llvm::ConstantStruct>(Init) || isa<llvm::ConstantArray>(Init)) &&
885 "Unknown value type!");
887 for (
unsigned i = 0, e = Init->getNumOperands(); i != e; ++i) {
888 llvm::Constant *Elt = cast<llvm::Constant>(Init->getOperand(i));
891 if (!Elt->isNullValue() && !isa<llvm::UndefValue>(Elt))
893 Elt, Builder.CreateConstGEP2_32(Init->getType(), Loc, 0, i),
894 isVolatile, Builder);
903 uint64_t GlobalSize) {
905 if (isa<llvm::ConstantAggregateZero>(Init))
return true;
911 unsigned StoreBudget = 6;
912 uint64_t SizeLimit = 32;
914 return GlobalSize > SizeLimit &&
932 if (!ShouldEmitLifetimeMarkers)
939 C->setDoesNotThrow();
947 C->setDoesNotThrow();
959 bool isByRef = D.
hasAttr<BlocksAttr>();
960 emission.IsByRef = isByRef;
1000 assert(emission.wasEmittedAsGlobal());
1005 emission.IsConstantAggregate =
true;
1018 if (!cast<CXXRecordDecl>(RecordTy->getDecl())->hasTrivialDestructor()) {
1038 allocaTy = byrefInfo.Type;
1039 allocaAlignment = byrefInfo.ByrefAlignment;
1042 allocaAlignment = alignment;
1053 bool IsMSCatchParam =
1075 emission.SizeForLifetimeMarkers =
1079 assert(!emission.useLifetimeMarkers());
1085 if (!DidCallStackSave) {
1094 DidCallStackSave =
true;
1103 std::tie(elementCount, elementType) =
getVLASize(Ty);
1111 setAddrOfLocalVar(&D, address);
1112 emission.Addr = address;
1124 if (D.
hasAttr<AnnotateAttr>())
1128 if (emission.useLifetimeMarkers())
1130 emission.getAllocatedAddress(),
1131 emission.getSizeForLifetimeMarkers());
1143 if (
const BlockExpr *be = dyn_cast<BlockExpr>(e)) {
1144 const BlockDecl *block = be->getBlockDecl();
1145 for (
const auto &
I : block->
captures()) {
1146 if (
I.getVariable() == &var)
1154 if (
const StmtExpr *SE = dyn_cast<StmtExpr>(e)) {
1156 for (
const auto *BI : CS->
body())
1157 if (
const auto *
E = dyn_cast<Expr>(BI)) {
1161 else if (
const auto *DS = dyn_cast<DeclStmt>(BI)) {
1163 for (
const auto *
I : DS->decls()) {
1164 if (
const auto *VD = dyn_cast<VarDecl>((
I))) {
1165 const Expr *Init = VD->getInit();
1193 if (Constructor->isTrivial() &&
1194 Constructor->isDefaultConstructor() &&
1195 !Construct->requiresZeroInitialization())
1202 assert(emission.Variable &&
"emission was not valid!");
1205 if (emission.wasEmittedAsGlobal())
return;
1207 const VarDecl &D = *emission.Variable;
1222 if (emission.IsByRef)
1231 bool capturedByInit = emission.IsByRef &&
isCapturedBy(D, Init);
1236 llvm::Constant *constant =
nullptr;
1237 if (emission.IsConstantAggregate || D.
isConstexpr()) {
1238 assert(!capturedByInit &&
"constant init contains a capturing block?");
1248 if (!emission.IsConstantAggregate) {
1257 bool isVolatile = type.isVolatileQualified();
1261 getContext().getTypeSizeInChars(type).getQuantity());
1274 if (!constant->isNullValue() && !isa<llvm::UndefValue>(constant)) {
1288 llvm::GlobalVariable *GV =
1289 new llvm::GlobalVariable(
CGM.
getModule(), constant->getType(),
true,
1290 llvm::GlobalValue::PrivateLinkage,
1291 constant,
Name,
nullptr,
1292 llvm::GlobalValue::NotThreadLocal, AS);
1294 GV->setUnnamedAddr(llvm::GlobalValue::UnnamedAddr::Global);
1317 LValue lvalue,
bool capturedByInit) {
1350 llvm_unreachable(
"bad evaluation kind");
1363 const VarDecl *var = emission.Variable;
1371 llvm_unreachable(
"no cleanup for trivially-destructible variable");
1376 if (emission.NRVOFlag) {
1379 EHStack.pushCleanup<DestroyNRVOVariable>(cleanupKind, addr,
1380 dtor, emission.NRVOFlag);
1393 if (!var->
hasAttr<ObjCPreciseLifetimeAttr>())
1406 bool useEHCleanup = (cleanupKind &
EHCleanup);
1407 EHStack.pushCleanup<DestroyObject>(cleanupKind, addr,
type, destroyer,
1412 assert(emission.Variable &&
"emission was not valid!");
1415 if (emission.wasEmittedAsGlobal())
return;
1421 const VarDecl &D = *emission.Variable;
1429 D.
hasAttr<ObjCPreciseLifetimeAttr>()) {
1434 if (
const CleanupAttr *CA = D.
getAttr<CleanupAttr>()) {
1438 assert(F &&
"Could not find function!");
1446 if (emission.IsByRef)
1461 llvm_unreachable(
"Unknown DestructionKind");
1468 assert(dtorKind &&
"cannot push destructor for trivial type");
1478 assert(dtorKind &&
"cannot push destructor for trivial type");
1487 bool useEHCleanupForArray) {
1488 pushFullExprCleanup<DestroyObject>(cleanupKind, addr,
type,
1489 destroyer, useEHCleanupForArray);
1493 EHStack.pushCleanup<CallStackRestore>(
Kind, SPMem);
1498 Destroyer *destroyer,
bool useEHCleanupForArray) {
1500 "performing lifetime extension from within conditional");
1506 EHStack.pushCleanup<DestroyObject>(
1508 destroyer, useEHCleanupForArray);
1512 pushCleanupAfterFullExpr<DestroyObject>(
1513 cleanupKind, addr,
type, destroyer, useEHCleanupForArray);
1528 Destroyer *destroyer,
1529 bool useEHCleanupForArray) {
1532 return destroyer(*
this, addr, type);
1541 bool checkZeroLength =
true;
1544 if (llvm::ConstantInt *constLength = dyn_cast<llvm::ConstantInt>(length)) {
1546 if (constLength->isZero())
return;
1547 checkZeroLength =
false;
1553 checkZeroLength, useEHCleanupForArray);
1570 Destroyer *destroyer,
1571 bool checkZeroLength,
1572 bool useEHCleanup) {
1580 if (checkZeroLength) {
1582 "arraydestroy.isempty");
1583 Builder.CreateCondBr(isEmpty, doneBB, bodyBB);
1587 llvm::BasicBlock *entryBB =
Builder.GetInsertBlock();
1589 llvm::PHINode *elementPast =
1590 Builder.CreatePHI(begin->getType(), 2,
"arraydestroy.elementPast");
1591 elementPast->addIncoming(end, entryBB);
1596 "arraydestroy.element");
1603 destroyer(*
this,
Address(element, elementAlign), elementType);
1610 Builder.CreateCondBr(done, doneBB, bodyBB);
1611 elementPast->addIncoming(element,
Builder.GetInsertBlock());
1624 unsigned arrayDepth = 0;
1627 if (!isa<VariableArrayType>(arrayType))
1629 type = arrayType->getElementType();
1636 begin = CGF.
Builder.CreateInBoundsGEP(begin, gepIndices,
"pad.arraybegin");
1637 end = CGF.
Builder.CreateInBoundsGEP(end, gepIndices,
"pad.arrayend");
1661 : ArrayBegin(arrayBegin), ArrayEnd(arrayEnd),
1662 ElementType(elementType), Destroyer(destroyer),
1663 ElementAlign(elementAlign) {}
1667 ElementType, ElementAlign, Destroyer);
1681 IrregularPartialArrayDestroy(
llvm::Value *arrayBegin,
1686 : ArrayBegin(arrayBegin), ArrayEndPointer(arrayEndPointer),
1687 ElementType(elementType), Destroyer(destroyer),
1688 ElementAlign(elementAlign) {}
1693 ElementType, ElementAlign, Destroyer);
1708 Destroyer *destroyer) {
1709 pushFullExprCleanup<IrregularPartialArrayDestroy>(
EHCleanup,
1710 arrayBegin, arrayEndPointer,
1711 elementType, elementAlign,
1725 Destroyer *destroyer) {
1726 pushFullExprCleanup<RegularPartialArrayDestroy>(
EHCleanup,
1727 arrayBegin, arrayEnd,
1728 elementType, elementAlign,
1734 if (LifetimeStartFn)
1735 return LifetimeStartFn;
1736 LifetimeStartFn = llvm::Intrinsic::getDeclaration(&
getModule(),
1738 return LifetimeStartFn;
1744 return LifetimeEndFn;
1745 LifetimeEndFn = llvm::Intrinsic::getDeclaration(&
getModule(),
1747 return LifetimeEndFn;
1758 : Param(param), Precise(precise) {}
1774 assert((isa<ParmVarDecl>(D) || isa<ImplicitParamDecl>(D)) &&
1775 "Invalid argument to EmitParmDecl");
1782 if (
auto IPD = dyn_cast<ImplicitParamDecl>(&D)) {
1795 if (MD->isVirtual() && IPD == CXXABIThisDecl) {
1800 *
this,
CurGD, This);
1810 bool DoStore =
false;
1816 unsigned AS = DeclPtr.
getType()->getAddressSpace();
1818 if (DeclPtr.
getType() != IRTy)
1847 bool isConsumed = D.
hasAttr<NSConsumedAttr>();
1906 setAddrOfLocalVar(&D, DeclPtr);
1916 if (D.
hasAttr<AnnotateAttr>())
1922 if (requiresReturnValueNullabilityCheck()) {
1926 RetValNullabilityPrecondition =
1927 Builder.CreateAnd(RetValNullabilityPrecondition,
1935 if (!LangOpts.OpenMP || (!LangOpts.EmitAllDecls && !D->
isUsed()))
unsigned getAddressSpace() const
Return the address space of this type.
CGOpenCLRuntime & getOpenCLRuntime()
Return a reference to the configured OpenCL runtime.
ReturnValueSlot - Contains the address where the return value of a function can be stored...
Defines the clang::ASTContext interface.
virtual llvm::Value * adjustThisParameterInVirtualFunctionPrologue(CodeGenFunction &CGF, GlobalDecl GD, llvm::Value *This)
Perform ABI-specific "this" parameter adjustment in a virtual function prologue.
llvm::StoreInst * CreateDefaultAlignedStore(llvm::Value *Val, llvm::Value *Addr, bool IsVolatile=false)
FunctionDecl - An instance of this class is created to represent a function declaration or definition...
StringRef getName() const
getName - Get the name of identifier for this declaration as a StringRef.
void EmitStaticVarDecl(const VarDecl &D, llvm::GlobalValue::LinkageTypes Linkage)
llvm::Value * EmitARCRetainAutoreleaseScalarExpr(const Expr *expr)
Destroyer * getDestroyer(QualType::DestructionKind destructionKind)
A (possibly-)qualified type.
ArrayRef< Capture > captures() const
bool isPODType(const ASTContext &Context) const
Determine whether this is a Plain Old Data (POD) type (C++ 3.9p10).
void EmitExtendGCLifetime(llvm::Value *object)
EmitExtendGCLifetime - Given a pointer to an Objective-C object, make sure it survives garbage collec...
llvm::Value * getPointer() const
CodeGenTypes & getTypes()
llvm::Type * ConvertTypeForMem(QualType T)
void EmitVarDecl(const VarDecl &D)
EmitVarDecl - Emit a local variable declaration.
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)
DestructionKind isDestructedType() const
Returns a nonzero value if objects of this type require non-trivial work to clean up after...
llvm::Constant * EmitCheckTypeDescriptor(QualType T)
Emit a description of a type in a format suitable for passing to a runtime sanitizer handler...
llvm::Module & getModule() const
static AggValueSlot forLValue(const LValue &LV, IsDestructed_t isDestructed, NeedsGCBarriers_t needsGC, IsAliased_t isAliased, IsZeroed_t isZeroed=IsNotZeroed)
Stmt - This represents one statement.
bool isInConditionalBranch() const
isInConditionalBranch - Return true if we're currently emitting one branch or the other of a conditio...
const TargetInfo & getTarget() const
unsigned GetGlobalVarAddressSpace(const VarDecl *D)
Return the AST address space of the underlying global variable for D, as determined by its declaratio...
Defines the SourceManager interface.
static bool canEmitInitWithFewStoresAfterMemset(llvm::Constant *Init, unsigned &NumStores)
canEmitInitWithFewStoresAfterMemset - Decide whether we can emit the non-zero parts of the specified ...
QuantityType getQuantity() const
getQuantity - Get the raw integer representation of this quantity.
bool isRecordType() const
void emitAutoVarTypeCleanup(const AutoVarEmission &emission, QualType::DestructionKind dtorKind)
Enter a destroy cleanup for the given local variable.
QualType getUnderlyingType() const
Decl - This represents one declaration (or definition), e.g.
Address getAddress() const
const Decl * CurCodeDecl
CurCodeDecl - This is the inner-most code context, which includes blocks.
bool hasNonTrivialDestructor() const
Determine whether this class has a non-trivial destructor (C++ [class.dtor]p3)
void EmitAutoVarDecl(const VarDecl &D)
EmitAutoVarDecl - Emit an auto variable declaration.
const llvm::DataLayout & getDataLayout() const
static Destroyer destroyARCStrongPrecise
void pushLifetimeExtendedDestroy(CleanupKind kind, Address addr, QualType type, Destroyer *destroyer, bool useEHCleanupForArray)
void EmitStoreThroughLValue(RValue Src, LValue Dst, bool isInit=false)
EmitStoreThroughLValue - Store the specified rvalue into the specified lvalue, where both are guarant...
Represents an array type, per C99 6.7.5.2 - Array Declarators.
const Expr * getInit() const
Represents a call to a C++ constructor.
void EmitARCCopyWeak(Address dst, Address src)
void @objc_copyWeak(i8** dest, i8** src) Disregards the current value in dest.
const LangOptions & getLangOpts() const
llvm::Value * EmitARCRetainNonBlock(llvm::Value *value)
Retain the given object, with normal retain semantics.
llvm::IntegerType * Int8Ty
i8, i16, i32, and i64
Represents a C++ constructor within a class.
static Destroyer destroyARCWeak
VarDecl - An instance of this class is created to represent a variable declaration or definition...
llvm::Type * getElementType() const
Return the type of the values stored in this address.
RAII object to set/unset CodeGenFunction::IsSanitizerScope.
bool areArgsDestroyedLeftToRightInCallee() const
Are arguments to a call destroyed left to right in the callee? This is a fundamental language change...
ObjCLifetime getObjCLifetime() const
This class gathers all debug information during compilation and is responsible for emitting to llvm g...
ObjCMethodDecl - Represents an instance or class method declaration.
void EmitVariablyModifiedType(QualType Ty)
EmitVLASize - Capture all the sizes for the VLA expressions in the given variably-modified type and s...
llvm::Type * ConvertTypeForMem(QualType T)
ConvertTypeForMem - Convert type T into a llvm::Type.
Represents an expression – generally a full-expression – that introduces cleanups to be run at the en...
Linkage
Describes the different kinds of linkage (C++ [basic.link], C99 6.2.2) that an entity may have...
The collection of all-type qualifiers we support.
void emitDestroy(Address addr, QualType type, Destroyer *destroyer, bool useEHCleanupForArray)
emitDestroy - Immediately perform the destruction of the given object.
void emitByrefStructureInit(const AutoVarEmission &emission)
Initialize the structural components of a __block variable, i.e.
void EmitCheck(ArrayRef< std::pair< llvm::Value *, SanitizerMask >> Checked, SanitizerHandler Check, ArrayRef< llvm::Constant * > StaticArgs, ArrayRef< llvm::Value * > DynamicArgs)
Create a basic block that will call a handler function in a sanitizer runtime with the provided argum...
CGDebugInfo * getDebugInfo()
CodeGenFunction - This class organizes the per-function state that is used while generating LLVM code...
bool isVariablyModifiedType() const
Whether this type is a variably-modified type (C99 6.7.5).
void EmitExprAsInit(const Expr *init, const ValueDecl *D, LValue lvalue, bool capturedByInit)
EmitExprAsInit - Emits the code necessary to initialize a location in memory with the given initializ...
llvm::IntegerType * Int64Ty
RValue EmitReferenceBindingToExpr(const Expr *E)
Emits a reference binding to the passed in expression.
bool isReferenceType() const
llvm::IntegerType * SizeTy
const internal::VariadicAllOfMatcher< Decl > decl
Matches declarations.
void pushEHDestroy(QualType::DestructionKind dtorKind, Address addr, QualType type)
pushEHDestroy - Push the standard destructor for the given type as an EH-only cleanup.
Denotes a cleanup that should run when a scope is exited using exceptional control flow (a throw stat...
CleanupKind getCleanupKind(QualType::DestructionKind kind)
const Decl * getDecl() const
bool hasExternalStorage() const
Returns true if a variable has extern or private_extern storage.
void setNonGC(bool Value)
llvm::Constant * getLLVMLifetimeStartFn()
Lazily declare the .lifetime.start intrinsic.
llvm::Value * EmitARCStoreStrongCall(Address addr, llvm::Value *value, bool resultIgnored)
Store into a strong object.
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...
void pushRegularPartialArrayCleanup(llvm::Value *arrayBegin, llvm::Value *arrayEnd, QualType elementType, CharUnits elementAlignment, Destroyer *destroyer)
pushRegularPartialArrayCleanup - Push an EH cleanup to destroy already-constructed elements of the gi...
static bool hasScalarEvaluationKind(QualType T)
static void drillIntoBlockVariable(CodeGenFunction &CGF, LValue &lvalue, const VarDecl *var)
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.
static bool shouldUseMemSetPlusStoresToInitialize(llvm::Constant *Init, uint64_t GlobalSize)
shouldUseMemSetPlusStoresToInitialize - Decide whether we should use memset plus some stores to initi...
Qualifiers::ObjCLifetime getObjCLifetime() const
ObjCMethodFamily getMethodFamily() const
Determines the family of this method.
void EmitOMPDeclareReduction(const OMPDeclareReductionDecl *D, CodeGenFunction *CGF=nullptr)
Emit a code for declare reduction construct.
An x-value expression is a reference to an object with independent storage but which can be "moved"...
void EmitGlobalVariable(llvm::GlobalVariable *GV, const VarDecl *Decl)
Emit information about a global variable.
void setStaticLocalDeclAddress(const VarDecl *D, llvm::Constant *C)
const ArrayType * getAsArrayType(QualType T) const
Type Query functions.
bool needsEHCleanup(QualType::DestructionKind kind)
Determines whether an EH cleanup is required to destroy a type with the given destruction kind...
llvm::Value * EmitARCUnsafeUnretainedScalarExpr(const Expr *expr)
EmitARCUnsafeUnretainedScalarExpr - Semantically equivalent to immediately releasing the resut of Emi...
bool IsBypassed(const VarDecl *D) const
Returns true if the variable declaration was by bypassed by any goto or switch statement.
llvm::CallInst * CreateMemCpy(Address Dest, Address Src, llvm::Value *Size, bool IsVolatile=false)
std::string getNameAsString() const
getNameAsString - Get a human-readable name for the declaration, even if it is one of the special kin...
Expr * IgnoreParenCasts() LLVM_READONLY
IgnoreParenCasts - Ignore parentheses and casts.
Values of this type can never be null.
Scope - A scope is a transient data structure that is used while parsing the program.
llvm::BasicBlock * createBasicBlock(const Twine &name="", llvm::Function *parent=nullptr, llvm::BasicBlock *before=nullptr)
createBasicBlock - Create an LLVM basic block.
llvm::Value * EmitARCRetainScalarExpr(const Expr *expr)
EmitARCRetainScalarExpr - Semantically equivalent to EmitARCRetainObject(e->getType(), EmitScalarExpr(e)), but making a best-effort attempt to peephole expressions that naturally produce retained objects.
Denotes a cleanup that should run when a scope is exited using normal control flow (falling off the e...
void EmitAtomicInit(Expr *E, LValue lvalue)
GlobalDecl CurGD
CurGD - The GlobalDecl for the current function being compiled.
static bool ContainsLabel(const Stmt *S, bool IgnoreCaseStmts=false)
ContainsLabel - Return true if the statement contains a label in it.
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...
void setGlobalVisibility(llvm::GlobalValue *GV, const NamedDecl *D) const
Set the visibility for the given LLVM GlobalValue.
detail::InMemoryDirectory::const_iterator I
This object can be modified without requiring retains or releases.
bool isTypeConstant(QualType QTy, bool ExcludeCtorDtor)
isTypeConstant - Determine whether an object of this type can be emitted as a constant.
static CharUnits One()
One - Construct a CharUnits quantity of one.
CompoundStmt - This represents a group of statements like { stmt stmt }.
std::pair< llvm::Value *, llvm::Value * > ComplexPairTy
AutoVarEmission EmitAutoVarAlloca(const VarDecl &var)
EmitAutoVarAlloca - Emit the alloca and debug information for a local variable.
const CodeGen::CGBlockInfo * BlockInfo
const TargetCodeGenInfo & getTargetCodeGenInfo()
Qualifiers::ObjCLifetime getObjCLifetime() const
Returns lifetime attribute of this type.
RValue - This trivial value class is used to represent the result of an expression that is evaluated...
void setAddress(Address address)
CleanupKind getARCCleanupKind()
Retrieves the default cleanup kind for an ARC cleanup.
StringRef getBlockMangledName(GlobalDecl GD, const BlockDecl *BD)
std::vector< bool > & Stack
llvm::Constant * getNullPointer(llvm::PointerType *T, QualType QT)
Get target specific null pointer.
llvm::Value * EmitARCStoreWeak(Address addr, llvm::Value *value, bool ignored)
i8* @objc_storeWeak(i8** addr, i8* value) Returns value.
void EmitCXXGuardedInit(const VarDecl &D, llvm::GlobalVariable *DeclPtr, bool PerformInit)
Emit code in this function to perform a guarded variable initialization.
static TypeEvaluationKind getEvaluationKind(QualType T)
hasAggregateLLVMType - Return true if the specified AST type will map into an aggregate LLVM type or ...
llvm::Value * getPointer() const
bool isMicrosoft() const
Is this ABI an MSVC-compatible ABI?
BlockDecl - This represents a block literal declaration, which is like an unnamed FunctionDecl...
ValueDecl - Represent the declaration of a variable (in which case it is an lvalue) a function (in wh...
Expr - This represents one expression.
void EmitARCMoveWeak(Address dst, Address src)
void @objc_moveWeak(i8** dest, i8** src) Disregards the current value in dest.
Emit only debug info necessary for generating line number tables (-gline-tables-only).
void EmitAutoVarInit(const AutoVarEmission &emission)
CGCXXABI & getCXXABI() const
void AddGlobalAnnotations(const ValueDecl *D, llvm::GlobalValue *GV)
Add global annotations that are set on D, for the global GV.
Enters a new scope for capturing cleanups, all of which will be executed once the scope is exited...
static CGCallee forDirect(llvm::Constant *functionPtr, const CGCalleeInfo &abstractInfo=CGCalleeInfo())
bool isAtomicType() const
virtual void EmitWorkGroupLocalVarDecl(CodeGenFunction &CGF, const VarDecl &D)
Emit the IR required for a work-group-local variable declaration, and add an entry to CGF's LocalDecl...
BlockExpr - Adaptor class for mixing a BlockDecl with expressions.
Represents a C++ destructor within a class.
DeclContext * getDeclContext()
ASTContext & getContext() const
llvm::Value * getAnyValue() const
ImplicitParamDecl * getSelfDecl() const
void add(RValue rvalue, QualType type, bool needscopy=false)
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...
llvm::LLVMContext & getLLVMContext()
void EmitNullabilityCheck(LValue LHS, llvm::Value *RHS, SourceLocation Loc)
Given an assignment *LHS = RHS, emit a test that checks if RHS is nonnull, if LHS is marked _Nonnull...
llvm::GlobalValue::LinkageTypes getLLVMLinkageVarDefinition(const VarDecl *VD, bool IsConstant)
Returns LLVM linkage for a declarator.
Checking the value assigned to a _Nonnull pointer. Must not be null.
bool isExceptionVariable() const
Determine whether this variable is the exception variable in a C++ catch statememt or an Objective-C ...
llvm::PointerType * AllocaInt8PtrTy
bool isExternallyVisible() const
llvm::CallInst * CreateMemSet(Address Dest, llvm::Value *Value, llvm::Value *Size, bool IsVolatile=false)
llvm::Function * getIntrinsic(unsigned IID, ArrayRef< llvm::Type * > Tys=None)
void emitArrayDestroy(llvm::Value *begin, llvm::Value *end, QualType elementType, CharUnits elementAlign, Destroyer *destroyer, bool checkZeroLength, bool useEHCleanup)
emitArrayDestroy - Destroys all the elements of the given array, beginning from last to first...
static bool hasNontrivialDestruction(QualType T)
hasNontrivialDestruction - Determine whether a type's destruction is non-trivial. ...
float __ovld __cnfn length(float p)
Return the length of vector p, i.e., sqrt(p.x2 + p.y 2 + ...)
static bool isCapturedBy(const VarDecl &var, const Expr *e)
Determines whether the given __block variable is potentially captured by the given expression...
GlobalDecl - represents a global declaration.
VarBypassDetector Bypasses
The l-value was considered opaque, so the alignment was determined from a type.
void setBlockContextParameter(const ImplicitParamDecl *D, unsigned argNum, llvm::Value *ptr)
void enterByrefCleanup(const AutoVarEmission &emission)
Enter a cleanup to destroy a __block variable.
llvm::Constant * getOrCreateStaticVarDecl(const VarDecl &D, llvm::GlobalValue::LinkageTypes Linkage)
There is no lifetime qualification on this type.
bool HaveInsertPoint() const
HaveInsertPoint - True if an insertion point is defined.
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...
llvm::GlobalVariable * AddInitializerToStaticVarDecl(const VarDecl &D, llvm::GlobalVariable *GV)
AddInitializerToStaticVarDecl - Add the initializer for 'D' to the global variable that has already b...
ASTContext & getContext() const
void pushDestroy(QualType::DestructionKind dtorKind, Address addr, QualType type)
pushDestroy - Push the standard destructor for the given type as at least a normal cleanup...
Encodes a location in the source.
CharUnits getPointerAlign() const
void EnsureInsertPoint()
EnsureInsertPoint - Ensure that an insertion point is defined so that emitted IR has a place to go...
void EmitARCRelease(llvm::Value *value, ARCPreciseLifetime_t precise)
Release the given object.
LValue EmitDeclRefLValue(const DeclRefExpr *E)
This represents '#pragma omp declare reduction ...' directive.
bool isConstant(const ASTContext &Ctx) const
static std::string getStaticDeclName(CodeGenModule &CGM, const VarDecl &D)
bool isConstantSizeType() const
Return true if this is not a variable sized type, according to the rules of C99 6.7.5p3.
bool isLocalVarDecl() const
isLocalVarDecl - Returns true for local variable declarations other than parameters.
static void emitPartialArrayDestroy(CodeGenFunction &CGF, llvm::Value *begin, llvm::Value *end, QualType type, CharUnits elementAlign, CodeGenFunction::Destroyer *destroyer)
Perform partial array destruction as if in an EH cleanup.
const BlockByrefInfo & getBlockByrefInfo(const VarDecl *var)
BuildByrefInfo - This routine changes a __block variable declared as T x into:
llvm::Value * EmitLifetimeStart(uint64_t Size, llvm::Value *Addr)
Emit a lifetime.begin marker if some criteria are satisfied.
Represents a static or instance method of a struct/union/class.
static bool isAccessedBy(const VarDecl &var, const Stmt *s)
SanitizerSet SanOpts
Sanitizers enabled for this function.
This file defines OpenMP nodes for declarative directives.
bool isTrivialInitializer(const Expr *Init)
Determine whether the given initializer is trivial in the sense that it requires no code to be genera...
CharUnits alignmentOfArrayElement(CharUnits elementSize) const
Given that this is the alignment of the first element of an array, return the minimum alignment of an...
const CodeGenOptions & getCodeGenOpts() const
const Type * getBaseElementTypeUnsafe() const
Get the base element type of this type, potentially discarding type qualifiers.
const LangOptions & getLangOpts() const
static void EmitAutoVarWithLifetime(CodeGenFunction &CGF, const VarDecl &var, Address addr, Qualifiers::ObjCLifetime lifetime)
EmitAutoVarWithLifetime - Does the setup required for an automatic variable with lifetime.
void EmitParmDecl(const VarDecl &D, ParamValue Arg, unsigned ArgNo)
EmitParmDecl - Emit a ParmVarDecl or an ImplicitParamDecl.
Assigning into this object requires a lifetime extension.
StmtExpr - This is the GNU Statement Expression extension: ({int X=4; X;}).
static ParamValue forDirect(llvm::Value *value)
llvm::Constant * getLLVMLifetimeEndFn()
Lazily declare the .lifetime.end intrinsic.
void enterFullExpression(const ExprWithCleanups *E)
void EmitDecl(const Decl &D)
EmitDecl - Emit a declaration.
static Destroyer destroyARCStrongImprecise
SourceLocation getExprLoc() const LLVM_READONLY
getExprLoc - Return the preferred location for the arrow when diagnosing a problem with a generic exp...
llvm::Constant * GetAddrOfGlobal(GlobalDecl GD, ForDefinition_t IsForDefinition=NotForDefinition)
llvm::Value * EmitScalarExpr(const Expr *E, bool IgnoreResultAssign=false)
EmitScalarExpr - Emit the computation of the specified expression of LLVM scalar type, returning the result.
void addUsedGlobal(llvm::GlobalValue *GV)
Add a global to a list to be added to the llvm.used metadata.
Base class for declarations which introduce a typedef-name.
void ErrorUnsupported(const Stmt *S, const char *Type)
Print out an error that codegen doesn't support the specified stmt yet.
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.
CGOpenMPRuntime & getOpenMPRuntime()
Return a reference to the configured OpenMP runtime.
static ApplyDebugLocation CreateDefaultArtificial(CodeGenFunction &CGF, SourceLocation TemporaryLocation)
Apply TemporaryLocation if it is valid.
Address getObjectAddress(CodeGenFunction &CGF) const
Returns the address of the object within this declaration.
void EmitCXXDestructorCall(const CXXDestructorDecl *D, CXXDtorType Type, bool ForVirtualBase, bool Delegating, Address This)
DeclContext - This is used only as base class of specific decl types that can act as declaration cont...
llvm::Value * getDirectValue() const
CXXDestructorDecl * getDestructor() const
Returns the destructor decl for this class.
const internal::VariadicAllOfMatcher< Type > type
Matches Types in the clang AST.
const CGFunctionInfo & arrangeFunctionDeclaration(const FunctionDecl *FD)
Free functions are functions that are compatible with an ordinary C function pointer type...
void setTLSMode(llvm::GlobalValue *GV, const VarDecl &D) const
Set the TLS mode for the given LLVM GlobalValue for the thread-local variable declaration D...
llvm::LoadInst * CreateLoad(Address Addr, const llvm::Twine &Name="")
llvm::IntegerType * IntPtrTy
QualType getPointerType(QualType T) const
Return the uniqued reference to the type for a pointer to the specified type.
bool isUsed(bool CheckUsedAttr=true) const
Whether any (re-)declaration of the entity was used, meaning that a definition is required...
Decl * getNonClosureContext()
Find the innermost non-closure ancestor of this declaration, walking up through blocks, lambdas, etc.
Address getIndirectAddress() const
llvm::Constant * EmitNullConstant(QualType T)
Return the result of value-initializing the given type, i.e.
detail::InMemoryDirectory::const_iterator E
llvm::StoreInst * CreateStore(llvm::Value *Val, Address Addr, bool IsVolatile=false)
static bool tryEmitARCCopyWeakInit(CodeGenFunction &CGF, const LValue &destLV, const Expr *init)
void EmitAggExpr(const Expr *E, AggValueSlot AS)
EmitAggExpr - Emit the computation of the specified expression of aggregate type. ...
bool isConstantInitializer(ASTContext &Ctx, bool ForRef, const Expr **Culprit=nullptr) const
isConstantInitializer - Returns true if this expression can be emitted to IR as a constant...
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...
const T * getAs() const
Member-template getAs<specific type>'.
void EmitStoreOfComplex(ComplexPairTy V, LValue dest, bool isInit)
EmitStoreOfComplex - Store a complex number into the specified l-value.
llvm::PointerType * Int8PtrTy
llvm::LoadInst * CreateFlagLoad(llvm::Value *Addr, const llvm::Twine &Name="")
Emit a load from an i1 flag variable.
bool has(SanitizerMask K) const
Check if a certain (single) sanitizer is enabled.
void EmitScalarInit(const Expr *init, const ValueDecl *D, LValue lvalue, bool capturedByInit)
llvm::Constant * GetAddrOfFunction(GlobalDecl GD, llvm::Type *Ty=nullptr, bool ForVTable=false, bool DontDefer=false, ForDefinition_t IsForDefinition=NotForDefinition)
Return the address of the given function.
bool isNRVOVariable() const
Determine whether this local variable can be used with the named return value optimization (NRVO)...
CXXRecordDecl * getAsCXXRecordDecl() const
Retrieves the CXXRecordDecl that this type refers to, either because the type is a RecordType or beca...
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.
ARCPreciseLifetime_t
Does an ARC strong l-value have precise lifetime?
ComplexPairTy EmitComplexExpr(const Expr *E, bool IgnoreReal=false, bool IgnoreImag=false)
EmitComplexExpr - Emit the computation of the specified expression of complex type, returning the result.
llvm::Constant * EmitConstantInit(const VarDecl &D, CodeGenFunction *CGF=nullptr)
Try to emit the initializer for the given declaration as a constant; returns 0 if the expression cann...
A use of a default initializer in a constructor or in aggregate initialization.
Reading or writing from this object requires a barrier call.
const internal::VariadicDynCastAllOfMatcher< Stmt, CastExpr > castExpr
Matches any cast nodes of Clang's AST.
virtual llvm::Value * performAddrSpaceCast(CodeGen::CodeGenFunction &CGF, llvm::Value *V, unsigned SrcAddr, unsigned DestAddr, llvm::Type *DestTy, bool IsNonNull=false) const
Perform address space cast of an expression of pointer type.
llvm::DenseMap< const VarDecl *, llvm::Value * > NRVOFlags
A mapping from NRVO variables to the flags used to indicate when the NRVO has been applied to this va...
static void emitStoresForInitAfterMemset(llvm::Constant *Init, llvm::Value *Loc, bool isVolatile, CGBuilderTy &Builder)
emitStoresForInitAfterMemset - For inits that canEmitInitWithFewStoresAfterMemset returned true for...
bool isARCPseudoStrong() const
Determine whether this variable is an ARC pseudo-__strong variable.
Represents a C++ struct/union/class.
BoundNodesTreeBuilder *const Builder
TargetCXXABI getCXXABI() const
Get the C++ ABI currently in use.
bool isObjCObjectPointerType() const
llvm::Type * ConvertType(QualType T)
static Destroyer destroyCXXObject
LValue MakeAddrLValue(Address Addr, QualType T, LValueBaseInfo BaseInfo=LValueBaseInfo(AlignmentSource::Type))
LValue EmitLValue(const Expr *E)
EmitLValue - Emit code to compute a designator that specifies the location of the expression...
Address ReturnValue
ReturnValue - The temporary alloca to hold the return value.
void pushStackRestore(CleanupKind kind, Address SPMem)
bool isConstexpr() const
Whether this variable is (C++11) constexpr.
unsigned kind
All of the diagnostics that can be emitted by the frontend.
std::pair< llvm::Value *, QualType > getVLASize(const VariableArrayType *vla)
getVLASize - Returns an LLVM value that corresponds to the size, in non-variably-sized elements...
Defines the clang::TargetInfo interface.
void setLocation(SourceLocation Loc)
Update the current source location.
unsigned getTargetAddressSpace(QualType T) const
A reference to a declared variable, function, enum, etc.
ExprValueKind getValueKind() const
getValueKind - The value kind that this expression produces.
static RValue get(llvm::Value *V)
void EmitLifetimeEnd(llvm::Value *Size, llvm::Value *Addr)
llvm::Constant * EmitCheckSourceLocation(SourceLocation Loc)
Emit a description of a source location in a format suitable for passing to a runtime sanitizer handl...
An l-value expression is a reference to an object with independent storage.
SourceLocation getLocation() const
LValue - This represents an lvalue references.
Information for lazily generating a cleanup.
void EmitVarAnnotations(const VarDecl *D, llvm::Value *V)
Emit local annotations for the local variable V, declared by D.
Automatic storage duration (most local variables).
SanitizerMetadata * getSanitizerMetadata()
bool CurFuncIsThunk
In C++, whether we are code generating a thunk.
llvm::Value * emitArrayLength(const ArrayType *arrayType, QualType &baseType, Address &addr)
emitArrayLength - Compute the length of an array, even if it's a VLA, and drill down to the base elem...
StorageDuration getStorageDuration() const
Get the storage duration of this variable, per C++ [basic.stc].
Optional< NullabilityKind > getNullability(const ASTContext &context) const
Determine the nullability of the given type.
CallArgList - Type for representing both the value and type of arguments in a call.
Address CreateMemTemp(QualType T, const Twine &Name="tmp", bool CastToDefaultAddrSpace=true)
CreateMemTemp - Create a temporary memory object of the given type, with appropriate alignment...
void PopCleanupBlock(bool FallThroughIsBranchThrough=false)
PopCleanupBlock - Will pop the cleanup entry on the stack and process all branch fixups.
QualType getBaseElementType(const ArrayType *VAT) const
Return the innermost element type of an array type.
Address emitBlockByrefAddress(Address baseAddr, const VarDecl *V, bool followForward=true)
BuildBlockByrefAddress - Computes the location of the data in a variable which is declared as __block...
void pushIrregularPartialArrayCleanup(llvm::Value *arrayBegin, Address arrayEndPointer, QualType elementType, CharUnits elementAlignment, Destroyer *destroyer)
pushIrregularPartialArrayCleanup - Push an EH cleanup to destroy already-constructed elements of the ...
bool supportsCOMDAT() const
RValue EmitCall(const CGFunctionInfo &CallInfo, const CGCallee &Callee, ReturnValueSlot ReturnValue, const CallArgList &Args, llvm::Instruction **callOrInvoke=nullptr)
EmitCall - Generate a call of the given function, expecting the given result type, and using the given argument list which specifies both the LLVM arguments and the types they were derived from.
bool hasLocalStorage() const
hasLocalStorage - Returns true if a variable with function scope is a non-static local variable...
Expr * IgnoreParens() LLVM_READONLY
IgnoreParens - Ignore parentheses.
bool hasLabelBeenSeenInCurrentScope() const
Return true if a label was seen in the current scope.
Qualifiers getQualifiers() const
Retrieve the set of qualifiers applied to this type.
void Destroyer(CodeGenFunction &CGF, Address addr, QualType ty)
static CharUnits getDeclAlign(Expr *E, CharUnits TypeAlign, ASTContext &Context)
A helper function to get the alignment of a Decl referred to by DeclRefExpr or MemberExpr.