33 #include "llvm/IR/DataLayout.h"
34 #include "llvm/IR/Intrinsics.h"
35 #include "llvm/IR/MDBuilder.h"
36 #include "llvm/IR/Operator.h"
37 using namespace clang;
38 using namespace CodeGen;
40 CodeGenFunction::CodeGenFunction(
CodeGenModule &cgm,
bool suppressNewContext)
42 Builder(cgm, cgm.getModule().getContext(), llvm::ConstantFolder(),
44 CurFn(nullptr), ReturnValue(
Address::invalid()),
45 CapturedStmtInfo(nullptr),
46 SanOpts(CGM.getLangOpts().Sanitize), IsSanitizerScope(
false),
48 IsOutlinedSEHHelper(
false),
49 BlockInfo(nullptr), BlockPointer(nullptr),
50 LambdaThisCaptureField(nullptr), NormalCleanupDest(nullptr),
51 NextCleanupDestIndex(1), FirstBlockInfo(nullptr), EHResumeBlock(nullptr),
52 ExceptionSlot(nullptr), EHSelectorSlot(nullptr),
53 DebugInfo(CGM.getModuleDebugInfo()),
54 DisableDebugInfo(
false), DidCallStackSave(
false), IndirectBranch(nullptr),
55 PGO(cgm), SwitchInsn(nullptr), SwitchWeights(nullptr),
56 CaseRangeBlock(nullptr), UnreachableBlock(nullptr), NumReturnExprs(0),
57 NumSimpleReturnExprs(0), CXXABIThisDecl(nullptr),
58 CXXABIThisValue(nullptr), CXXThisValue(nullptr),
59 CXXStructorImplicitParamDecl(nullptr),
60 CXXStructorImplicitParamValue(nullptr), OutermostConditional(nullptr),
61 CurLexicalScope(nullptr), TerminateLandingPad(nullptr),
62 TerminateHandler(nullptr), TrapBB(nullptr) {
63 if (!suppressNewContext)
66 llvm::FastMathFlags FMF;
68 FMF.setUnsafeAlgebra();
77 FMF.setNoSignedZeros();
80 FMF.setAllowReciprocal();
107 bool forPointeeType) {
112 if (
auto Align = TT->getDecl()->getMaxAlignment()) {
136 if (
unsigned MaxAlign =
getLangOpts().MaxTypeAlign) {
174 #define TYPE(name, parent)
175 #define ABSTRACT_TYPE(name, parent)
176 #define NON_CANONICAL_TYPE(name, parent) case Type::name:
177 #define DEPENDENT_TYPE(name, parent) case Type::name:
178 #define NON_CANONICAL_UNLESS_DEPENDENT_TYPE(name, parent) case Type::name:
179 #include "clang/AST/TypeNodes.def"
180 llvm_unreachable(
"non-canonical or dependent type in IR-generation");
183 llvm_unreachable(
"undeduced auto type in IR-generation");
188 case Type::BlockPointer:
189 case Type::LValueReference:
190 case Type::RValueReference:
191 case Type::MemberPointer:
193 case Type::ExtVector:
194 case Type::FunctionProto:
195 case Type::FunctionNoProto:
197 case Type::ObjCObjectPointer:
206 case Type::ConstantArray:
207 case Type::IncompleteArray:
208 case Type::VariableArray:
210 case Type::ObjCObject:
211 case Type::ObjCInterface:
216 type = cast<AtomicType>(
type)->getValueType();
219 llvm_unreachable(
"unknown type kind!");
226 llvm::BasicBlock *CurBB =
Builder.GetInsertBlock();
229 assert(!CurBB->getTerminator() &&
"Unexpected terminated block.");
238 return llvm::DebugLoc();
245 llvm::BranchInst *BI =
247 if (BI && BI->isUnconditional() &&
251 llvm::DebugLoc Loc = BI->getDebugLoc();
252 Builder.SetInsertPoint(BI->getParent());
253 BI->eraseFromParent();
264 return llvm::DebugLoc();
269 if (!BB->use_empty())
270 return CGF.
CurFn->getBasicBlockList().push_back(BB);
275 assert(BreakContinueStack.empty() &&
276 "mismatched push/pop in break/continue stack!");
278 bool OnlySimpleReturnStmts = NumSimpleReturnExprs > 0
279 && NumSimpleReturnExprs == NumReturnExprs
294 if (OnlySimpleReturnStmts)
295 DI->EmitLocation(
Builder, LastStopPoint);
297 DI->EmitLocation(
Builder, EndLoc);
305 bool HasOnlyLifetimeMarkers =
307 bool EmitRetDbgLoc = !HasCleanups || HasOnlyLifetimeMarkers;
312 if (OnlySimpleReturnStmts)
313 DI->EmitLocation(
Builder, EndLoc);
335 "did not remove all scopes from cleanup stack!");
339 if (IndirectBranch) {
346 if (!EscapedLocals.empty()) {
350 EscapeArgs.resize(EscapedLocals.size());
351 for (
auto &Pair : EscapedLocals)
352 EscapeArgs[Pair.second] = Pair.first;
353 llvm::Function *FrameEscapeFn = llvm::Intrinsic::getDeclaration(
361 Ptr->eraseFromParent();
365 if (IndirectBranch) {
366 llvm::PHINode *PN = cast<llvm::PHINode>(IndirectBranch->getAddress());
367 if (PN->getNumIncomingValues() == 0) {
368 PN->replaceAllUsesWith(llvm::UndefValue::get(PN->getType()));
369 PN->eraseFromParent();
382 I = DeferredReplacements.begin(),
383 E = DeferredReplacements.end();
385 I->first->replaceAllUsesWith(
I->second);
386 I->first->eraseFromParent();
405 llvm::PointerType *PointerTy =
Int8PtrTy;
406 llvm::Type *ProfileFuncArgs[] = { PointerTy, PointerTy };
407 llvm::FunctionType *FunctionTy =
408 llvm::FunctionType::get(
VoidTy, ProfileFuncArgs,
false);
411 llvm::CallInst *CallSite =
Builder.CreateCall(
413 llvm::ConstantInt::get(
Int32Ty, 0),
417 llvm::ConstantExpr::getBitCast(
CurFn, PointerTy),
425 llvm::FunctionType *FTy = llvm::FunctionType::get(
VoidTy,
false);
427 llvm::Constant *MCountFn =
447 addressQuals.push_back(llvm::MDString::get(Context,
"kernel_arg_addr_space"));
451 accessQuals.push_back(llvm::MDString::get(Context,
"kernel_arg_access_qual"));
455 argTypeNames.push_back(llvm::MDString::get(Context,
"kernel_arg_type"));
459 argBaseTypeNames.push_back(
460 llvm::MDString::get(Context,
"kernel_arg_base_type"));
464 argTypeQuals.push_back(llvm::MDString::get(Context,
"kernel_arg_type_qual"));
468 argNames.push_back(llvm::MDString::get(Context,
"kernel_arg_name"));
470 for (
unsigned i = 0, e = FD->
getNumParams(); i != e; ++i) {
473 std::string typeQuals;
479 addressQuals.push_back(llvm::ConstantAsMetadata::get(Builder.getInt32(
483 std::string typeName =
487 std::string::size_type pos = typeName.find(
"unsigned");
488 if (pointeeTy.
isCanonical() && pos != std::string::npos)
489 typeName.erase(pos+1, 8);
491 argTypeNames.push_back(llvm::MDString::get(Context, typeName));
493 std::string baseTypeName =
499 pos = baseTypeName.find(
"unsigned");
500 if (pos != std::string::npos)
501 baseTypeName.erase(pos+1, 8);
503 argBaseTypeNames.push_back(llvm::MDString::get(Context, baseTypeName));
507 typeQuals =
"restrict";
510 typeQuals += typeQuals.empty() ?
"const" :
" const";
512 typeQuals += typeQuals.empty() ?
"volatile" :
" volatile";
514 uint32_t AddrSpc = 0;
520 addressQuals.push_back(
521 llvm::ConstantAsMetadata::get(Builder.getInt32(AddrSpc)));
524 std::string typeName;
526 typeName = cast<PipeType>(ty)->
getElementType().getAsString(Policy);
531 std::string::size_type pos = typeName.find(
"unsigned");
533 typeName.erase(pos+1, 8);
535 argTypeNames.push_back(llvm::MDString::get(Context, typeName));
537 std::string baseTypeName;
540 cast<PipeType>(ty)->
getElementType().getCanonicalType().getAsString(Policy);
546 pos = baseTypeName.find(
"unsigned");
547 if (pos != std::string::npos)
548 baseTypeName.erase(pos+1, 8);
550 argBaseTypeNames.push_back(llvm::MDString::get(Context, baseTypeName));
556 typeQuals += typeQuals.empty() ?
"volatile" :
" volatile";
561 argTypeQuals.push_back(llvm::MDString::get(Context, typeQuals));
567 const OpenCLImageAccessAttr *A = parm->
getAttr<OpenCLImageAccessAttr>();
568 if (A && A->isWriteOnly())
569 accessQuals.push_back(llvm::MDString::get(Context,
"write_only"));
571 accessQuals.push_back(llvm::MDString::get(Context,
"read_only"));
574 accessQuals.push_back(llvm::MDString::get(Context,
"none"));
577 argNames.push_back(llvm::MDString::get(Context, parm->
getName()));
580 kernelMDArgs.push_back(llvm::MDNode::get(Context, addressQuals));
581 kernelMDArgs.push_back(llvm::MDNode::get(Context, accessQuals));
582 kernelMDArgs.push_back(llvm::MDNode::get(Context, argTypeNames));
583 kernelMDArgs.push_back(llvm::MDNode::get(Context, argBaseTypeNames));
584 kernelMDArgs.push_back(llvm::MDNode::get(Context, argTypeQuals));
586 kernelMDArgs.push_back(llvm::MDNode::get(Context, argNames));
589 void CodeGenFunction::EmitOpenCLKernelMetadata(
const FunctionDecl *FD,
592 if (!FD->
hasAttr<OpenCLKernelAttr>())
598 kernelMDArgs.push_back(llvm::ConstantAsMetadata::get(Fn));
603 if (
const VecTypeHintAttr *A = FD->
getAttr<VecTypeHintAttr>()) {
604 QualType hintQTy = A->getTypeHint();
606 bool isSignedInteger =
609 llvm::Metadata *attrMDArgs[] = {
610 llvm::MDString::get(Context,
"vec_type_hint"),
611 llvm::ConstantAsMetadata::get(llvm::UndefValue::get(
613 llvm::ConstantAsMetadata::get(llvm::ConstantInt::get(
614 llvm::IntegerType::get(Context, 32),
615 llvm::APInt(32, (uint64_t)(isSignedInteger ? 1 : 0))))};
616 kernelMDArgs.push_back(llvm::MDNode::get(Context, attrMDArgs));
619 if (
const WorkGroupSizeHintAttr *A = FD->
getAttr<WorkGroupSizeHintAttr>()) {
620 llvm::Metadata *attrMDArgs[] = {
621 llvm::MDString::get(Context,
"work_group_size_hint"),
622 llvm::ConstantAsMetadata::get(
Builder.getInt32(A->getXDim())),
623 llvm::ConstantAsMetadata::get(
Builder.getInt32(A->getYDim())),
624 llvm::ConstantAsMetadata::get(
Builder.getInt32(A->getZDim()))};
625 kernelMDArgs.push_back(llvm::MDNode::get(Context, attrMDArgs));
628 if (
const ReqdWorkGroupSizeAttr *A = FD->
getAttr<ReqdWorkGroupSizeAttr>()) {
629 llvm::Metadata *attrMDArgs[] = {
630 llvm::MDString::get(Context,
"reqd_work_group_size"),
631 llvm::ConstantAsMetadata::get(
Builder.getInt32(A->getXDim())),
632 llvm::ConstantAsMetadata::get(
Builder.getInt32(A->getYDim())),
633 llvm::ConstantAsMetadata::get(
Builder.getInt32(A->getZDim()))};
634 kernelMDArgs.push_back(llvm::MDNode::get(Context, attrMDArgs));
637 llvm::MDNode *kernelMDNode = llvm::MDNode::get(Context, kernelMDArgs);
638 llvm::NamedMDNode *OpenCLKernelMetadata =
639 CGM.
getModule().getOrInsertNamedMetadata(
"opencl.kernels");
640 OpenCLKernelMetadata->addOperand(kernelMDNode);
645 const Stmt *Body =
nullptr;
646 if (
auto *FD = dyn_cast_or_null<FunctionDecl>(F))
648 else if (
auto *OMD = dyn_cast_or_null<ObjCMethodDecl>(F))
649 Body = OMD->getBody();
651 if (
auto *CS = dyn_cast_or_null<CompoundStmt>(Body)) {
652 auto LastStmt = CS->body_rbegin();
653 if (LastStmt != CS->body_rend())
654 return isa<ReturnStmt>(*LastStmt);
667 "Do not use a CodeGenFunction object for more than one function");
671 DidCallStackSave =
false;
677 assert(
CurFn->isDeclaration() &&
"Function already has body?");
689 if (
SanOpts.
hasOneOf(SanitizerKind::Address | SanitizerKind::KernelAddress))
690 Fn->addFnAttr(llvm::Attribute::SanitizeAddress);
692 Fn->addFnAttr(llvm::Attribute::SanitizeThread);
694 Fn->addFnAttr(llvm::Attribute::SanitizeMemory);
696 Fn->addFnAttr(llvm::Attribute::SafeStack);
701 if (
const FunctionDecl *FD = dyn_cast_or_null<FunctionDecl>(D)) {
704 if (RI->isInlineSpecified()) {
705 Fn->addFnAttr(llvm::Attribute::InlineHint);
708 }
else if (!FD->
hasAttr<AlwaysInlineAttr>())
709 Fn->addFnAttr(llvm::Attribute::NoInline);
714 if (
const FunctionDecl *FD = dyn_cast_or_null<FunctionDecl>(D))
715 EmitOpenCLKernelMetadata(FD, Fn);
721 if (
const FunctionDecl *FD = dyn_cast_or_null<FunctionDecl>(D)) {
722 if (llvm::Constant *PrologueSig =
724 llvm::Constant *FTRTTIConst =
726 llvm::Constant *PrologueStructElems[] = { PrologueSig, FTRTTIConst };
727 llvm::Constant *PrologueStructConst =
728 llvm::ConstantStruct::getAnon(PrologueStructElems,
true);
729 Fn->setPrologueData(PrologueStructConst);
738 if (
const FunctionDecl *FD = dyn_cast_or_null<FunctionDecl>(D))
740 Fn->addFnAttr(llvm::Attribute::NoRecurse);
749 if (
Builder.isNamePreserving())
754 Builder.SetInsertPoint(EntryBB);
759 for (FunctionArgList::const_iterator i = Args.begin(), e = Args.end();
761 ArgTypes.push_back((*i)->getType());
767 DI->EmitFunctionStart(GD, Loc, StartLoc, FnType,
CurFn,
Builder);
787 auto AI =
CurFn->arg_begin();
795 llvm::Function::arg_iterator EI =
CurFn->arg_end();
817 if (D && isa<CXXMethodDecl>(D) && cast<CXXMethodDecl>(D)->isInstance()) {
832 if (FD->hasCapturedVLAType()) {
835 auto VAT = FD->getCapturedVLAType();
836 VLASizeMap[VAT->getSizeExpr()] = ExprArg;
843 CXXThisValue = CXXABIThisValue;
849 for (FunctionArgList::const_iterator i = Args.begin(), e = Args.end();
857 if (
const ParmVarDecl *PVD = dyn_cast<ParmVarDecl>(VD))
858 Ty = PVD->getOriginalType();
867 DI->EmitLocation(
Builder, StartLoc);
885 llvm::BasicBlock *SkipCountBB =
nullptr;
907 if (F->mayBeOverridden())
return;
909 for (llvm::BasicBlock &BB : *F)
910 for (llvm::Instruction &
I : BB)
914 F->setDoesNotThrow();
922 if (FD->
hasAttr<NoDebugAttr>())
938 for (
auto *Param : FD->
params()) {
939 Args.push_back(Param);
940 if (!Param->hasAttr<PassObjectSizeAttr>())
945 getContext(), Param->getDeclContext(), Param->getLocation(), NoID,
947 SizeArguments[Param] = Implicit;
948 Args.push_back(Implicit);
951 if (MD && (isa<CXXConstructorDecl>(MD) || isa<CXXDestructorDecl>(MD)))
955 if (
Stmt *Body = FD->
getBody()) BodyRange = Body->getSourceRange();
956 CurEHLocation = BodyRange.
getEnd();
968 if (SpecDecl->hasBody(SpecDecl))
969 Loc = SpecDecl->getLocation();
976 if (isa<CXXDestructorDecl>(FD))
978 else if (isa<CXXConstructorDecl>(FD))
984 else if (isa<CXXConversionDecl>(FD) &&
985 cast<CXXConversionDecl>(FD)->isLambdaToBlockPointerConversion()) {
989 }
else if (isa<CXXMethodDecl>(FD) &&
990 cast<CXXMethodDecl>(FD)->isLambdaStaticInvoker()) {
994 }
else if (FD->
isDefaulted() && isa<CXXMethodDecl>(FD) &&
995 (cast<CXXMethodDecl>(FD)->isCopyAssignmentOperator() ||
996 cast<CXXMethodDecl>(FD)->isMoveAssignmentOperator())) {
1003 llvm_unreachable(
"no definition for emitted function");
1016 EmitCheck(std::make_pair(IsFalse, SanitizerKind::Return),
1023 Builder.ClearInsertionPoint();
1031 if (!
CurFn->doesNotThrow())
1040 if (!S)
return false;
1047 if (isa<LabelStmt>(S))
1052 if (isa<SwitchCase>(S) && !IgnoreCaseStmts)
1056 if (isa<SwitchStmt>(S))
1057 IgnoreCaseStmts =
true;
1060 for (
const Stmt *SubStmt : S->children())
1072 if (!S)
return false;
1076 if (isa<SwitchStmt>(S) || isa<WhileStmt>(S) || isa<DoStmt>(S) ||
1080 if (isa<BreakStmt>(S))
1084 for (
const Stmt *SubStmt : S->children())
1097 llvm::APSInt ResultInt;
1101 ResultBool = ResultInt.getBoolValue();
1130 llvm::BasicBlock *TrueBlock,
1131 llvm::BasicBlock *FalseBlock,
1132 uint64_t TrueCount) {
1135 if (
const BinaryOperator *CondBOp = dyn_cast<BinaryOperator>(Cond)) {
1138 if (CondBOp->getOpcode() ==
BO_LAnd) {
1141 bool ConstantBool =
false;
1184 if (CondBOp->getOpcode() ==
BO_LOr) {
1187 bool ConstantBool =
false;
1213 uint64_t RHSCount = TrueCount - LHSCount;
1235 if (
const UnaryOperator *CondUOp = dyn_cast<UnaryOperator>(Cond)) {
1237 if (CondUOp->getOpcode() ==
UO_LNot) {
1260 uint64_t LHSScaledTrueCount = 0;
1264 LHSScaledTrueCount = TrueCount * LHSRatio;
1273 LHSScaledTrueCount);
1280 TrueCount - LHSScaledTrueCount);
1286 if (
const CXXThrowExpr *Throw = dyn_cast<CXXThrowExpr>(Cond)) {
1299 llvm::MDNode *Unpredictable =
nullptr;
1301 if (
const CallExpr *Call = dyn_cast<CallExpr>(Cond)) {
1302 const Decl *TargetDecl = Call->getCalleeDecl();
1303 if (
const FunctionDecl *FD = dyn_cast_or_null<FunctionDecl>(TargetDecl)) {
1304 if (FD->
getBuiltinID() == Builtin::BI__builtin_unpredictable) {
1306 Unpredictable = MDHelper.createUnpredictable();
1315 llvm::MDNode *Weights =
1316 createProfileWeights(TrueCount, CurrentCount - TrueCount);
1324 Builder.CreateCondBr(CondV, TrueBlock, FalseBlock, Weights, Unpredictable);
1352 Builder.CreateInBoundsGEP(begin.getPointer(), sizeInChars,
"vla.end");
1354 llvm::BasicBlock *originBB = CGF.
Builder.GetInsertBlock();
1362 llvm::PHINode *cur = Builder.CreatePHI(begin.getType(), 2,
"vla.cur");
1363 cur->addIncoming(begin.getPointer(), originBB);
1374 Builder.CreateInBoundsGEP(CGF.
Int8Ty, cur, baseSizeInChars,
"vla.next");
1377 llvm::Value *done = Builder.CreateICmpEQ(next, end,
"vla-init.isdone");
1378 Builder.CreateCondBr(done, contBB, loopBB);
1379 cur->addIncoming(next, loopBB);
1389 if (cast<CXXRecordDecl>(RT->getDecl())->isEmpty())
1408 dyn_cast_or_null<VariableArrayType>(
1412 std::tie(numElts, eltType) =
getVLASize(vlaType);
1416 if (!eltSize.
isOne())
1437 llvm::GlobalVariable *NullVariable =
1438 new llvm::GlobalVariable(
CGM.
getModule(), NullConstant->getType(),
1440 llvm::GlobalVariable::PrivateLinkage,
1441 NullConstant, Twine());
1443 NullVariable->setAlignment(NullAlign.getQuantity());
1462 if (!IndirectBranch)
1468 IndirectBranch->addDestination(BB);
1469 return llvm::BlockAddress::get(
CurFn, BB);
1474 if (IndirectBranch)
return IndirectBranch->getParent();
1480 "indirect.goto.dest");
1483 IndirectBranch = TmpBuilder.CreateIndirectBr(DestVal);
1484 return IndirectBranch->getParent();
1492 const ArrayType *arrayType = origArrayType;
1497 if (isa<VariableArrayType>(arrayType)) {
1498 numVLAElements =
getVLASize(cast<VariableArrayType>(arrayType)).first;
1508 baseType = elementType;
1509 return numVLAElements;
1511 }
while (isa<VariableArrayType>(arrayType));
1523 llvm::ConstantInt *zero =
Builder.getInt32(0);
1524 gepIndices.push_back(zero);
1526 uint64_t countFromCLAs = 1;
1529 llvm::ArrayType *llvmArrayType =
1531 while (llvmArrayType) {
1532 assert(isa<ConstantArrayType>(arrayType));
1533 assert(cast<ConstantArrayType>(arrayType)->getSize().getZExtValue()
1534 == llvmArrayType->getNumElements());
1536 gepIndices.push_back(zero);
1537 countFromCLAs *= llvmArrayType->getNumElements();
1541 dyn_cast<llvm::ArrayType>(llvmArrayType->getElementType());
1543 assert((!llvmArrayType || arrayType) &&
1544 "LLVM and Clang types are out-of-synch");
1553 cast<ConstantArrayType>(arrayType)->getSize().getZExtValue();
1563 gepIndices,
"array.begin"),
1570 = llvm::ConstantInt::get(
SizeTy, countFromCLAs);
1574 numElements =
Builder.CreateNUWMul(numVLAElements, numElements);
1579 std::pair<llvm::Value*, QualType>
1582 assert(vla &&
"type was not a variable array type!");
1586 std::pair<llvm::Value*, QualType>
1595 assert(vlaSize &&
"no size for VLA!");
1596 assert(vlaSize->getType() ==
SizeTy);
1599 numElements = vlaSize;
1603 numElements =
Builder.CreateNUWMul(numElements, vlaSize);
1605 }
while ((type =
getContext().getAsVariableArrayType(elementType)));
1607 return std::pair<llvm::Value*,QualType>(numElements, elementType);
1612 "Must pass variably modified type to EmitVLASizes!");
1622 switch (ty->getTypeClass()) {
1624 #define TYPE(Class, Base)
1625 #define ABSTRACT_TYPE(Class, Base)
1626 #define NON_CANONICAL_TYPE(Class, Base)
1627 #define DEPENDENT_TYPE(Class, Base) case Type::Class:
1628 #define NON_CANONICAL_UNLESS_DEPENDENT_TYPE(Class, Base)
1629 #include "clang/AST/TypeNodes.def"
1630 llvm_unreachable(
"unexpected dependent type!");
1636 case Type::ExtVector:
1639 case Type::Elaborated:
1640 case Type::TemplateSpecialization:
1641 case Type::ObjCObject:
1642 case Type::ObjCInterface:
1643 case Type::ObjCObjectPointer:
1644 llvm_unreachable(
"type class is never variably-modified!");
1646 case Type::Adjusted:
1647 type = cast<AdjustedType>(ty)->getAdjustedType();
1651 type = cast<DecayedType>(ty)->getPointeeType();
1655 type = cast<PointerType>(ty)->getPointeeType();
1658 case Type::BlockPointer:
1659 type = cast<BlockPointerType>(ty)->getPointeeType();
1662 case Type::LValueReference:
1663 case Type::RValueReference:
1664 type = cast<ReferenceType>(ty)->getPointeeType();
1667 case Type::MemberPointer:
1668 type = cast<MemberPointerType>(ty)->getPointeeType();
1671 case Type::ConstantArray:
1672 case Type::IncompleteArray:
1677 case Type::VariableArray: {
1695 size->getType()->isSignedIntegerType()) {
1697 llvm::Value *Zero = llvm::Constant::getNullValue(Size->getType());
1698 llvm::Constant *StaticArgs[] = {
1703 SanitizerKind::VLABound),
1704 "vla_bound_not_positive", StaticArgs, Size);
1716 case Type::FunctionProto:
1717 case Type::FunctionNoProto:
1718 type = cast<FunctionType>(ty)->getReturnType();
1723 case Type::UnaryTransform:
1724 case Type::Attributed:
1725 case Type::SubstTemplateTypeParm:
1726 case Type::PackExpansion:
1732 case Type::Decltype:
1737 case Type::TypeOfExpr:
1743 type = cast<AtomicType>(ty)->getValueType();
1754 if (
getContext().getBuiltinVaListType()->isArrayType())
1764 llvm::Constant *Init) {
1765 assert (Init &&
"Invalid DeclRefExpr initializer!");
1768 Dbg->EmitGlobalVariable(E->
getDecl(), Init);
1783 llvm::Instruction *inst =
new llvm::BitCastInst(value, value->getType(),
"",
1787 protection.Inst = inst;
1792 if (!protection.Inst)
return;
1795 protection.Inst->eraseFromParent();
1800 StringRef AnnotationStr,
1808 return Builder.CreateCall(AnnotationFn, Args);
1812 assert(D->
hasAttr<AnnotateAttr>() &&
"no annotate attribute");
1823 assert(D->
hasAttr<AnnotateAttr>() &&
"no annotate attribute");
1851 CGF->IsSanitizerScope =
false;
1855 const llvm::Twine &
Name,
1856 llvm::BasicBlock *BB,
1863 template <
bool PreserveNames>
1865 llvm::Instruction *
I,
const llvm::Twine &
Name, llvm::BasicBlock *BB,
1867 llvm::IRBuilderDefaultInserter<PreserveNames>::InsertHelper(I, Name, BB,
1870 CGF->InsertHelper(I, Name, BB, InsertPt);
1874 #define PreserveNames false
1876 #define PreserveNames true
1879 llvm::Instruction *
I,
const llvm::Twine &
Name, llvm::BasicBlock *BB,
1881 #undef PreserveNames
1885 std::string &FirstMissing) {
1887 if (ReqFeatures.empty())
1892 llvm::StringMap<bool> CallerFeatureMap;
1898 ReqFeatures.begin(), ReqFeatures.end(), [&](StringRef Feature) {
1900 Feature.split(OrFeatures,
"|");
1901 return std::any_of(OrFeatures.begin(), OrFeatures.end(),
1902 [&](StringRef Feature) {
1903 if (!CallerFeatureMap.lookup(Feature)) {
1904 FirstMissing = Feature.str();
1930 std::string MissingFeature;
1933 const char *FeatureList =
1936 if (!FeatureList || StringRef(FeatureList) ==
"")
1938 StringRef(FeatureList).split(ReqFeatures,
",");
1944 }
else if (TargetDecl->
hasAttr<TargetAttr>()) {
1947 llvm::StringMap<bool> CalleeFeatureMap;
1949 for (
const auto &F : CalleeFeatureMap) {
1952 ReqFeatures.push_back(F.getKey());
unsigned getAddressSpace() const
Return the address space of this type.
Defines the clang::ASTContext interface.
SourceLocation getEnd() const
FunctionDecl - An instance of this class is created to represent a function declaration or definition...
LValue MakeNaturalAlignPointeeAddrLValue(llvm::Value *V, QualType T)
Given a value of type T* that may not be to a complete object, construct an l-value with the natural ...
void end(CodeGenFunction &CGF)
StringRef getName() const
getName - Get the name of identifier for this declaration as a StringRef.
A (possibly-)qualified type.
CodeGenTypes & getTypes()
llvm::Type * ConvertTypeForMem(QualType T)
void EmitBranchOnBoolExpr(const Expr *Cond, llvm::BasicBlock *TrueBlock, llvm::BasicBlock *FalseBlock, uint64_t TrueCount)
EmitBranchOnBoolExpr - Emit a branch on a boolean condition (e.g.
CanQualType getReturnType() const
unsigned getInAllocaFieldIndex() const
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
AlignmentSource
The source of the alignment of an l-value; an expression of confidence in the alignment actually matc...
void EmitFunctionInstrumentation(const char *Fn)
EmitFunctionInstrumentation - Emit LLVM code to call the specified instrumentation function with the ...
bool isOne() const
isOne - Test whether the quantity equals one.
virtual void addImplicitStructorParams(CodeGenFunction &CGF, QualType &ResTy, FunctionArgList &Params)=0
Insert any ABI-specific implicit parameters into the parameter list for a function.
CharUnits getClassPointerAlignment(const CXXRecordDecl *CD)
Returns the assumed alignment of an opaque pointer to the given class.
const TargetInfo & getTarget() const
bool isMain() const
Determines whether this function is "main", which is the entry point into an executable program...
CanQualType getSizeType() const
Return the unique type for "size_t" (C99 7.17), defined in <stddef.h>.
static bool endsWithReturn(const Decl *F)
Determine whether the function F ends with a return stmt.
QuantityType getQuantity() const
getQuantity - Get the raw integer representation of this quantity.
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 isAlignmentRequired(const Type *T) const
Determine if the alignment the type has was required using an alignment attribute.
std::string getAsString() const
The base class of the type hierarchy.
bool ShouldInstrumentFunction()
ShouldInstrumentFunction - Return true if the current function should be instrumented with __cyg_prof...
Emit only debug info necessary for generating line number tables (-gline-tables-only).
DiagnosticBuilder Report(SourceLocation Loc, unsigned DiagID)
Issue the message to the client.
void GenerateCode(GlobalDecl GD, llvm::Function *Fn, const CGFunctionInfo &FnInfo)
Represents an array type, per C99 6.7.5.2 - Array Declarators.
static bool hasRequiredFeatures(const SmallVectorImpl< StringRef > &ReqFeatures, CodeGenModule &CGM, const FunctionDecl *FD, std::string &FirstMissing)
const LangOptions & getLangOpts() const
llvm::IntegerType * Int8Ty
i8, i16, i32, and i64
TypeEvaluationKind
The kind of evaluation to perform on values of a particular type.
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.
Extra information about a function prototype.
uint64_t getProfileCount(const Stmt *S)
Get the profiler's count for the given statement.
This class gathers all debug information during compilation and is responsible for emitting to llvm g...
QualType getThisType(ASTContext &C) const
Returns the type of the this pointer.
llvm::CallInst * EmitTrapCall(llvm::Intrinsic::ID IntrID)
Emit a call to trap or debugtrap and attach function attribute "trap-func-name" if specified...
void EmitVariablyModifiedType(QualType Ty)
EmitVLASize - Capture all the sizes for the VLA expressions in the given variably-modified type and s...
CharUnits getNaturalTypeAlignment(QualType T, AlignmentSource *Source=nullptr, bool forPointeeType=false)
void setCurrentProfileCount(uint64_t Count)
Set the profiler's current count.
bool IsSanitizerScope
True if CodeGen currently emits code implementing sanitizer checks.
Describes how types, statements, expressions, and declarations should be printed. ...
llvm::Type * ConvertTypeForMem(QualType T)
ConvertTypeForMem - Convert type T into a llvm::Type.
A C++ throw-expression (C++ [except.throw]).
ParmVarDecl - Represents a parameter to a function.
bool isObjCRetainableType() const
static void destroyBlockInfos(CGBlockInfo *info)
Destroy a chain of block layouts.
void emitImplicitAssignmentOperatorBody(FunctionArgList &Args)
EHScopeStack::stable_iterator PrologueCleanupDepth
PrologueCleanupDepth - The cleanup depth enclosing all the cleanups associated with the parameters...
virtual bool hasMostDerivedReturn(GlobalDecl GD) const
JumpDest getJumpDestForLabel(const LabelDecl *S)
getBasicBlockForLabel - Return the LLVM basicblock that the specified label maps to.
llvm::DenseMap< const VarDecl *, FieldDecl * > LambdaCaptureFields
An object to manage conditionally-evaluated expressions.
PeepholeProtection protectFromPeepholes(RValue rvalue)
protectFromPeepholes - Protect a value that we're intending to store to the side, but which will prob...
One of these records is kept for each identifier that is lexed.
CGBlockInfo * FirstBlockInfo
FirstBlockInfo - The head of a singly-linked-list of block layouts.
void EmitFunctionEpilog(const CGFunctionInfo &FI, bool EmitRetDbgLoc, SourceLocation EndLoc)
EmitFunctionEpilog - Emit the target specific LLVM code to return the given temporary.
class LLVM_ALIGNAS(8) DependentTemplateSpecializationType const IdentifierInfo * Name
Represents a template specialization type whose template cannot be resolved, e.g. ...
Indirect - Pass the argument indirectly via a hidden pointer with the specified alignment (0 indicate...
CGDebugInfo * getDebugInfo()
CodeGenFunction - This class organizes the per-function state that is used while generating LLVM code...
Expr * getSizeExpr() const
llvm::Type * ConvertType(QualType T)
ConvertType - Convert type T into a llvm::Type.
bool isVariablyModifiedType() const
Whether this type is a variably-modified type (C99 6.7.5).
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
LValue EmitLValueForLambdaField(const FieldDecl *Field)
Given that we are currently emitting a lambda, emit an l-value for one of its members.
QualType getReturnType() const
FieldDecl - An instance of this class is created by Sema::ActOnField to represent a member of a struc...
llvm::IntegerType * SizeTy
void InsertHelper(llvm::Instruction *I, const llvm::Twine &Name, llvm::BasicBlock *BB, llvm::BasicBlock::iterator InsertPt) const
CGBuilder insert helper.
SanitizerMask Mask
Bitmask of enabled sanitizers.
const Decl * getDecl() const
Address CreateIRTemp(QualType T, const Twine &Name="tmp")
CreateIRTemp - Create a temporary IR object of the given type, with appropriate alignment.
virtual void EmitInstanceFunctionProlog(CodeGenFunction &CGF)=0
Emit the ABI-specific prolog for the function.
CGCUDARuntime & getCUDARuntime()
Return a reference to the configured CUDA runtime.
static bool hasScalarEvaluationKind(QualType T)
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.
const CXXRecordDecl * getParent() const
Returns the parent of this method declaration, which is the class in which this method is defined...
bool isDefaulted() const
Whether this function is defaulted per C++0x.
field_range fields() const
const ArrayType * getAsArrayType(QualType T) const
Type Query functions.
A builtin binary operation expression such as "x + y" or "x <= y".
The l-value was considered opaque, so the alignment was determined from a type, but that type was an ...
FunctionDecl * getTemplateInstantiationPattern() const
Retrieve the function declaration from which this function could be instantiated, if it is an instant...
llvm::CallInst * CreateMemCpy(Address Dest, Address Src, llvm::Value *Size, bool IsVolatile=false)
void incrementProfileCounter(const Stmt *S)
Increment the profiler's counter for the given statement.
void EmitStmt(const Stmt *S)
EmitStmt - Emit the code for the statement.
llvm::BasicBlock * createBasicBlock(const Twine &name="", llvm::Function *parent=nullptr, llvm::BasicBlock *before=nullptr)
createBasicBlock - Create an LLVM basic block.
void EmitIgnoredExpr(const Expr *E)
EmitIgnoredExpr - Emit an expression in a context which ignores the result.
void assignRegionCounters(GlobalDecl GD, llvm::Function *Fn)
Assign counters to regions and configure them for PGO of a given function.
TypeClass getTypeClass() const
bool isIncompleteType(NamedDecl **Def=nullptr) const
Types are partitioned into 3 broad categories (C99 6.2.5p1): object types, function types...
GlobalDecl CurGD
CurGD - The GlobalDecl for the current function being compiled.
CharUnits getTypeSizeInChars(QualType T) const
Return the size of the specified (complete) type T, in characters.
static bool ContainsLabel(const Stmt *S, bool IgnoreCaseStmts=false)
ContainsLabel - Return true if the statement contains a label in it.
llvm::DebugLoc EmitReturnBlock()
Emit the unified return block, trying to avoid its emission when possible.
uint64_t getCurrentProfileCount()
Get the profiler's current count.
detail::InMemoryDirectory::const_iterator I
virtual void emitDeviceStub(CodeGenFunction &CGF, FunctionArgList &Args)=0
Emits a kernel launch stub.
void begin(CodeGenFunction &CGF)
void EmitDeclRefExprDbgValue(const DeclRefExpr *E, llvm::Constant *Init)
LValue MakeAddrLValue(Address Addr, QualType T, AlignmentSource AlignSource=AlignmentSource::Type)
ConditionalOperator - The ?: ternary operator.
static CharUnits One()
One - Construct a CharUnits quantity of one.
void EmitCheck(ArrayRef< std::pair< llvm::Value *, SanitizerMask >> Checked, StringRef CheckName, 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...
CompoundStmt - This represents a group of statements like { stmt stmt }.
llvm::CallInst * EmitNounwindRuntimeCall(llvm::Value *callee, const Twine &name="")
const TargetCodeGenInfo & getTargetCodeGenInfo()
void clear()
Disable all sanitizers.
RValue - This trivial value class is used to represent the result of an expression that is evaluated...
static void EmitIfUsed(CodeGenFunction &CGF, llvm::BasicBlock *BB)
QualType getPointeeType() const
If this is a pointer, ObjC object pointer, or block pointer, this returns the respective pointee...
void getFunctionFeatureMap(llvm::StringMap< bool > &FeatureMap, const FunctionDecl *FD)
static TypeEvaluationKind getEvaluationKind(QualType T)
hasAggregateLLVMType - Return true if the specified AST type will map into an aggregate LLVM type or ...
llvm::Constant * EmitAnnotationUnit(SourceLocation Loc)
Emit the annotation's translation unit.
static void GenOpenCLArgMetadata(const FunctionDecl *FD, llvm::Function *Fn, CodeGenModule &CGM, llvm::LLVMContext &Context, SmallVector< llvm::Metadata *, 5 > &kernelMDArgs, CGBuilderTy &Builder, ASTContext &ASTCtx)
llvm::Value * getPointer() const
llvm::BasicBlock * EHResumeBlock
EHResumeBlock - Unified block containing a call to llvm.eh.resume.
bool empty() const
Determines whether the exception-scopes stack is empty.
Expr - This represents one expression.
CGCXXABI & getCXXABI() const
CharUnits getIndirectAlign() const
const ParmVarDecl * getParamDecl(unsigned i) const
static void TryMarkNoThrow(llvm::Function *F)
Tries to mark the given function nounwind based on the non-existence of any throwing calls within it...
ASTContext & getContext() const
CharUnits getNaturalPointeeTypeAlignment(QualType T, AlignmentSource *Source=nullptr)
llvm::BasicBlock * getBlock() const
static CharUnits fromQuantity(QuantityType Quantity)
fromQuantity - Construct a CharUnits quantity from a raw integer type.
static LValue MakeAddr(Address address, QualType type, ASTContext &Context, AlignmentSource alignSource, llvm::MDNode *TBAAInfo=nullptr)
stable_iterator stable_begin() const
Create a stable reference to the top of the EH stack.
llvm::LLVMContext & getLLVMContext()
llvm::BasicBlock * GetIndirectGotoBlock()
CharUnits toCharUnitsFromBits(int64_t BitSize) const
Convert a size in bits to a size in characters.
llvm::IntegerType * Int32Ty
void EmitConstructorBody(FunctionArgList &Args)
EmitConstructorBody - Emits the body of the current constructor.
Address EmitPointerWithAlignment(const Expr *Addr, AlignmentSource *Source=nullptr)
EmitPointerWithAlignment - Given an expression with a pointer type, emit the value and compute our be...
llvm::Constant * EmitAnnotationString(StringRef Str)
Emit an annotation string.
bool EvaluateAsInt(llvm::APSInt &Result, const ASTContext &Ctx, SideEffectsKind AllowSideEffects=SE_NoSideEffects) const
EvaluateAsInt - Return true if this is a constant which we can fold and convert to an integer...
virtual llvm::Constant * getUBSanFunctionSignature(CodeGen::CodeGenModule &CGM) const
Return a constant used by UBSan as a signature to identify functions possessing type information...
virtual bool HasThisReturn(GlobalDecl GD) const
Returns true if the given constructor or destructor is one of the kinds that the ABI says returns 'th...
LValue MakeNaturalAlignAddrLValue(llvm::Value *V, QualType T)
bool containsOnlyLifetimeMarkers(stable_iterator Old) const
llvm::CallInst * CreateMemSet(Address Dest, llvm::Value *Value, llvm::Value *Size, bool IsVolatile=false)
void EmitMCountInstrumentation()
EmitMCountInstrumentation - Emit call to .mcount.
An object which temporarily prevents a value from being destroyed by aggressive peephole optimization...
UnaryOperator - This represents the unary-expression's (except sizeof and alignof), the postinc/postdec operators from postfix-expression, and various extensions.
void EmitLambdaToBlockPointerBody(FunctionArgList &Args)
llvm::Function * getIntrinsic(unsigned IID, ArrayRef< llvm::Type * > Tys=None)
DeclarationName getDeclName() const
getDeclName - Get the actual, stored name of the declaration, which may be a special name...
QualType getElementType() const
virtual void startNewFunction()
GlobalDecl - represents a global declaration.
const clang::PrintingPolicy & getPrintingPolicy() const
SanitizerScope(CodeGenFunction *CGF)
The l-value was considered opaque, so the alignment was determined from a type.
Stmt * getBody(const FunctionDecl *&Definition) const
getBody - Retrieve the body (definition) of the function.
bool HaveInsertPoint() const
HaveInsertPoint - True if an insertion point is defined.
redecl_range redecls() const
Returns an iterator range for all the redeclarations of the same decl.
bool SawAsmBlock
Whether we processed a Microsoft-style asm block during CodeGen.
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.
bool hasOneOf(SanitizerMask K) const
Check if one or more sanitizers are enabled.
llvm::Constant * CreateRuntimeFunction(llvm::FunctionType *Ty, StringRef Name, llvm::AttributeSet ExtraAttrs=llvm::AttributeSet())
Create a new runtime function with the specified type and name.
ASTContext & getContext() const
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...
unsigned getNumParams() const
getNumParams - Return the number of parameters this function must have based on its FunctionType...
const Type * getTypePtr() const
Retrieves a pointer to the underlying (unqualified) type.
const TemplateArgument * iterator
llvm::Value * EvaluateExprAsBool(const Expr *E)
EvaluateExprAsBool - Perform the usual unary conversions on the specified expression and compare the ...
bool ConstantFoldsToSimpleInteger(const Expr *Cond, bool &Result)
ConstantFoldsToSimpleInteger - If the specified expression does not fold to a constant, or if it does but contains a label, return false.
const char * getRequiredFeatures(unsigned ID) const
LabelDecl - Represents the declaration of a label.
A scoped helper to set the current debug location to the specified location or preferred location of ...
Represents a static or instance method of a struct/union/class.
bool isReturnsRetained() const
In ARC, whether this function retains its return value.
SanitizerSet SanOpts
Sanitizers enabled for this function.
llvm::Constant * GetAddrOfRTTIDescriptor(QualType Ty, bool ForEH=false)
Get the address of the RTTI descriptor for the given type.
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
void StartFunction(GlobalDecl GD, QualType RetTy, llvm::Function *Fn, const CGFunctionInfo &FnInfo, const FunctionArgList &Args, SourceLocation Loc=SourceLocation(), SourceLocation StartLoc=SourceLocation())
Emit code for the start of a function.
const LangOptions & getLangOpts() const
SourceLocation getBegin() const
void InsertHelper(llvm::Instruction *I, const llvm::Twine &Name, llvm::BasicBlock *BB, llvm::BasicBlock::iterator InsertPt) const
This forwards to CodeGenFunction::InsertHelper.
MangleContext & getMangleContext()
Gets the mangle context.
void getCaptureFields(llvm::DenseMap< const VarDecl *, FieldDecl * > &Captures, FieldDecl *&ThisCapture) const
For a closure type, retrieve the mapping from captured variables and this to the non-static data memb...
JumpDest getJumpDestInCurrentScope(llvm::BasicBlock *Target)
The given basic block lies in the current EH scope, but may be a target of a potentially scope-crossi...
llvm::Constant * EmitAnnotationLineNo(SourceLocation L)
Emit the annotation line number.
unsigned getBuiltinID() const
Returns a value indicating whether this function corresponds to a builtin function.
InAlloca - Pass the argument directly using the LLVM inalloca attribute.
bool isVolatileQualified() const
Determine whether this type is volatile-qualified.
Address EmitMSVAListRef(const Expr *E)
Emit a "reference" to a __builtin_ms_va_list; this is always the value of the expression, because a __builtin_ms_va_list is a pointer to a char.
const CGFunctionInfo * CurFnInfo
void EmitStartEHSpec(const Decl *D)
EmitStartEHSpec - Emit the start of the exception spec.
void FinishFunction(SourceLocation EndLoc=SourceLocation())
FinishFunction - Complete IR generation of the current function.
QualType getFunctionType(QualType ResultTy, ArrayRef< QualType > Args, const FunctionProtoType::ExtProtoInfo &EPI) const
Return a normal function type with a typed argument list.
This is an IRBuilder insertion helper that forwards to CodeGenFunction::InsertHelper, which adds necessary metadata to instructions.
Address EmitVAListRef(const Expr *E)
llvm::Value * EmitScalarExpr(const Expr *E, bool IgnoreResultAssign=false)
EmitScalarExpr - Emit the computation of the specified expression of LLVM scalar type, returning the result.
bool isSRetAfterThis() const
FunctionArgList - Type for representing both the decl and type of parameters to a function...
Represents a template argument.
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 const Type * getElementType(const Expr *BaseExpr)
static void emitNonZeroVLAInit(CodeGenFunction &CGF, QualType baseType, Address dest, Address src, llvm::Value *sizeInChars)
emitNonZeroVLAInit - Emit the "zero" initialization of a variable-length array whose elements have a ...
Address EmitFieldAnnotations(const FieldDecl *D, Address V)
Emit field annotations for the given field & value.
bool isZero() const
isZero - Test whether the quantity equals zero.
const internal::VariadicAllOfMatcher< Type > type
Matches Types in the clang AST.
virtual ~CGCapturedStmtInfo()
llvm::Value * getScalarVal() const
getScalarVal() - Return the Value* of this scalar value.
Address CreateStructGEP(Address Addr, unsigned Index, CharUnits Offset, const llvm::Twine &Name="")
llvm::Value * EmitAnnotationCall(llvm::Value *AnnotationFn, llvm::Value *AnnotatedVal, StringRef AnnotationStr, SourceLocation Location)
Emit an annotation call (intrinsic or builtin).
llvm::LoadInst * CreateAlignedLoad(llvm::Value *Addr, CharUnits Align, const llvm::Twine &Name="")
llvm::IntegerType * IntPtrTy
Decl * getNonClosureContext()
Find the innermost non-closure ancestor of this declaration, walking up through blocks, lambdas, etc.
void buildThisParam(CodeGenFunction &CGF, FunctionArgList &Params)
Build a parameter variable suitable for 'this'.
llvm::Constant * EmitNullConstant(QualType T)
Return the result of value-initializing the given type, i.e.
detail::InMemoryDirectory::const_iterator E
llvm::SmallVector< char, 256 > LifetimeExtendedCleanupStack
bool isLambda() const
Determine whether this class describes a lambda function object.
bool isInSanitizerBlacklist(llvm::Function *Fn, SourceLocation Loc) const
const VariableArrayType * getAsVariableArrayType(QualType T) const
JumpDest ReturnBlock
ReturnBlock - Unified return block.
A helper class that allows the use of isa/cast/dyncast to detect TagType objects of structs/unions/cl...
void EmitBlockWithFallThrough(llvm::BasicBlock *BB, const Stmt *S)
When instrumenting to collect profile data, the counts for some blocks such as switch cases need to n...
const T * getAs() const
Member-template getAs<specific type>'.
QualType getCanonicalType() const
static ImplicitParamDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation IdLoc, IdentifierInfo *Id, QualType T)
llvm::PointerType * Int8PtrTy
void EmitLambdaStaticInvokeFunction(const CXXMethodDecl *MD)
SourceLocation getLocStart() const LLVM_READONLY
bool has(SanitizerMask K) const
Check if a certain (single) sanitizer is enabled.
llvm::AssertingVH< llvm::Instruction > AllocaInsertPt
AllocaInsertPoint - This is an instruction in the entry block before which we prefer to insert alloca...
ExtVectorType - Extended vector type.
CXXRecordDecl * getAsCXXRecordDecl() const
Retrieves the CXXRecordDecl that this type refers to, either because the type is a RecordType or beca...
bool isRestrictQualified() const
Determine whether this type is restrict-qualified.
void EmitBlock(llvm::BasicBlock *BB, bool IsFinished=false)
EmitBlock - Emit the given block.
void checkTargetFeatures(const CallExpr *E, const FunctionDecl *TargetDecl)
FieldDecl * LambdaThisCaptureField
ABIArgInfo & getReturnInfo()
void EmitFunctionBody(FunctionArgList &Args, const Stmt *Body)
llvm::ConstantInt * getSize(CharUnits numChars)
Emit the given number of characters as a value of type size_t.
const Decl * CurFuncDecl
CurFuncDecl - Holds the Decl for the current outermost non-closure context.
void InsertHelper(llvm::Instruction *I) const
Function called by the CodeGenFunction when an instruction is created.
Defines the C++ Decl subclasses, other than those for templates (found in DeclTemplate.h) and friends (in DeclFriend.h).
void unprotectFromPeepholes(PeepholeProtection protection)
DiagnosticsEngine & getDiags() const
void ErrorUnsupported(const Stmt *S, const char *Type)
ErrorUnsupported - Print out an error that codegen doesn't support the specified stmt yet...
QualType getUnqualifiedType() const
Retrieve the unqualified variant of the given type, removing as little sugar as possible.
Represents a C++ struct/union/class.
BoundNodesTreeBuilder *const Builder
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.
llvm::iterator_range< specific_attr_iterator< T > > specific_attrs() const
llvm::Type * ConvertType(QualType T)
void EmitFunctionProlog(const CGFunctionInfo &FI, llvm::Function *Fn, const FunctionArgList &Args)
EmitFunctionProlog - Emit the target specific LLVM code to load the arguments for the given function...
void PopCleanupBlocks(EHScopeStack::stable_iterator OldCleanupStackSize)
Takes the old cleanup stack size and emits the cleanup blocks that have been added.
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.
Builtin::Context & BuiltinInfo
bool AutoreleaseResult
In ARC, whether we should autorelease the return value.
RValue EmitLoadOfLValue(LValue V, SourceLocation Loc)
EmitLoadOfLValue - Given an expression that represents a value lvalue, this method emits the address ...
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.
CallExpr - Represents a function call (C99 6.5.2.2, C++ [expr.call]).
llvm::MDNode * getTBAAInfo(QualType QTy)
unsigned getTargetAddressSpace(QualType T) const
A reference to a declared variable, function, enum, etc.
void EmitDestructorBody(FunctionArgList &Args)
EmitDestructorBody - Emits the body of the current destructor.
QualType getElementType() const
This structure provides a set of types that are commonly used during IR emission. ...
void EmitEndEHSpec(const Decl *D)
EmitEndEHSpec - Emit the end of the exception spec.
llvm::Constant * EmitCheckSourceLocation(SourceLocation Loc)
Emit a description of a source location in a format suitable for passing to a runtime sanitizer handl...
Address EmitCompoundStmtWithoutScope(const CompoundStmt &S, bool GetLast=false, AggValueSlot AVS=AggValueSlot::ignored())
A trivial tuple used to represent a source range.
SourceLocation getLocation() const
LValue - This represents an lvalue references.
llvm::BlockAddress * GetAddrOfLabel(const LabelDecl *L)
void EmitVarAnnotations(const VarDecl *D, llvm::Value *V)
Emit local annotations for the local variable V, declared by D.
Represents a C array with a specified size that is not an integer-constant-expression.
SanitizerMetadata * getSanitizerMetadata()
bool isSignedIntegerType() const
Return true if this is an integer type that is signed, according to C99 6.2.5p4 [char, signed char, short, int, long..], or an enum decl which has a signed representation.
bool isConstQualified() const
Determine whether this type is const-qualified.
bool hasImplicitReturnZero() const
Whether falling off this function implicitly returns null/zero.
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...
static bool containsBreak(const Stmt *S)
containsBreak - Return true if the statement contains a break out of it.
QualType getSingleStepDesugaredType(const ASTContext &Context) const
Return the specified type with one level of "sugar" removed from the type.
QualType getBaseElementType(const ArrayType *VAT) const
Return the innermost element type of an array type.
bool isZeroInitializable(QualType T)
IsZeroInitializable - Return whether a type can be zero-initialized (in the C++ sense) with an LLVM z...
Defines enum values for all the target-independent builtin functions.
void EmitCXXThrowExpr(const CXXThrowExpr *E, bool KeepInsertionPoint=true)
Attr - This represents one attribute.
void EmitNullInitialization(Address DestPtr, QualType Ty)
EmitNullInitialization - Generate code to set a value of the given type to null, If the type contains...
Expr * IgnoreParens() LLVM_READONLY
IgnoreParens - Ignore parentheses.
bool isPointerType() const
OverloadedOperatorKind getOverloadedOperator() const
getOverloadedOperator - Which C++ overloaded operator this function represents, if any...