30 #include "llvm/ADT/Hashing.h" 31 #include "llvm/ADT/StringExtras.h" 32 #include "llvm/IR/DataLayout.h" 33 #include "llvm/IR/Intrinsics.h" 34 #include "llvm/IR/LLVMContext.h" 35 #include "llvm/IR/MDBuilder.h" 36 #include "llvm/Support/ConvertUTF.h" 37 #include "llvm/Support/MathExtras.h" 38 #include "llvm/Support/Path.h" 39 #include "llvm/Transforms/Utils/SanitizerStats.h" 43 using namespace clang;
44 using namespace CodeGen;
51 unsigned addressSpace =
52 cast<llvm::PointerType>(value->getType())->getAddressSpace();
56 destType = llvm::Type::getInt8PtrTy(
getLLVMContext(), addressSpace);
58 if (value->getType() == destType)
return value;
89 llvm::IRBuilderBase::InsertPointGuard IPG(
Builder);
97 Ty->getPointerTo(DestAddrSpace),
true);
110 return Builder.CreateAlloca(Ty, ArraySize, Name);
127 assert(isa<llvm::AllocaInst>(Var.
getPointer()));
146 const Twine &Name,
Address *Alloca) {
203 if (!ignoreResult && aggSlot.
isIgnored())
208 llvm_unreachable(
"bad evaluation kind");
250 llvm_unreachable(
"bad evaluation kind");
291 VD && isa<VarDecl>(VD) && VD->
hasAttr<ObjCPreciseLifetimeAttr>();
312 llvm_unreachable(
"temporary cannot have dynamic storage duration");
314 llvm_unreachable(
"unknown storage duration");
322 auto *ClassDecl = cast<CXXRecordDecl>(RT->getDecl());
323 if (!ClassDecl->hasTrivialDestructor())
324 ReferenceTemporaryDtor = ClassDecl->getDestructor();
327 if (!ReferenceTemporaryDtor)
334 llvm::Constant *CleanupFn;
335 llvm::Constant *CleanupArg;
338 ReferenceTemporary, E->
getType(),
341 CleanupArg = llvm::Constant::getNullValue(CGF.
Int8PtrTy);
345 CleanupArg = cast<llvm::Constant>(ReferenceTemporary.
getPointer());
360 ReferenceTemporary, E->
getType(),
366 llvm_unreachable(
"temporary cannot have dynamic storage duration");
388 auto AS = AddrSpace.getValue();
389 auto *GV =
new llvm::GlobalVariable(
391 llvm::GlobalValue::PrivateLinkage, Init,
".ref.tmp",
nullptr,
392 llvm::GlobalValue::NotThreadLocal,
395 GV->setAlignment(alignment.getQuantity());
396 llvm::Constant *C = GV;
398 C = TCG.performAddrSpaceCast(
400 GV->getValueType()->getPointerTo(
413 llvm_unreachable(
"temporary can't have dynamic storage duration");
415 llvm_unreachable(
"unknown storage duration");
424 "Reference should never be pseudo-strong!");
432 if (
auto *Var = dyn_cast<llvm::GlobalVariable>(Object.
getPointer())) {
433 Object =
Address(llvm::ConstantExpr::getBitCast(Var,
444 if (Var->hasInitializer())
453 default: llvm_unreachable(
"expected scalar or aggregate expression");
476 for (
const auto &Ignored : CommaLHSs)
479 if (
const auto *opaque = dyn_cast<OpaqueValueExpr>(E)) {
480 if (opaque->getType()->isRecordType()) {
481 assert(Adjustments.empty());
489 if (
auto *Var = dyn_cast<llvm::GlobalVariable>(
491 Object =
Address(llvm::ConstantExpr::getBitCast(
498 if (!Var->hasInitializer()) {
514 if (!ShouldEmitLifetimeMarkers)
524 CGBuilderTy::InsertPoint OldIP;
527 OldConditional = OutermostConditional;
528 OutermostConditional =
nullptr;
532 Builder.restoreIP(CGBuilderTy::InsertPoint(
533 Block, llvm::BasicBlock::iterator(Block->back())));
543 if (OldConditional) {
544 OutermostConditional = OldConditional;
560 for (
unsigned I = Adjustments.size(); I != 0; --I) {
562 switch (Adjustment.
Kind) {
574 assert(LV.isSimple() &&
575 "materialized temporary field is not a simple lvalue");
576 Object = LV.getAddress();
616 const llvm::Constant *Elts) {
617 return cast<llvm::ConstantInt>(Elts->getAggregateElement(Idx))
624 llvm::Value *KMul = Builder.getInt64(0x9ddfea08eb382d69ULL);
626 llvm::Value *A0 = Builder.CreateMul(Builder.CreateXor(Low, High), KMul);
627 llvm::Value *A1 = Builder.CreateXor(Builder.CreateLShr(A0, K47), A0);
628 llvm::Value *B0 = Builder.CreateMul(Builder.CreateXor(High, A1), KMul);
629 llvm::Value *B1 = Builder.CreateXor(Builder.CreateLShr(B0, K47), B0);
630 return Builder.CreateMul(B1, KMul);
663 if (Ptr->getType()->getPointerAddressSpace())
674 llvm::BasicBlock *Done =
nullptr;
680 dyn_cast<llvm::AllocaInst>(Ptr->stripPointerCastsNoFollowAliases());
684 bool IsGuaranteedNonNull =
685 SkippedChecks.
has(SanitizerKind::Null) || PtrToAlloca;
687 if ((
SanOpts.
has(SanitizerKind::Null) || AllowNullPointers) &&
688 !IsGuaranteedNonNull) {
690 IsNonNull =
Builder.CreateIsNotNull(Ptr);
694 IsGuaranteedNonNull = IsNonNull == True;
697 if (!IsGuaranteedNonNull) {
698 if (AllowNullPointers) {
703 Builder.CreateCondBr(IsNonNull, Rest, Done);
706 Checks.push_back(std::make_pair(IsNonNull, SanitizerKind::Null));
712 !SkippedChecks.
has(SanitizerKind::ObjectSize) &&
726 Builder.CreateCall(F, {CastAddr, Min, NullIsUnknown}),
727 llvm::ConstantInt::get(
IntPtrTy, Size));
728 Checks.push_back(std::make_pair(LargeEnough, SanitizerKind::ObjectSize));
731 uint64_t AlignVal = 0;
735 !SkippedChecks.
has(SanitizerKind::Alignment)) {
742 (!PtrToAlloca || PtrToAlloca->getAlignment() < AlignVal)) {
745 PtrAsInt, llvm::ConstantInt::get(
IntPtrTy, AlignVal - 1));
749 Checks.push_back(std::make_pair(Aligned, SanitizerKind::Alignment));
753 if (Checks.size() > 0) {
756 assert(!AlignVal || (uint64_t)1 << llvm::Log2_64(AlignVal) == AlignVal);
757 llvm::Constant *StaticData[] = {
759 llvm::ConstantInt::get(
Int8Ty, AlignVal ? llvm::Log2_64(AlignVal) : 1),
760 llvm::ConstantInt::get(
Int8Ty, TCK)};
761 EmitCheck(Checks, SanitizerHandler::TypeMismatch, StaticData,
762 PtrAsInt ? PtrAsInt : Ptr);
777 if (!IsGuaranteedNonNull) {
779 IsNonNull =
Builder.CreateIsNotNull(Ptr);
783 Builder.CreateCondBr(IsNonNull, VptrNotNull, Done);
793 llvm::raw_svector_ostream Out(MangledName);
799 SanitizerKind::Vptr, Out.str())) {
800 llvm::hash_code TypeHash = hash_value(Out.str());
813 const int CacheSize = 128;
816 "__ubsan_vptr_type_cache");
830 llvm::Constant *StaticData[] = {
834 llvm::ConstantInt::get(
Int8Ty, TCK)
837 EmitCheck(std::make_pair(EqualHash, SanitizerKind::Vptr),
838 SanitizerHandler::DynamicTypeCacheMiss, StaticData,
855 if (
const auto *CAT = dyn_cast<ConstantArrayType>(AT)) {
856 if (CAT->getSize().ugt(1))
858 }
else if (!isa<IncompleteArrayType>(AT))
864 if (
const auto *ME = dyn_cast<MemberExpr>(E)) {
867 if (
const auto *FD = dyn_cast<FieldDecl>(ME->getMemberDecl())) {
870 return ++FI == FD->getParent()->field_end();
872 }
else if (
const auto *IRE = dyn_cast<ObjCIvarRefExpr>(E)) {
873 return IRE->getDecl()->getNextIvar() ==
nullptr;
890 auto *ParamDecl = dyn_cast<
ParmVarDecl>(ArrayDeclRef->getDecl());
894 auto *POSAttr = ParamDecl->
getAttr<PassObjectSizeAttr>();
899 int POSType = POSAttr->getType();
900 if (POSType != 0 && POSType != 1)
904 auto PassedSizeIt = SizeArguments.find(ParamDecl);
905 if (PassedSizeIt == SizeArguments.end())
909 assert(LocalDeclMap.count(PassedSizeDecl) &&
"Passed size not loadable");
910 Address AddrOfSize = LocalDeclMap.find(PassedSizeDecl)->second;
914 llvm::ConstantInt::get(SizeInBytes->getType(), EltSize);
915 return Builder.CreateUDiv(SizeInBytes, SizeOfElement);
925 return CGF.
Builder.getInt32(VT->getNumElements());
930 if (
const auto *CE = dyn_cast<CastExpr>(Base)) {
931 if (CE->getCastKind() == CK_ArrayToPointerDecay &&
933 IndexedType = CE->getSubExpr()->getType();
935 if (
const auto *CAT = dyn_cast<ConstantArrayType>(AT))
936 return CGF.
Builder.getInt(CAT->getSize());
937 else if (
const auto *VAT = dyn_cast<VariableArrayType>(AT))
955 assert(
SanOpts.
has(SanitizerKind::ArrayBounds) &&
956 "should not be called unless adding bounds checks");
968 llvm::Constant *StaticData[] = {
974 :
Builder.CreateICmpULE(IndexVal, BoundVal);
975 EmitCheck(std::make_pair(Check, SanitizerKind::ArrayBounds),
976 SanitizerHandler::OutOfBounds, StaticData, Index);
982 bool isInc,
bool isPre) {
986 if (isa<llvm::IntegerType>(InVal.first->getType())) {
987 uint64_t AmountVal = isInc ? 1 : -1;
988 NextVal = llvm::ConstantInt::get(InVal.first->getType(), AmountVal,
true);
991 NextVal =
Builder.CreateAdd(InVal.first, NextVal, isInc ?
"inc" :
"dec");
994 llvm::APFloat FVal(
getContext().getFloatTypeSemantics(ElemTy), 1);
1000 NextVal =
Builder.CreateFAdd(InVal.first, NextVal, isInc ?
"inc" :
"dec");
1010 return isPre ? IncVal : InVal;
1020 DI->EmitExplicitCastType(E->
getType());
1038 if (
const CastExpr *CE = dyn_cast<CastExpr>(E)) {
1039 if (
const auto *ECE = dyn_cast<ExplicitCastExpr>(CE))
1042 switch (CE->getCastKind()) {
1046 case CK_AddressSpaceConversion:
1047 if (
auto PtrTy = CE->getSubExpr()->getType()->getAs<
PointerType>()) {
1048 if (PtrTy->getPointeeType()->isVoidType())
1056 if (BaseInfo) *BaseInfo = InnerBaseInfo;
1057 if (TBAAInfo) *TBAAInfo = InnerTBAAInfo;
1059 if (isa<ExplicitCastExpr>(CE)) {
1063 &TargetTypeBaseInfo,
1064 &TargetTypeTBAAInfo);
1067 TargetTypeTBAAInfo);
1077 if (
SanOpts.
has(SanitizerKind::CFIUnrelatedCast) &&
1078 CE->getCastKind() == CK_BitCast) {
1085 return CE->getCastKind() != CK_AddressSpaceConversion
1093 case CK_ArrayToPointerDecay:
1097 case CK_UncheckedDerivedToBase:
1098 case CK_DerivedToBase: {
1105 auto Derived = CE->getSubExpr()->
getType()->getPointeeCXXRecordDecl();
1107 CE->path_begin(), CE->path_end(),
1121 if (UO->getOpcode() == UO_AddrOf) {
1160 llvm_unreachable(
"bad evaluation kind");
1179 while (!isa<CXXThisExpr>(Base)) {
1181 if (isa<CXXDynamicCastExpr>(Base))
1184 if (
const auto *CE = dyn_cast<CastExpr>(Base)) {
1185 Base = CE->getSubExpr();
1186 }
else if (
const auto *PE = dyn_cast<ParenExpr>(Base)) {
1187 Base = PE->getSubExpr();
1188 }
else if (
const auto *UO = dyn_cast<UnaryOperator>(Base)) {
1189 if (UO->getOpcode() == UO_Extension)
1190 Base = UO->getSubExpr();
1202 if (
SanOpts.
has(SanitizerKind::ArrayBounds) && isa<ArraySubscriptExpr>(E))
1208 if (
const auto *ME = dyn_cast<MemberExpr>(E)) {
1211 SkippedChecks.
set(SanitizerKind::Alignment,
true);
1212 if (IsBaseCXXThis || isa<DeclRefExpr>(ME->getBase()))
1213 SkippedChecks.
set(SanitizerKind::Null,
true);
1241 case Expr::ObjCPropertyRefExprClass:
1242 llvm_unreachable(
"cannot emit a property reference directly");
1244 case Expr::ObjCSelectorExprClass:
1246 case Expr::ObjCIsaExprClass:
1248 case Expr::BinaryOperatorClass:
1250 case Expr::CompoundAssignOperatorClass: {
1253 Ty = AT->getValueType();
1258 case Expr::CallExprClass:
1259 case Expr::CXXMemberCallExprClass:
1260 case Expr::CXXOperatorCallExprClass:
1261 case Expr::UserDefinedLiteralClass:
1263 case Expr::VAArgExprClass:
1265 case Expr::DeclRefExprClass:
1267 case Expr::ConstantExprClass:
1268 return EmitLValue(cast<ConstantExpr>(E)->getSubExpr());
1269 case Expr::ParenExprClass:
1270 return EmitLValue(cast<ParenExpr>(E)->getSubExpr());
1271 case Expr::GenericSelectionExprClass:
1272 return EmitLValue(cast<GenericSelectionExpr>(E)->getResultExpr());
1273 case Expr::PredefinedExprClass:
1275 case Expr::StringLiteralClass:
1277 case Expr::ObjCEncodeExprClass:
1279 case Expr::PseudoObjectExprClass:
1281 case Expr::InitListExprClass:
1283 case Expr::CXXTemporaryObjectExprClass:
1284 case Expr::CXXConstructExprClass:
1286 case Expr::CXXBindTemporaryExprClass:
1288 case Expr::CXXUuidofExprClass:
1290 case Expr::LambdaExprClass:
1293 case Expr::ExprWithCleanupsClass: {
1294 const auto *cleanups = cast<ExprWithCleanups>(E);
1311 case Expr::CXXDefaultArgExprClass:
1312 return EmitLValue(cast<CXXDefaultArgExpr>(E)->getExpr());
1313 case Expr::CXXDefaultInitExprClass: {
1315 return EmitLValue(cast<CXXDefaultInitExpr>(E)->getExpr());
1317 case Expr::CXXTypeidExprClass:
1320 case Expr::ObjCMessageExprClass:
1322 case Expr::ObjCIvarRefExprClass:
1324 case Expr::StmtExprClass:
1326 case Expr::UnaryOperatorClass:
1328 case Expr::ArraySubscriptExprClass:
1330 case Expr::OMPArraySectionExprClass:
1332 case Expr::ExtVectorElementExprClass:
1334 case Expr::MemberExprClass:
1336 case Expr::CompoundLiteralExprClass:
1338 case Expr::ConditionalOperatorClass:
1340 case Expr::BinaryConditionalOperatorClass:
1342 case Expr::ChooseExprClass:
1343 return EmitLValue(cast<ChooseExpr>(E)->getChosenSubExpr());
1344 case Expr::OpaqueValueExprClass:
1346 case Expr::SubstNonTypeTemplateParmExprClass:
1347 return EmitLValue(cast<SubstNonTypeTemplateParmExpr>(E)->getReplacement());
1348 case Expr::ImplicitCastExprClass:
1349 case Expr::CStyleCastExprClass:
1350 case Expr::CXXFunctionalCastExprClass:
1351 case Expr::CXXStaticCastExprClass:
1352 case Expr::CXXDynamicCastExprClass:
1353 case Expr::CXXReinterpretCastExprClass:
1354 case Expr::CXXConstCastExprClass:
1355 case Expr::ObjCBridgedCastExprClass:
1358 case Expr::MaterializeTemporaryExprClass:
1361 case Expr::CoawaitExprClass:
1363 case Expr::CoyieldExprClass:
1376 if (!qs.hasConst() || qs.hasVolatile())
return false;
1380 if (
const auto *RT = dyn_cast<RecordType>(type))
1381 if (
const auto *RD = dyn_cast<CXXRecordDecl>(RT->getDecl()))
1382 if (RD->hasMutableFields() || !RD->isTrivial())
1403 if (
const auto *ref = dyn_cast<ReferenceType>(type)) {
1424 if (isa<ParmVarDecl>(value)) {
1426 }
else if (
auto *var = dyn_cast<VarDecl>(value)) {
1428 }
else if (isa<EnumConstantDecl>(value)) {
1436 bool resultIsReference;
1442 resultIsReference =
false;
1443 resultType = refExpr->
getType();
1448 resultIsReference =
true;
1449 resultType = value->
getType();
1462 result.
Val, resultType);
1466 if (isa<VarDecl>(value)) {
1470 assert(isa<EnumConstantDecl>(value));
1475 if (resultIsReference)
1502 assert(Constant &&
"not a constant");
1522 return ET->getDecl()->getIntegerType()->isBooleanType();
1531 llvm::APInt &Min, llvm::APInt &
End,
1532 bool StrictEnums,
bool IsBool) {
1534 bool IsRegularCPlusPlusEnum = CGF.
getLangOpts().CPlusPlus && StrictEnums &&
1536 if (!IsBool && !IsRegularCPlusPlusEnum)
1545 unsigned Bitwidth = LTy->getScalarSizeInBits();
1549 if (NumNegativeBits) {
1550 unsigned NumBits =
std::max(NumNegativeBits, NumPositiveBits + 1);
1551 assert(NumBits <= Bitwidth);
1552 End = llvm::APInt(Bitwidth, 1) << (NumBits - 1);
1555 assert(NumPositiveBits <= Bitwidth);
1556 End = llvm::APInt(Bitwidth, 1) << NumPositiveBits;
1557 Min = llvm::APInt(Bitwidth, 0);
1563 llvm::MDNode *CodeGenFunction::getRangeForLoadFromType(
QualType Ty) {
1564 llvm::APInt Min,
End;
1570 return MDHelper.createRange(Min, End);
1575 bool HasBoolCheck =
SanOpts.
has(SanitizerKind::Bool);
1576 bool HasEnumCheck =
SanOpts.
has(SanitizerKind::Enum);
1577 if (!HasBoolCheck && !HasEnumCheck)
1582 bool NeedsBoolCheck = HasBoolCheck && IsBool;
1583 bool NeedsEnumCheck = HasEnumCheck && Ty->
getAs<
EnumType>();
1584 if (!NeedsBoolCheck && !NeedsEnumCheck)
1591 cast<llvm::IntegerType>(Value->getType())->getBitWidth() == 1)
1594 llvm::APInt Min,
End;
1603 Check =
Builder.CreateICmpULE(Value, llvm::ConstantInt::get(Ctx, End));
1606 Builder.CreateICmpSLE(Value, llvm::ConstantInt::get(Ctx, End));
1608 Builder.CreateICmpSGE(Value, llvm::ConstantInt::get(Ctx, Min));
1609 Check =
Builder.CreateAnd(Upper, Lower);
1614 NeedsEnumCheck ? SanitizerKind::Enum : SanitizerKind::Bool;
1615 EmitCheck(std::make_pair(Check, Kind), SanitizerHandler::LoadInvalidValue,
1625 bool isNontemporal) {
1631 const auto *VTy = cast<llvm::VectorType>(EltTy);
1634 if (VTy->getNumElements() == 3) {
1637 llvm::VectorType *vec4Ty =
1638 llvm::VectorType::get(VTy->getElementType(), 4);
1644 V =
Builder.CreateShuffleVector(V, llvm::UndefValue::get(vec4Ty),
1645 {0, 1, 2},
"extractVec");
1659 if (isNontemporal) {
1660 llvm::MDNode *
Node = llvm::MDNode::get(
1661 Load->getContext(), llvm::ConstantAsMetadata::get(
Builder.getInt32(1)));
1671 if (llvm::MDNode *RangeInfo = getRangeForLoadFromType(Ty))
1672 Load->setMetadata(llvm::LLVMContext::MD_range, RangeInfo);
1682 if (Value->getType()->isIntegerTy(1))
1685 "wrong value rep of bool");
1695 "wrong value rep of bool");
1696 return Builder.CreateTrunc(Value,
Builder.getInt1Ty(),
"tobool");
1706 bool isInit,
bool isNontemporal) {
1711 auto *VecTy = dyn_cast<llvm::VectorType>(SrcTy);
1713 if (VecTy && VecTy->getNumElements() == 3) {
1715 llvm::Constant *Mask[] = {
Builder.getInt32(0),
Builder.getInt32(1),
1717 llvm::UndefValue::get(
Builder.getInt32Ty())};
1718 llvm::Value *MaskV = llvm::ConstantVector::get(Mask);
1719 Value =
Builder.CreateShuffleVector(Value, llvm::UndefValue::get(VecTy),
1720 MaskV,
"extractVec");
1721 SrcTy = llvm::VectorType::get(VecTy->getElementType(), 4);
1740 if (isNontemporal) {
1741 llvm::MDNode *
Node =
1742 llvm::MDNode::get(Store->getContext(),
1743 llvm::ConstantAsMetadata::get(
Builder.getInt32(1)));
1802 assert(LV.
isBitField() &&
"Unknown LValue type!");
1820 Val =
Builder.CreateShl(Val, HighBits,
"bf.shl");
1821 if (Info.
Offset + HighBits)
1822 Val =
Builder.CreateAShr(Val, Info.
Offset + HighBits,
"bf.ashr");
1857 for (
unsigned i = 0; i != NumResultElts; ++i)
1860 llvm::Value *MaskV = llvm::ConstantVector::get(Mask);
1861 Vec =
Builder.CreateShuffleVector(Vec, llvm::UndefValue::get(Vec->getType()),
1873 Address CastToPointerElement =
1875 "conv.ptr.element");
1885 return VectorBasePtrPlusIx;
1891 "Bad type for register variable");
1892 llvm::MDNode *RegName = cast<llvm::MDNode>(
1893 cast<llvm::MetadataAsValue>(LV.
getGlobalReg())->getMetadata());
1898 if (OrigTy->isPointerTy())
1904 F, llvm::MetadataAsValue::get(Ty->getContext(), RegName));
1905 if (OrigTy->isPointerTy())
1906 Call =
Builder.CreateIntToPtr(Call, OrigTy);
1936 assert(Dst.
isBitField() &&
"Unknown LValue type");
1944 llvm_unreachable(
"present but none");
1991 RHS =
Builder.CreatePtrToInt(RHS, ResultType,
"sub.ptr.rhs.cast");
1994 "sub.ptr.lhs.cast");
2007 assert(Src.
isScalar() &&
"Can't emit an agg store with this method");
2021 SrcVal =
Builder.CreateIntCast(SrcVal, Ptr.getElementType(),
2034 SrcVal =
Builder.CreateAnd(SrcVal,
2050 SrcVal =
Builder.CreateOr(Val, SrcVal,
"bf.set");
2052 assert(Info.
Offset == 0);
2067 ResultVal =
Builder.CreateShl(ResultVal, HighBits,
"bf.result.shl");
2068 ResultVal =
Builder.CreateAShr(ResultVal, HighBits,
"bf.result.ashr");
2089 unsigned NumSrcElts = VTy->getNumElements();
2090 unsigned NumDstElts = Vec->getType()->getVectorNumElements();
2091 if (NumDstElts == NumSrcElts) {
2096 for (
unsigned i = 0; i != NumSrcElts; ++i)
2099 llvm::Value *MaskV = llvm::ConstantVector::get(Mask);
2100 Vec =
Builder.CreateShuffleVector(SrcVal,
2101 llvm::UndefValue::get(Vec->getType()),
2103 }
else if (NumDstElts > NumSrcElts) {
2109 for (
unsigned i = 0; i != NumSrcElts; ++i)
2110 ExtMask.push_back(
Builder.getInt32(i));
2111 ExtMask.resize(NumDstElts, llvm::UndefValue::get(
Int32Ty));
2112 llvm::Value *ExtMaskV = llvm::ConstantVector::get(ExtMask);
2114 Builder.CreateShuffleVector(SrcVal,
2115 llvm::UndefValue::get(SrcVal->getType()),
2119 for (
unsigned i = 0; i != NumDstElts; ++i)
2120 Mask.push_back(
Builder.getInt32(i));
2129 for (
unsigned i = 0; i != NumSrcElts; ++i)
2131 llvm::Value *MaskV = llvm::ConstantVector::get(Mask);
2132 Vec =
Builder.CreateShuffleVector(Vec, ExtSrcVal, MaskV);
2135 llvm_unreachable(
"unexpected shorten vector length");
2141 Vec =
Builder.CreateInsertElement(Vec, SrcVal, Elt);
2151 "Bad type for register variable");
2152 llvm::MDNode *RegName = cast<llvm::MDNode>(
2153 cast<llvm::MetadataAsValue>(Dst.
getGlobalReg())->getMetadata());
2154 assert(RegName &&
"Register LValue is not metadata");
2159 if (OrigTy->isPointerTy())
2165 if (OrigTy->isPointerTy())
2166 Value =
Builder.CreatePtrToInt(Value, Ty);
2168 F, {llvm::MetadataAsValue::get(Ty->getContext(), RegName), Value});
2176 bool IsMemberAccess=
false) {
2180 if (isa<ObjCIvarRefExpr>(E)) {
2193 auto *Exp = cast<ObjCIvarRefExpr>(
const_cast<Expr *
>(E));
2199 if (
const auto *Exp = dyn_cast<DeclRefExpr>(E)) {
2200 if (
const auto *VD = dyn_cast<VarDecl>(Exp->getDecl())) {
2201 if (VD->hasGlobalStorage()) {
2210 if (
const auto *Exp = dyn_cast<UnaryOperator>(E)) {
2215 if (
const auto *Exp = dyn_cast<ParenExpr>(E)) {
2229 if (
const auto *Exp = dyn_cast<GenericSelectionExpr>(E)) {
2234 if (
const auto *Exp = dyn_cast<ImplicitCastExpr>(E)) {
2239 if (
const auto *Exp = dyn_cast<CStyleCastExpr>(E)) {
2244 if (
const auto *Exp = dyn_cast<ObjCBridgedCastExpr>(E)) {
2249 if (
const auto *Exp = dyn_cast<ArraySubscriptExpr>(E)) {
2262 if (
const auto *Exp = dyn_cast<MemberExpr>(E)) {
2274 StringRef Name = StringRef()) {
2275 unsigned AS = cast<llvm::PointerType>(V->getType())->getAddressSpace();
2290 OMPDeclareTargetDeclAttr::isDeclareTargetDeclaration(VD);
2291 if (!Res || *Res == OMPDeclareTargetDeclAttr::MT_To)
2293 assert(*Res == OMPDeclareTargetDeclAttr::MT_Link &&
"Expected link clause");
2308 PointeeBaseInfo, PointeeTBAAInfo,
2319 PointeeBaseInfo, PointeeTBAAInfo);
2364 VD->
hasAttr<OMPThreadPrivateDeclAttr>()) {
2378 if (FD->
hasAttr<WeakRefAttr>()) {
2393 V = llvm::ConstantExpr::getBitCast(V,
2423 AsmLabelAttr *Asm = VD->
getAttr<AsmLabelAttr>();
2424 assert(Asm->getLabel().size() < 64-Name.size() &&
2425 "Register name too big");
2426 Name.append(Asm->getLabel());
2427 llvm::NamedMDNode *M =
2428 CGM.
getModule().getOrInsertNamedMetadata(Name);
2429 if (M->getNumOperands() == 0) {
2432 llvm::Metadata *Ops[] = {Str};
2439 llvm::MetadataAsValue::get(CGM.
getLLVMContext(), M->getOperand(0));
2447 if (
const auto *VD = dyn_cast<VarDecl>(ND)) {
2450 VD->hasAttr<AsmLabelAttr>() && !VD->isLocalVarDecl())
2455 const Expr *Init = VD->getAnyInitializer(VD);
2456 const auto *BD = dyn_cast_or_null<BlockDecl>(
CurCodeDecl);
2458 VD->isUsableInConstantExpressions(
getContext()) &&
2459 VD->checkInitIsICE() &&
2463 (LocalDeclMap.count(VD->getCanonicalDecl()) ||
2466 (BD && BD->capturesVariable(VD))))) {
2467 llvm::Constant *Val =
2469 *VD->evaluateValue(),
2471 assert(Val &&
"failed to emit reference constant expression");
2484 VD = VD->getCanonicalDecl();
2488 auto I = LocalDeclMap.find(VD);
2489 if (I != LocalDeclMap.end()) {
2490 if (VD->getType()->isReferenceType())
2513 assert((ND->
isUsed(
false) || !isa<VarDecl>(ND) ||
2515 "Should not use decl without marking it used!");
2517 if (ND->
hasAttr<WeakRefAttr>()) {
2518 const auto *VD = cast<ValueDecl>(ND);
2523 if (
const auto *VD = dyn_cast<VarDecl>(ND)) {
2525 if (VD->hasLinkage() || VD->isStaticDataMember())
2531 auto iter = LocalDeclMap.find(VD);
2532 if (iter != LocalDeclMap.end()) {
2533 addr = iter->second;
2537 }
else if (VD->isStaticLocal()) {
2544 llvm_unreachable(
"DeclRefExpr for Decl not entered in LocalDeclMap?");
2550 VD->hasAttr<OMPThreadPrivateDeclAttr>()) {
2557 bool isBlockByref = VD->isEscapingByref();
2567 bool isLocalStorage = VD->hasLocalStorage();
2569 bool NonGCable = isLocalStorage &&
2570 !VD->getType()->isReferenceType() &&
2577 bool isImpreciseLifetime =
2578 (isLocalStorage && !VD->hasAttr<ObjCPreciseLifetimeAttr>());
2579 if (isImpreciseLifetime)
2585 if (
const auto *FD = dyn_cast<FunctionDecl>(ND))
2591 if (
const auto *BD = dyn_cast<BindingDecl>(ND))
2594 llvm_unreachable(
"Unhandled DeclRefExpr");
2604 default: llvm_unreachable(
"Unknown unary operator lvalue!");
2607 assert(!T.
isNull() &&
"CodeGenFunction::EmitUnaryOpLValue: Illegal type");
2629 assert(LV.
isSimple() &&
"real/imag on non-ordinary l-value");
2653 bool isInc = E->
getOpcode() == UO_PreInc;
2676 assert(SL !=
nullptr &&
"No StringLiteral name in PredefinedExpr");
2677 StringRef FnName =
CurFn->getName();
2678 if (FnName.startswith(
"\01"))
2679 FnName = FnName.substr(1);
2680 StringRef NameItems[] = {
2682 std::string GVName = llvm::join(NameItems, NameItems + 2,
".");
2683 if (
auto *BD = dyn_cast_or_null<BlockDecl>(
CurCodeDecl)) {
2684 std::string Name = SL->getString();
2685 if (!Name.empty()) {
2686 unsigned Discriminator =
2689 Name +=
"_" + Twine(Discriminator + 1).str();
2715 uint16_t TypeKind = -1;
2732 StringRef(), StringRef(), None, Buffer,
2735 llvm::Constant *Components[] = {
2739 llvm::Constant *Descriptor = llvm::ConstantStruct::getAnon(Components);
2741 auto *GV =
new llvm::GlobalVariable(
2743 true, llvm::GlobalVariable::PrivateLinkage, Descriptor);
2744 GV->setUnnamedAddr(llvm::GlobalValue::UnnamedAddr::Global);
2756 if (V->getType() == TargetTy)
2761 if (V->getType()->isFloatingPointTy()) {
2762 unsigned Bits = V->getType()->getPrimitiveSizeInBits();
2763 if (Bits <= TargetTy->getIntegerBitWidth())
2769 if (V->getType()->isIntegerTy() &&
2770 V->getType()->getIntegerBitWidth() <= TargetTy->getIntegerBitWidth())
2771 return Builder.CreateZExt(V, TargetTy);
2774 if (!V->getType()->isPointerTy()) {
2779 return Builder.CreatePtrToInt(V, TargetTy);
2799 int PathComponentsToStrip =
2801 if (PathComponentsToStrip < 0) {
2802 assert(PathComponentsToStrip !=
INT_MIN);
2803 int PathComponentsToKeep = -PathComponentsToStrip;
2804 auto I = llvm::sys::path::rbegin(FilenameString);
2805 auto E = llvm::sys::path::rend(FilenameString);
2806 while (I != E && --PathComponentsToKeep)
2809 FilenameString = FilenameString.substr(I - E);
2810 }
else if (PathComponentsToStrip > 0) {
2811 auto I = llvm::sys::path::begin(FilenameString);
2812 auto E = llvm::sys::path::end(FilenameString);
2813 while (I != E && PathComponentsToStrip--)
2818 FilenameString.substr(I - llvm::sys::path::begin(FilenameString));
2820 FilenameString = llvm::sys::path::filename(FilenameString);
2825 cast<llvm::GlobalVariable>(FilenameGV.getPointer()));
2826 Filename = FilenameGV.getPointer();
2830 Filename = llvm::Constant::getNullValue(
Int8PtrTy);
2837 return llvm::ConstantStruct::getAnon(Data);
2854 assert(llvm::countPopulation(Kind) == 1);
2856 case SanitizerKind::Vptr:
2858 case SanitizerKind::Return:
2859 case SanitizerKind::Unreachable:
2862 return CheckRecoverableKind::Recoverable;
2867 struct SanitizerHandlerInfo {
2868 char const *
const Name;
2874 #define SANITIZER_CHECK(Enum, Name, Version) {#Name, Version}, 2876 #undef SANITIZER_CHECK 2880 llvm::FunctionType *FnType,
2884 llvm::BasicBlock *ContBB) {
2887 if (!CGF.
Builder.getCurrentDebugLocation()) {
2891 bool NeedsAbortSuffix =
2894 const SanitizerHandlerInfo &CheckInfo = SanitizerHandlers[CheckHandler];
2895 const StringRef CheckName = CheckInfo.Name;
2896 std::string FnName =
"__ubsan_handle_" + CheckName.str();
2897 if (CheckInfo.Version && !MinimalRuntime)
2898 FnName +=
"_v" + llvm::utostr(CheckInfo.Version);
2900 FnName +=
"_minimal";
2901 if (NeedsAbortSuffix)
2906 llvm::AttrBuilder B;
2908 B.addAttribute(llvm::Attribute::NoReturn)
2909 .addAttribute(llvm::Attribute::NoUnwind);
2911 B.addAttribute(llvm::Attribute::UWTable);
2916 llvm::AttributeList::FunctionIndex, B),
2920 HandlerCall->setDoesNotReturn();
2921 CGF.
Builder.CreateUnreachable();
2928 ArrayRef<std::pair<llvm::Value *, SanitizerMask>> Checked,
2932 assert(Checked.size() > 0);
2933 assert(CheckHandler >= 0 &&
2934 size_t(CheckHandler) < llvm::array_lengthof(SanitizerHandlers));
2935 const StringRef CheckName = SanitizerHandlers[CheckHandler].Name;
2940 for (
int i = 0, n = Checked.size(); i < n; ++i) {
2949 Cond = Cond ?
Builder.CreateAnd(Cond, Check) : Check;
2954 if (!FatalCond && !RecoverableCond)
2958 if (FatalCond && RecoverableCond)
2959 JointCond =
Builder.CreateAnd(FatalCond, RecoverableCond);
2961 JointCond = FatalCond ? FatalCond : RecoverableCond;
2967 for (
int i = 1, n = Checked.size(); i < n; ++i) {
2969 "All recoverable kinds in a single check must be same!");
2976 llvm::Instruction *Branch =
Builder.CreateCondBr(JointCond, Cont, Handlers);
2980 llvm::MDNode *
Node = MDHelper.createBranchWeights((1U << 20) - 1, 1);
2981 Branch->setMetadata(llvm::LLVMContext::MD_prof, Node);
2990 Args.reserve(DynamicArgs.size() + 1);
2991 ArgTypes.reserve(DynamicArgs.size() + 1);
2994 if (!StaticArgs.empty()) {
2995 llvm::Constant *Info = llvm::ConstantStruct::getAnon(StaticArgs);
2997 new llvm::GlobalVariable(
CGM.
getModule(), Info->getType(),
false,
2998 llvm::GlobalVariable::PrivateLinkage, Info);
2999 InfoPtr->setUnnamedAddr(llvm::GlobalValue::UnnamedAddr::Global);
3005 for (
size_t i = 0, n = DynamicArgs.size(); i != n; ++i) {
3011 llvm::FunctionType *FnType =
3012 llvm::FunctionType::get(
CGM.
VoidTy, ArgTypes,
false);
3014 if (!FatalCond || !RecoverableCond) {
3018 (FatalCond !=
nullptr), Cont);
3022 llvm::BasicBlock *NonFatalHandlerBB =
3025 Builder.CreateCondBr(FatalCond, NonFatalHandlerBB, FatalHandlerBB);
3043 llvm::BranchInst *BI =
Builder.CreateCondBr(Cond, Cont, CheckBB);
3046 llvm::MDNode *
Node = MDHelper.createBranchWeights((1U << 20) - 1, 1);
3047 BI->setMetadata(llvm::LLVMContext::MD_prof, Node);
3053 llvm::CallInst *CheckCall;
3054 llvm::Constant *SlowPathFn;
3056 llvm::Constant *Info = llvm::ConstantStruct::getAnon(StaticArgs);
3058 new llvm::GlobalVariable(
CGM.
getModule(), Info->getType(),
false,
3059 llvm::GlobalVariable::PrivateLinkage, Info);
3060 InfoPtr->setUnnamedAddr(llvm::GlobalValue::UnnamedAddr::Global);
3064 "__cfi_slowpath_diag",
3067 CheckCall =
Builder.CreateCall(
3073 CheckCall =
Builder.CreateCall(SlowPathFn, {TypeId, Ptr});
3076 CGM.
setDSOLocal(cast<llvm::GlobalValue>(SlowPathFn->stripPointerCasts()));
3077 CheckCall->setDoesNotThrow();
3086 auto &Ctx = M->getContext();
3089 llvm::GlobalValue::WeakAnyLinkage,
"__cfi_check", M);
3097 llvm::Intrinsic::getDeclaration(M, llvm::Intrinsic::trap),
"", BB);
3115 Args.push_back(&ArgData);
3116 Args.push_back(&ArgAddr);
3123 llvm::GlobalValue::WeakODRLinkage,
"__cfi_check_fail", &
CGM.
getModule());
3146 llvm::StructType *SourceLocationTy =
3148 llvm::StructType *CfiCheckFailDataTy =
3149 llvm::StructType::get(
Int8Ty, SourceLocationTy, VoidPtrTy);
3153 Builder.CreatePointerCast(Data, CfiCheckFailDataTy->getPointerTo(0)), 0,
3158 llvm::Value *AllVtables = llvm::MetadataAsValue::get(
3163 {Addr, AllVtables}),
3166 const std::pair<int, SanitizerMask> CheckKinds[] = {
3174 for (
auto CheckKindMaskPair : CheckKinds) {
3175 int Kind = CheckKindMaskPair.first;
3178 Builder.CreateICmpNE(CheckKind, llvm::ConstantInt::get(
Int8Ty, Kind));
3180 EmitCheck(std::make_pair(Cond, Mask), SanitizerHandler::CFICheckFail, {},
3181 {Data, Addr, ValidVtable});
3193 if (
SanOpts.
has(SanitizerKind::Unreachable)) {
3196 SanitizerKind::Unreachable),
3197 SanitizerHandler::BuiltinUnreachable,
3210 Builder.CreateCondBr(Checked, Cont, TrapBB);
3212 llvm::CallInst *TrapCall =
EmitTrapCall(llvm::Intrinsic::trap);
3213 TrapCall->setDoesNotReturn();
3214 TrapCall->setDoesNotThrow();
3217 Builder.CreateCondBr(Checked, Cont, TrapBB);
3227 auto A = llvm::Attribute::get(
getLLVMContext(),
"trap-func-name",
3229 TrapCall->addAttribute(llvm::AttributeList::FunctionIndex, A);
3239 "Array to pointer decay must have array source type!");
3243 Address Addr = LV.getAddress();
3253 assert(isa<llvm::ArrayType>(Addr.getElementType()) &&
3254 "Expected pointer to array");
3264 if (BaseInfo) *BaseInfo = LV.getBaseInfo();
3274 const auto *CE = dyn_cast<
CastExpr>(E);
3275 if (!CE || CE->getCastKind() != CK_ArrayToPointerDecay)
3279 const Expr *SubExpr = CE->getSubExpr();
3292 const llvm::Twine &name =
"arrayidx") {
3298 return CGF.
Builder.CreateGEP(ptr, indices, name);
3307 if (
auto constantIdx = dyn_cast<llvm::ConstantInt>(idx)) {
3308 CharUnits offset = constantIdx->getZExtValue() * eltSize;
3330 const llvm::Twine &name =
"arrayidx") {
3333 for (
auto idx : indices.drop_back())
3334 assert(isa<llvm::ConstantInt>(idx) &&
3335 cast<llvm::ConstantInt>(idx)->
isZero());
3350 CGF, addr.
getPointer(), indices, inbounds, signedIndices, loc, name);
3351 return Address(eltPtr, eltAlign);
3360 bool SignedIndices =
false;
3361 auto EmitIdxAfterBase = [&, IdxPre](
bool Promote) ->
llvm::Value * {
3364 assert(E->
getRHS() == E->
getIdx() &&
"index was neither LHS nor RHS");
3370 SignedIndices |= IdxSigned;
3376 if (Promote && Idx->getType() !=
IntPtrTy)
3386 !isa<ExtVectorElementExpr>(E->
getBase())) {
3389 auto *Idx = EmitIdxAfterBase(
false);
3390 assert(LHS.
isSimple() &&
"Can only subscript lvalue vectors here!");
3398 if (isa<ExtVectorElementExpr>(E->
getBase())) {
3400 auto *Idx = EmitIdxAfterBase(
true);
3419 auto *Idx = EmitIdxAfterBase(
true);
3429 Idx =
Builder.CreateMul(Idx, numElements);
3431 Idx =
Builder.CreateNSWMul(Idx, numElements);
3443 auto *Idx = EmitIdxAfterBase(
true);
3447 llvm::ConstantInt::get(Idx->getType(), InterfaceSize.
getQuantity());
3464 Addr =
Address(EltPtr, EltAlign);
3473 assert(Array->getType()->isArrayType() &&
3474 "Array to pointer decay must have array source type!");
3478 if (
const auto *ASE = dyn_cast<ArraySubscriptExpr>(Array))
3482 auto *Idx = EmitIdxAfterBase(
true);
3489 EltBaseInfo = ArrayLV.getBaseInfo();
3494 auto *Idx = EmitIdxAfterBase(
true);
3514 bool IsLowerBound) {
3531 "Expected pointer to array");
3551 bool IsLowerBound) {
3555 ResultExprTy = AT->getElementType();
3566 LowerBound->getType()->hasSignedIntegerRepresentation());
3568 Idx = llvm::ConstantInt::getNullValue(
IntPtrTy);
3575 llvm::APSInt ConstLength;
3578 if (Length->isIntegerConstantExpr(ConstLength, C)) {
3584 if (LowerBound && LowerBound->isIntegerConstantExpr(ConstLowerBound, C)) {
3586 LowerBound =
nullptr;
3590 else if (!LowerBound)
3593 if (Length || LowerBound) {
3594 auto *LowerBoundVal =
3598 LowerBound->getType()->hasSignedIntegerRepresentation())
3599 : llvm::ConstantInt::get(
IntPtrTy, ConstLowerBound);
3604 Length->getType()->hasSignedIntegerRepresentation())
3605 : llvm::ConstantInt::get(
IntPtrTy, ConstLength);
3606 Idx =
Builder.CreateAdd(LowerBoundVal, LengthVal,
"lb_add_len",
3609 if (Length && LowerBound) {
3611 Idx, llvm::ConstantInt::get(
IntPtrTy, 1),
"idx_sub_1",
3615 Idx = llvm::ConstantInt::get(
IntPtrTy, ConstLength + ConstLowerBound);
3621 if (
auto *VAT = C.getAsVariableArrayType(ArrayTy)) {
3622 Length = VAT->getSizeExpr();
3623 if (Length->isIntegerConstantExpr(ConstLength, C))
3626 auto *CAT = C.getAsConstantArrayType(ArrayTy);
3627 ConstLength = CAT->getSize();
3630 auto *LengthVal =
Builder.CreateIntCast(
3632 Length->getType()->hasSignedIntegerRepresentation());
3634 LengthVal, llvm::ConstantInt::get(
IntPtrTy, 1),
"len_sub_1",
3639 Idx = llvm::ConstantInt::get(
IntPtrTy, ConstLength);
3648 if (
auto *VLA =
getContext().getAsVariableArrayType(ResultExprTy)) {
3654 BaseTy, VLA->getElementType(), IsLowerBound);
3663 Idx =
Builder.CreateMul(Idx, NumElements);
3665 Idx =
Builder.CreateNSWMul(Idx, NumElements);
3674 assert(Array->getType()->isArrayType() &&
3675 "Array to pointer decay must have array source type!");
3679 if (
const auto *ASE = dyn_cast<ArraySubscriptExpr>(Array))
3689 BaseInfo = ArrayLV.getBaseInfo();
3693 TBAAInfo, BaseTy, ResultExprTy,
3716 Base =
MakeAddrLValue(Ptr, PT->getPointeeType(), BaseInfo, TBAAInfo);
3717 Base.getQuals().removeObjCGCAttr();
3726 "Result must be a vector");
3744 llvm::Constant *CV =
3749 assert(Base.
isExtVectorElt() &&
"Can only subscript lvalue vec elts here!");
3754 for (
unsigned i = 0, e = Indices.size(); i != e; ++i)
3755 CElts.push_back(BaseElts->getAggregateElement(Indices[i]));
3756 llvm::Constant *CV = llvm::ConstantVector::get(CElts);
3778 SkippedChecks.
set(SanitizerKind::Alignment,
true);
3779 if (IsBaseCXXThis || isa<DeclRefExpr>(BaseExpr))
3780 SkippedChecks.
set(SanitizerKind::Null,
true);
3788 if (
auto *Field = dyn_cast<FieldDecl>(ND)) {
3794 if (
const auto *FD = dyn_cast<FunctionDecl>(ND))
3797 llvm_unreachable(
"Unhandled member declaration!");
3803 assert(cast<CXXMethodDecl>(
CurCodeDecl)->getParent()->isLambda());
3828 "LLVM field at index zero had non-zero offset?");
3843 if (RD->isDynamicClass())
3846 for (
const auto &
Base : RD->bases())
3850 for (
const FieldDecl *Field : RD->fields())
3905 assert(!FieldTBAAInfo.
Offset &&
3906 "Nonzero offset for an access with no base type!");
3919 FieldTBAAInfo.
Size =
3924 if (
auto *ClassDef = dyn_cast<CXXRecordDecl>(rec)) {
3926 ClassDef->isDynamicClass()) {
3939 assert(!FieldType->
isReferenceType() &&
"union has reference member");
3971 if (field->
hasAttr<AnnotateAttr>())
4033 assert(E->
isTransparent() &&
"non-transparent glvalue init list");
4041 const Expr *Operand) {
4042 if (
auto *ThrowExpr = dyn_cast<CXXThrowExpr>(Operand->
IgnoreParens())) {
4055 "Unexpected conditional operator!");
4065 if (!CondExprBool) std::swap(live, dead);
4090 if (lhs && !lhs->isSimple())
4093 lhsBlock =
Builder.GetInsertBlock();
4103 if (rhs && !rhs->isSimple())
4105 rhsBlock =
Builder.GetInsertBlock();
4110 llvm::PHINode *phi =
Builder.CreatePHI(lhs->getPointer()->getType(),
4112 phi->addIncoming(lhs->getPointer(), lhsBlock);
4113 phi->addIncoming(rhs->getPointer(), rhsBlock);
4114 Address result(phi,
std::min(lhs->getAlignment(), rhs->getAlignment()));
4116 std::max(lhs->getBaseInfo().getAlignmentSource(),
4117 rhs->getBaseInfo().getAlignmentSource());
4119 lhs->getTBAAInfo(), rhs->getTBAAInfo());
4123 assert((lhs || rhs) &&
4124 "both operands of glvalue conditional are throw-expressions?");
4125 return lhs ? *lhs : *rhs;
4140 case CK_ArrayToPointerDecay:
4141 case CK_FunctionToPointerDecay:
4142 case CK_NullToMemberPointer:
4143 case CK_NullToPointer:
4144 case CK_IntegralToPointer:
4145 case CK_PointerToIntegral:
4146 case CK_PointerToBoolean:
4147 case CK_VectorSplat:
4148 case CK_IntegralCast:
4149 case CK_BooleanToSignedIntegral:
4150 case CK_IntegralToBoolean:
4151 case CK_IntegralToFloating:
4152 case CK_FloatingToIntegral:
4153 case CK_FloatingToBoolean:
4154 case CK_FloatingCast:
4155 case CK_FloatingRealToComplex:
4156 case CK_FloatingComplexToReal:
4157 case CK_FloatingComplexToBoolean:
4158 case CK_FloatingComplexCast:
4159 case CK_FloatingComplexToIntegralComplex:
4160 case CK_IntegralRealToComplex:
4161 case CK_IntegralComplexToReal:
4162 case CK_IntegralComplexToBoolean:
4163 case CK_IntegralComplexCast:
4164 case CK_IntegralComplexToFloatingComplex:
4165 case CK_DerivedToBaseMemberPointer:
4166 case CK_BaseToDerivedMemberPointer:
4167 case CK_MemberPointerToBoolean:
4168 case CK_ReinterpretMemberPointer:
4169 case CK_AnyPointerToBlockPointerCast:
4170 case CK_ARCProduceObject:
4171 case CK_ARCConsumeObject:
4172 case CK_ARCReclaimReturnedObject:
4173 case CK_ARCExtendBlockObject:
4174 case CK_CopyAndAutoreleaseBlockObject:
4175 case CK_IntToOCLSampler:
4176 case CK_FixedPointCast:
4177 case CK_FixedPointToBoolean:
4181 llvm_unreachable(
"dependent cast kind in IR gen!");
4183 case CK_BuiltinFnToFnPtr:
4184 llvm_unreachable(
"builtin functions are handled elsewhere");
4187 case CK_NonAtomicToAtomic:
4188 case CK_AtomicToNonAtomic:
4194 const auto *DCE = cast<CXXDynamicCastExpr>(E);
4198 case CK_ConstructorConversion:
4199 case CK_UserDefinedConversion:
4200 case CK_CPointerToObjCPointerCast:
4201 case CK_BlockPointerToObjCPointerCast:
4203 case CK_LValueToRValue:
4206 case CK_UncheckedDerivedToBase:
4207 case CK_DerivedToBase: {
4210 auto *DerivedClassDecl = cast<CXXRecordDecl>(DerivedClassTy->
getDecl());
4213 Address This = LV.getAddress();
4228 case CK_BaseToDerived: {
4230 auto *DerivedClassDecl = cast<CXXRecordDecl>(DerivedClassTy->
getDecl());
4244 Derived.getPointer(), E->
getType());
4246 if (
SanOpts.
has(SanitizerKind::CFIDerivedCast))
4254 case CK_LValueBitCast: {
4256 const auto *CE = cast<ExplicitCastExpr>(E);
4263 if (
SanOpts.
has(SanitizerKind::CFIUnrelatedCast))
4271 case CK_AddressSpaceConversion: {
4280 case CK_ObjCObjectLValueCast: {
4287 case CK_ZeroToOCLOpaqueType:
4288 llvm_unreachable(
"NULL to OpenCL opaque type lvalue cast is not valid");
4291 llvm_unreachable(
"Unhandled lvalue cast kind?");
4303 llvm::DenseMap<const OpaqueValueExpr*,LValue>::iterator
4304 it = OpaqueLValues.find(e);
4306 if (it != OpaqueLValues.end())
4309 assert(e->
isUnique() &&
"LValue for a nonunique OVE hasn't been emitted");
4317 llvm::DenseMap<const OpaqueValueExpr*,RValue>::iterator
4318 it = OpaqueRValues.find(e);
4320 if (it != OpaqueRValues.end())
4323 assert(e->
isUnique() &&
"RValue for a nonunique OVE hasn't been emitted");
4344 llvm_unreachable(
"bad evaluation kind");
4357 if (
const auto *CE = dyn_cast<CXXMemberCallExpr>(E))
4360 if (
const auto *CE = dyn_cast<CUDAKernelCallExpr>(E))
4363 if (
const auto *CE = dyn_cast<CXXOperatorCallExpr>(E))
4365 dyn_cast_or_null<CXXMethodDecl>(CE->getCalleeDecl()))
4402 if (
auto ICE = dyn_cast<ImplicitCastExpr>(E)) {
4403 if (ICE->getCastKind() == CK_FunctionToPointerDecay ||
4404 ICE->getCastKind() == CK_BuiltinFnToFnPtr) {
4409 }
else if (
auto DRE = dyn_cast<DeclRefExpr>(E)) {
4410 if (
auto FD = dyn_cast<FunctionDecl>(DRE->getDecl())) {
4413 }
else if (
auto ME = dyn_cast<MemberExpr>(E)) {
4414 if (
auto FD = dyn_cast<FunctionDecl>(ME->getMemberDecl())) {
4420 }
else if (
auto NTTP = dyn_cast<SubstNonTypeTemplateParmExpr>(E)) {
4424 }
else if (
auto PDE = dyn_cast<CXXPseudoDestructorExpr>(E)) {
4441 if (
const auto *VD =
4446 CGCallee callee(calleeInfo, calleePtr);
4462 assert(E->
getOpcode() == BO_Assign &&
"unexpected binary l-value");
4497 llvm_unreachable(
"bad evaluation kind");
4508 "Can't have a scalar return unless the return type is a " 4521 &&
"binding l-value to type which needs a temporary");
4566 "Can't have a scalar return unless the return type is a " 4586 unsigned CVRQualifiers) {
4588 Ivar, CVRQualifiers);
4604 ObjectTy = BaseExpr->
getType();
4628 "Call must have function pointer type!");
4630 const Decl *TargetDecl =
4633 if (
const FunctionDecl *FD = dyn_cast_or_null<FunctionDecl>(TargetDecl))
4640 if (TargetDecl->hasAttr<AlwaysInlineAttr>() &&
4641 TargetDecl->hasAttr<TargetAttr>())
4646 auto PointeeType = cast<PointerType>(CalleeType)->getPointeeType();
4651 (!TargetDecl || !isa<FunctionDecl>(TargetDecl))) {
4652 if (llvm::Constant *PrefixSig =
4659 llvm::Constant *FTRTTIConst =
4662 llvm::StructType *PrefixStructTy = llvm::StructType::get(
4668 CalleePtr, llvm::PointerType::getUnqual(PrefixStructTy));
4670 Builder.CreateConstGEP2_32(PrefixStructTy, CalleePrefixStruct, 0, 0);
4677 Builder.CreateCondBr(CalleeSigMatch, TypeCheck, Cont);
4681 Builder.CreateConstGEP2_32(PrefixStructTy, CalleePrefixStruct, 0, 1);
4687 Builder.CreateICmpEQ(CalleeRTTI, FTRTTIConst);
4690 EmitCheck(std::make_pair(CalleeRTTIMatch, SanitizerKind::Function),
4691 SanitizerHandler::FunctionTypeMismatch, StaticData, CalleePtr);
4698 const auto *FnType = cast<FunctionType>(PointeeType);
4703 (!TargetDecl || !isa<FunctionDecl>(TargetDecl))) {
4718 CGM.
getIntrinsic(llvm::Intrinsic::type_test), {CastedCallee, TypeId});
4721 llvm::Constant *StaticData[] = {
4728 CastedCallee, StaticData);
4730 EmitCheck(std::make_pair(TypeTest, SanitizerKind::CFIICall),
4731 SanitizerHandler::CFICheckFail, StaticData,
4732 {CastedCallee, llvm::UndefValue::get(
IntPtrTy)});
4748 if (
auto *OCE = dyn_cast<CXXOperatorCallExpr>(E)) {
4749 if (OCE->isAssignmentOp())
4752 switch (OCE->getOperator()) {
4754 case OO_GreaterGreater:
4771 Args, FnType, Chain);
4793 if (isa<FunctionNoProtoType>(FnType) || Chain) {
4795 CalleeTy = CalleeTy->getPointerTo();
4825 return MakeAddrLValue(MemberAddr, MPT->getPointeeType(), BaseInfo, TBAAInfo);
4842 llvm_unreachable(
"bad evaluation kind");
4846 assert(Val->getType()->isFPOrFPVectorTy());
4847 if (Accuracy == 0.0 || !isa<llvm::Instruction>(Val))
4851 llvm::MDNode *
Node = MDHelper.createFPMath(Accuracy);
4853 cast<llvm::Instruction>(Val)->setMetadata(llvm::LLVMContext::MD_fpmath, Node);
4857 struct LValueOrRValue {
4871 LValueOrRValue result;
4875 const Expr *semantic = *i;
4879 if (
const auto *ov = dyn_cast<OpaqueValueExpr>(semantic)) {
4881 if (ov->isUnique()) {
4882 assert(ov != resultExpr &&
4883 "A unique OVE cannot be used as the result expression");
4891 if (ov == resultExpr && ov->
isRValue() && !forLValue &&
4896 opaqueData = OVMA::bind(CGF, ov, LV);
4901 opaqueData = OVMA::bind(CGF, ov, ov->getSourceExpr());
4904 if (ov == resultExpr) {
4912 opaques.push_back(opaqueData);
4916 }
else if (semantic == resultExpr) {
4929 for (
unsigned i = 0, e = opaques.size(); i != e; ++i)
4930 opaques[i].unbind(CGF);
const CGFunctionInfo & arrangeBuiltinFunctionDeclaration(QualType resultType, const FunctionArgList &args)
A builtin function is a freestanding function using the default C conventions.
const llvm::DataLayout & getDataLayout() const
TBAAAccessInfo getTBAAInfoForSubobject(LValue Base, QualType AccessType)
getTBAAInfoForSubobject - Get TBAA information for an access with a given base lvalue.
ReturnValueSlot - Contains the address where the return value of a function can be stored...
const internal::VariadicAllOfMatcher< Type > type
Matches Types in the clang AST.
SourceLocation getExprLoc() const LLVM_READONLY
bool EmitScalarRangeCheck(llvm::Value *Value, QualType Ty, SourceLocation Loc)
Check if the scalar Value is within the valid range for the given type Ty.
Defines the clang::ASTContext interface.
Represents a function declaration or definition.
llvm::Value * EmitARCStoreStrong(LValue lvalue, llvm::Value *value, bool resultIgnored)
Store into a strong object.
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 ...
Address getAddress() const
CharUnits getIntAlign() const
void end(CodeGenFunction &CGF)
Other implicit parameter.
LValue getReferenceLValue(CodeGenFunction &CGF, Expr *refExpr) const
bool isSignedOverflowDefined() const
no exception specification
LValue EmitComplexCompoundAssignmentLValue(const CompoundAssignOperator *E)
PointerType - C99 6.7.5.1 - Pointer Declarators.
QualType getPointeeType() const
enum clang::SubobjectAdjustment::@45 Kind
llvm::Constant * getValue() const
void setTypeDescriptorInMap(QualType Ty, llvm::Constant *C)
A (possibly-)qualified type.
const CGBitFieldInfo & getBitFieldInfo(const FieldDecl *FD) const
Return the BitFieldInfo that corresponds to the field FD.
bool isBlockPointerType() const
Address EmitCXXMemberDataPointerAddress(const Expr *E, Address base, llvm::Value *memberPtr, const MemberPointerType *memberPtrType, LValueBaseInfo *BaseInfo=nullptr, TBAAAccessInfo *TBAAInfo=nullptr)
Emit the address of a field using a member data pointer.
CodeGenTypes & getTypes()
ValueDecl * getMemberDecl() const
Retrieve the member declaration to which this expression refers.
Address CreateAddrSpaceCast(Address Addr, llvm::Type *Ty, const llvm::Twine &Name="")
bool sanitizePerformTypeCheck() const
Whether any type-checking sanitizers are enabled.
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.
const CodeGenOptions & getCodeGenOpts() const
SourceLocation getExprLoc() const
LValue EmitStmtExprLValue(const StmtExpr *E)
const Expr * skipRValueSubobjectAdjustments(SmallVectorImpl< const Expr *> &CommaLHS, SmallVectorImpl< SubobjectAdjustment > &Adjustments) const
Walk outwards from an expression we want to bind a reference to and find the expression whose lifetim...
Address CreateMemTemp(QualType T, const Twine &Name="tmp", Address *Alloca=nullptr)
CreateMemTemp - Create a temporary memory object of the given type, with appropriate alignmen and cas...
llvm::Value * getGlobalReg() const
llvm::Constant * EmitCheckTypeDescriptor(QualType T)
Emit a description of a type in a format suitable for passing to a runtime sanitizer handler...
void enterFullExpression(const FullExpr *E)
CGRecordLayout - This class handles struct and union layout info while lowering AST types to LLVM typ...
AlignmentSource
The source of the alignment of an l-value; an expression of confidence in the alignment actually matc...
bool isBlacklistedType(SanitizerMask Mask, StringRef MangledTypeName, StringRef Category=StringRef()) const
llvm::LLVMContext & getLLVMContext()
LValue EmitObjCIsaExpr(const ObjCIsaExpr *E)
const Expr * getInit(unsigned Init) const
ConstantAddress GetAddrOfConstantStringFromObjCEncode(const ObjCEncodeExpr *)
Return a pointer to a constant array for the given ObjCEncodeExpr node.
LValue EmitMaterializeTemporaryExpr(const MaterializeTemporaryExpr *E)
const ASTRecordLayout & getASTRecordLayout(const RecordDecl *D) const
Get or compute information about the layout of the specified record (struct/union/class) D...
bool isArithmeticType() const
SanitizerSet Sanitize
Set of enabled sanitizers.
void EmitStoreThroughGlobalRegLValue(RValue Src, LValue Dst)
Store of global named registers are always calls to intrinsics.
QualType getPointeeType() const
If this is a pointer, ObjC object pointer, or block pointer, this returns the respective pointee...
Address GetAddressOfDerivedClass(Address Value, const CXXRecordDecl *Derived, CastExpr::path_const_iterator PathBegin, CastExpr::path_const_iterator PathEnd, bool NullCheckValue)
Address EmitPointerWithAlignment(const Expr *Addr, LValueBaseInfo *BaseInfo=nullptr, TBAAAccessInfo *TBAAInfo=nullptr)
EmitPointerWithAlignment - Given an expression with a pointer type, emit the value and compute our be...
bool isRecordType() const
RValue EmitPseudoObjectRValue(const PseudoObjectExpr *e, AggValueSlot slot=AggValueSlot::ignored())
Decl - This represents one declaration (or definition), e.g.
static void pushTemporaryCleanup(CodeGenFunction &CGF, const MaterializeTemporaryExpr *M, const Expr *E, Address ReferenceTemporary)
void EmitTypeCheck(TypeCheckKind TCK, SourceLocation Loc, llvm::Value *V, QualType Type, CharUnits Alignment=CharUnits::Zero(), SanitizerSet SkippedChecks=SanitizerSet())
Emit a check that V is the address of storage of the appropriate size and alignment for an object of ...
void getEncodedElementAccess(SmallVectorImpl< uint32_t > &Elts) const
getEncodedElementAccess - Encode the elements accessed into an llvm aggregate Constant of ConstantInt...
llvm::MDNode * AccessType
AccessType - The final access type.
const Decl * CurCodeDecl
CurCodeDecl - This is the inner-most code context, which includes blocks.
llvm::Value * getTypeSize(QualType Ty)
Returns calculated size of the specified type.
const llvm::DataLayout & getDataLayout() const
bool isTransparent() const
Is this a transparent initializer list (that is, an InitListExpr that is purely syntactic, and whose semantics are that of the sole contained initializer)?
const CastExpr * BasePath
unsigned getFieldIndex() const
Returns the index of this field within its record, as appropriate for passing to ASTRecordLayout::get...
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...
const AstTypeMatcher< FunctionType > functionType
Matches FunctionType nodes.
Expr * getFalseExpr() const
static Destroyer destroyARCStrongPrecise
Expr * getLowerBound()
Get lower bound of array section.
const RecordDecl * getParent() const
Returns the parent of this field declaration, which is the struct in which this field is defined...
The base class of the type hierarchy.
void pushLifetimeExtendedDestroy(CleanupKind kind, Address addr, QualType type, Destroyer *destroyer, bool useEHCleanupForArray)
LValue EmitBinaryOperatorLValue(const BinaryOperator *E)
static void setObjCGCLValueClass(const ASTContext &Ctx, const Expr *E, LValue &LV, bool IsMemberAccess=false)
void EmitStoreThroughLValue(RValue Src, LValue Dst, bool isInit=false)
EmitStoreThroughLValue - Store the specified rvalue into the specified lvalue, where both are guarant...
void EmitComplexExprIntoLValue(const Expr *E, LValue dest, bool isInit)
EmitComplexExprIntoLValue - Emit the given expression of complex type and place its result into the s...
LValue EmitOpaqueValueLValue(const OpaqueValueExpr *e)
Represents an array type, per C99 6.7.5.2 - Array Declarators.
static llvm::Value * EmitBitCastOfLValueToProperType(CodeGenFunction &CGF, llvm::Value *V, llvm::Type *IRType, StringRef Name=StringRef())
virtual const FieldDecl * lookup(const VarDecl *VD) const
Lookup the captured field decl for a variable.
Represents a call to a C++ constructor.
RValue EmitCXXMemberCallExpr(const CXXMemberCallExpr *E, ReturnValueSlot ReturnValue)
static LValue EmitThreadPrivateVarDeclLValue(CodeGenFunction &CGF, const VarDecl *VD, QualType T, Address Addr, llvm::Type *RealVarTy, SourceLocation Loc)
The l-value was an access to a declared entity or something equivalently strong, like the address of ...
void EmitCfiCheckFail()
Emit a cross-DSO CFI failure handling function.
StorageDuration
The storage duration for an object (per C++ [basic.stc]).
Address EmitLoadOfPointer(Address Ptr, const PointerType *PtrTy, LValueBaseInfo *BaseInfo=nullptr, TBAAAccessInfo *TBAAInfo=nullptr)
llvm::Value * LoadPassedObjectSize(const Expr *E, QualType EltTy)
If E references a parameter with pass_object_size info or a constant array size modifier, emit the object size divided by the size of EltTy.
IdentKind getIdentKind() const
LValue EmitLValueForFieldInitialization(LValue Base, const FieldDecl *Field)
EmitLValueForFieldInitialization - Like EmitLValueForField, except that if the Field is a reference...
bool isZero(ProgramStateRef State, const NonLoc &Val)
llvm::IntegerType * Int8Ty
i8, i16, i32, and i64
Represents a prvalue temporary that is written into memory so that a reference can bind to it...
void EmitAtomicStore(RValue rvalue, LValue lvalue, bool isInit)
Address CreateMemTempWithoutCast(QualType T, const Twine &Name="tmp")
CreateMemTemp - Create a temporary memory object of the given type, with appropriate alignmen without...
bool ConstantFoldsToSimpleInteger(const Expr *Cond, bool &Result, bool AllowLabels=false)
ConstantFoldsToSimpleInteger - If the specified expression does not fold to a constant, or if it does but contains a label, return false.
QualType getElementType() const
static Destroyer destroyARCWeak
! Language semantics require left-to-right evaluation.
LValue EmitCXXUuidofLValue(const CXXUuidofExpr *E)
Address GetAddrOfLocalVar(const VarDecl *VD)
GetAddrOfLocalVar - Return the address of a local variable.
RValue EmitCall(const CGFunctionInfo &CallInfo, const CGCallee &Callee, ReturnValueSlot ReturnValue, const CallArgList &Args, llvm::Instruction **callOrInvoke, SourceLocation Loc)
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.
Represents a variable declaration or definition.
LValue EmitObjCEncodeExprLValue(const ObjCEncodeExpr *E)
Objects with "hidden" visibility are not seen by the dynamic linker.
static bool hasBooleanRepresentation(QualType Ty)
CompoundLiteralExpr - [C99 6.5.2.5].
RAII object to set/unset CodeGenFunction::IsSanitizerScope.
llvm::Value * getFunctionPointer() const
const internal::VariadicDynCastAllOfMatcher< Stmt, Expr > expr
Matches expressions.
bool isFixed() const
Returns true if this is an Objective-C, C++11, or Microsoft-style enumeration with a fixed underlying...
const T * getAs() const
Member-template getAs<specific type>'.
LValue EmitObjCSelectorLValue(const ObjCSelectorExpr *E)
const void * Store
Store - This opaque type encapsulates an immutable mapping from locations to values.
uint64_t getProfileCount(const Stmt *S)
Get the profiler's count for the given statement.
const ArrayType * castAsArrayTypeUnsafe() const
A variant of castAs<> for array type which silently discards qualifiers from the outermost type...
This class gathers all debug information during compilation and is responsible for emitting to llvm g...
static LValue MakeVectorElt(Address vecAddress, llvm::Value *Idx, QualType type, LValueBaseInfo BaseInfo, TBAAAccessInfo TBAAInfo)
DiagnosticsEngine & getDiags() const
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...
LValue EmitComplexAssignmentLValue(const BinaryOperator *E)
Emit an l-value for an assignment (simple or compound) of complex type.
llvm::Value * getPointer() const
virtual llvm::Constant * getUBSanFunctionSignature(CodeGen::CodeGenModule &CGM) const
Return a constant used by UBSan as a signature to identify functions possessing type information...
static ConstantEmission forValue(llvm::Constant *C)
bool IsSanitizerScope
True if CodeGen currently emits code implementing sanitizer checks.
static Address createReferenceTemporary(CodeGenFunction &CGF, const MaterializeTemporaryExpr *M, const Expr *Inner, Address *Alloca=nullptr)
static DeclRefExpr * tryToConvertMemberExprToDeclRefExpr(CodeGenFunction &CGF, const MemberExpr *ME)
llvm::Type * ConvertTypeForMem(QualType T)
ConvertTypeForMem - Convert type T into a llvm::Type.
RValue EmitCUDAKernelCallExpr(const CUDAKernelCallExpr *E, ReturnValueSlot ReturnValue)
bool hasDefinition() const
Represents a parameter to a function.
SanitizerSet SanitizeRecover
Set of sanitizer checks that are non-fatal (i.e.
void EmitStoreThroughBitfieldLValue(RValue Src, LValue Dst, llvm::Value **Result=nullptr)
EmitStoreThroughBitfieldLValue - Store Src into Dst with same constraints as EmitStoreThroughLValue.
unsigned getAddressSpace() const
Return the address space that this address resides in.
Address emitAddrOfImagComponent(Address complex, QualType complexType)
The collection of all-type qualifiers we support.
void add(RValue rvalue, QualType type)
bool isVariableArrayType() const
void EmitBoundsCheck(const Expr *E, const Expr *Base, llvm::Value *Index, QualType IndexType, bool Accessed)
Emit a check that Base points into an array object, which we can access at index Index.
Represents a struct/union/class.
llvm::DenseMap< const VarDecl *, FieldDecl * > LambdaCaptureFields
const TargetInfo & getTarget() const
An object to manage conditionally-evaluated expressions.
TBAAAccessInfo mergeTBAAInfoForCast(TBAAAccessInfo SourceInfo, TBAAAccessInfo TargetInfo)
mergeTBAAInfoForCast - Get merged TBAA information for the purposes of type casts.
Expr * GetTemporaryExpr() const
Retrieve the temporary-generating subexpression whose value will be materialized into a glvalue...
llvm::Value * EmitScalarPrePostIncDec(const UnaryOperator *E, LValue LV, bool isInc, bool isPre)
Address getAddress() const
Represents a class type in Objective C.
CodeGenFunction - This class organizes the per-function state that is used while generating LLVM code...
llvm::Type * ConvertType(QualType T)
ConvertType - Convert type T into a llvm::Type.
LValue EmitObjCIvarRefLValue(const ObjCIvarRefExpr *E)
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.
A C++ nested-name-specifier augmented with source location information.
std::pair< LValue, llvm::Value * > EmitARCStoreAutoreleasing(const BinaryOperator *e)
llvm::IntegerType * Int64Ty
llvm::Value * EmitDynamicCast(Address V, const CXXDynamicCastExpr *DCE)
SourceLocation getExprLoc() const LLVM_READONLY
llvm::Value * EmitObjCExtendObjectLifetime(QualType T, llvm::Value *Ptr)
RValue EmitReferenceBindingToExpr(const Expr *E)
Emits a reference binding to the passed in expression.
LValue EmitCXXBindTemporaryLValue(const CXXBindTemporaryExpr *E)
SourceLocation getBeginLoc() const LLVM_READONLY
llvm::Constant * getAddrOfCXXStructor(const CXXMethodDecl *MD, StructorType Type, const CGFunctionInfo *FnInfo=nullptr, llvm::FunctionType *FnType=nullptr, bool DontDefer=false, ForDefinition_t IsForDefinition=NotForDefinition)
Return the address of the constructor/destructor of the given type.
Address EmitLoadOfReference(LValue RefLVal, LValueBaseInfo *PointeeBaseInfo=nullptr, TBAAAccessInfo *PointeeTBAAInfo=nullptr)
bool isVolatileQualified() const
Represents a member of a struct/union/class.
static llvm::Value * emitArraySubscriptGEP(CodeGenFunction &CGF, llvm::Value *ptr, ArrayRef< llvm::Value *> indices, bool inbounds, bool signedIndices, SourceLocation loc, const llvm::Twine &name="arrayidx")
CharUnits getAlignment() const
llvm::IntegerType * SizeTy
An RAII object to set (and then clear) a mapping for an OpaqueValueExpr.
LValue EmitCoyieldLValue(const CoyieldExpr *E)
virtual void EmitObjCIvarAssign(CodeGen::CodeGenFunction &CGF, llvm::Value *src, Address dest, llvm::Value *ivarOffset)=0
LValue EmitOMPArraySectionExpr(const OMPArraySectionExpr *E, bool IsLowerBound=true)
SourceLocation getExprLoc() const LLVM_READONLY
bool isReferenceType() const
Denotes a cleanup that should run when a scope is exited using exceptional control flow (a throw stat...
llvm::BasicBlock * getStartingBlock() const
Returns a block which will be executed prior to each evaluation of the conditional code...
static bool getRangeForType(CodeGenFunction &CGF, QualType Ty, llvm::APInt &Min, llvm::APInt &End, bool StrictEnums, bool IsBool)
static DeclRefExpr * Create(const ASTContext &Context, NestedNameSpecifierLoc QualifierLoc, SourceLocation TemplateKWLoc, ValueDecl *D, bool RefersToEnclosingVariableOrCapture, SourceLocation NameLoc, QualType T, ExprValueKind VK, NamedDecl *FoundD=nullptr, const TemplateArgumentListInfo *TemplateArgs=nullptr)
Expr * getSourceExpr() const
The source expression of an opaque value expression is the expression which originally generated the ...
static AggValueSlot forAddr(Address addr, Qualifiers quals, IsDestructed_t isDestructed, NeedsGCBarriers_t needsGC, IsAliased_t isAliased, Overlap_t mayOverlap, IsZeroed_t isZeroed=IsNotZeroed, IsSanitizerChecked_t isChecked=IsNotSanitizerChecked)
forAddr - Make a slot for an aggregate value.
static CharUnits Zero()
Zero - Construct a CharUnits quantity of zero.
ExtVectorElementExpr - This represents access to specific elements of a vector, and may occur on the ...
void setBaseIvarExp(Expr *V)
bool isArrow() const
isArrow - Return true if the base expression is a pointer to vector, return false if the base express...
void InitTempAlloca(Address Alloca, llvm::Value *Value)
InitTempAlloca - Provide an initial value for the given alloca which will be observable at all locati...
RValue EmitLoadOfExtVectorElementLValue(LValue V)
LValue EmitLambdaLValue(const LambdaExpr *E)
static Address emitAddrOfFieldStorage(CodeGenFunction &CGF, Address base, const FieldDecl *field)
Drill down to the storage of a field without walking into reference types.
Qualifiers getLocalQualifiers() const
Retrieve the set of qualifiers local to this particular QualType instance, not including any qualifie...
static bool isFlexibleArrayMemberExpr(const Expr *E)
Determine whether this expression refers to a flexible array member in a struct.
Selector getSelector() const
RValue EmitAnyExprToTemp(const Expr *E)
EmitAnyExprToTemp - Similarly to EmitAnyExpr(), however, the result will always be accessible even if...
void EmitStoreOfScalar(llvm::Value *Value, Address Addr, bool Volatile, QualType Ty, AlignmentSource Source=AlignmentSource::Type, bool isInit=false, bool isNontemporal=false)
EmitStoreOfScalar - Store a scalar value to an address, taking care to appropriately convert from the...
ComplexPairTy EmitLoadOfComplex(LValue src, SourceLocation loc)
EmitLoadOfComplex - Load a complex number from the specified l-value.
const Expr *const * const_semantics_iterator
void setNonGC(bool Value)
Address CreateIRTemp(QualType T, const Twine &Name="tmp")
CreateIRTemp - Create a temporary IR object of the given type, with appropriate alignment.
RValue EmitAnyExpr(const Expr *E, AggValueSlot aggSlot=AggValueSlot::ignored(), bool ignoreResult=false)
EmitAnyExpr - Emit code to compute the specified expression which can have any type.
const CXXPseudoDestructorExpr * getPseudoDestructorExpr() const
Describes an C or C++ initializer list.
A C++ typeid expression (C++ [expr.typeid]), which gets the type_info that corresponds to the supplie...
Address emitAddrOfRealComponent(Address complex, QualType complexType)
virtual llvm::Value * EmitIvarOffset(CodeGen::CodeGenFunction &CGF, const ObjCInterfaceDecl *Interface, const ObjCIvarDecl *Ivar)=0
unsigned Size
The total size of the bit-field, in bits.
bool isBitField() const
Determines whether this field is a bitfield.
static LValueOrRValue emitPseudoObjectExpr(CodeGenFunction &CGF, const PseudoObjectExpr *E, bool forLValue, AggValueSlot slot)
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.
APValue Val
Val - This is the value the expression can be folded to.
static LValue EmitFunctionDeclLValue(CodeGenFunction &CGF, const Expr *E, const FunctionDecl *FD)
void setDSOLocal(llvm::GlobalValue *GV) const
const FunctionDecl * getBuiltinDecl() const
bool hasPrototype() const
Whether this function has a prototype, either because one was explicitly written or because it was "i...
CharUnits StorageOffset
The offset of the bitfield storage from the start of the struct.
bool isGlobalObjCRef() const
ExprValueKind getValueKind() const
getValueKind - The value kind that this expression produces.
TBAAAccessInfo getTBAAAccessInfo(QualType AccessType)
getTBAAAccessInfo - Get TBAA information that describes an access to an object of the given type...
path_iterator path_begin()
unsigned char PointerWidthInBits
The width of a pointer into the generic address space.
CharUnits getAlignment() const
Return the alignment of this pointer.
static LValue MakeExtVectorElt(Address vecAddress, llvm::Constant *Elts, QualType type, LValueBaseInfo BaseInfo, TBAAAccessInfo TBAAInfo)
llvm::PointerType * VoidPtrTy
void setFunctionPointer(llvm::Value *functionPtr)
void addCVRQualifiers(unsigned mask)
semantics_iterator semantics_end()
A builtin binary operation expression such as "x + y" or "x <= y".
bool isVolatileQualified() const
Determine whether this type is volatile-qualified.
Checking the operand of a dynamic_cast or a typeid expression.
unsigned getNumPositiveBits() const
Returns the width in bits required to store all the non-negative enumerators of this enum...
static AlignmentSource getFieldAlignmentSource(AlignmentSource Source)
Given that the base address has the given alignment source, what's our confidence in the alignment of...
virtual llvm::Value * EmitMemberPointerIsNotNull(CodeGenFunction &CGF, llvm::Value *MemPtr, const MemberPointerType *MPT)
Determine if a member pointer is non-null. Returns an i1.
CharUnits getDeclAlign(const Decl *D, bool ForAlignof=false) const
Return a conservative estimate of the alignment of the specified decl D.
llvm::Value * EmitARCLoadWeak(Address addr)
i8* @objc_loadWeak(i8** addr) Essentially objc_autorelease(objc_loadWeakRetained(addr)).
Scope - A scope is a transient data structure that is used while parsing the program.
LValue EmitCXXConstructLValue(const CXXConstructExpr *E)
RValue EmitSimpleCallExpr(const CallExpr *E, ReturnValueSlot ReturnValue)
Emit a CallExpr without considering whether it might be a subclass.
const Type * getTypePtr() const
Retrieves a pointer to the underlying (unqualified) type.
LValue EmitUnaryOpLValue(const UnaryOperator *E)
void addQualifiers(Qualifiers Q)
Add the qualifiers from the given set to this set.
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.
An adjustment to be made to the temporary created when emitting a reference binding, which accesses a particular subobject of that temporary.
static Address emitDeclTargetLinkVarDeclLValue(CodeGenFunction &CGF, const VarDecl *VD, QualType T)
CastExpr - Base class for type casts, including both implicit casts (ImplicitCastExpr) and explicit c...
LValue EmitObjCMessageExprLValue(const ObjCMessageExpr *E)
unsigned Offset
The offset within a contiguous run of bitfields that are represented as a single "field" within the L...
void ForceCleanup(std::initializer_list< llvm::Value **> ValuesToReload={})
Force the emission of cleanups now, instead of waiting until this object is destroyed.
Represents binding an expression to a temporary.
llvm::Constant * CreateRuntimeVariable(llvm::Type *Ty, StringRef Name)
Create a new runtime global variable with the specified type and name.
CXXTemporary * getTemporary()
A C++ lambda expression, which produces a function object (of unspecified type) that can be invoked l...
__INTPTR_TYPE__ intptr_t
A signed integer type with the property that any valid pointer to void can be converted to this type...
bool hasTrivialDestructor() const
Determine whether this class has a trivial destructor (C++ [class.dtor]p3)
CharUnits getPointerAlign() const
static bool ContainsLabel(const Stmt *S, bool IgnoreCaseStmts=false)
ContainsLabel - Return true if the statement contains a label in it.
void * getAsOpaquePtr() const
void incrementProfileCounter(const Stmt *S, llvm::Value *StepV=nullptr)
Increment the profiler's counter for the given statement by StepV.
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 setARCPreciseLifetime(ARCPreciseLifetime_t value)
Represents an ObjC class declaration.
QualType getReturnType() const
RValue convertTempToRValue(Address addr, QualType type, SourceLocation Loc)
Given the address of a temporary variable, produce an r-value of its type.
Checking the operand of a cast to a virtual base object.
Address getAggregateAddress() const
getAggregateAddr() - Return the Value* of the address of the aggregate.
static CharUnits getArrayElementAlign(CharUnits arrayAlign, llvm::Value *idx, CharUnits eltSize)
virtual void mangleCXXRTTI(QualType T, raw_ostream &)=0
static bool ShouldNullCheckClassCastValue(const CastExpr *Cast)
llvm::Value * EmitCheckValue(llvm::Value *V)
Convert a value into a format suitable for passing to a runtime sanitizer handler.
void begin(CodeGenFunction &CGF)
void setThreadLocalRef(bool Value)
This object can be modified without requiring retains or releases.
LValue EmitLValueForField(LValue Base, const FieldDecl *Field)
virtual llvm::Value * performAddrSpaceCast(CodeGen::CodeGenFunction &CGF, llvm::Value *V, LangAS SrcAddr, LangAS DestAddr, llvm::Type *DestTy, bool IsNonNull=false) const
Perform address space cast of an expression of pointer type.
llvm::Constant * CreateRuntimeFunction(llvm::FunctionType *Ty, StringRef Name, llvm::AttributeList ExtraAttrs=llvm::AttributeList(), bool Local=false)
Create a new runtime function with the specified type and name.
Checking the 'this' pointer for a call to a non-static member function.
virtual void EmitObjCGlobalAssign(CodeGen::CodeGenFunction &CGF, llvm::Value *src, Address dest, bool threadlocal=false)=0
bool isTypeConstant(QualType QTy, bool ExcludeCtorDtor)
isTypeConstant - Determine whether an object of this type can be emitted as a constant.
llvm::Value * EmitLoadOfScalar(Address Addr, bool Volatile, QualType Ty, SourceLocation Loc, AlignmentSource Source=AlignmentSource::Type, bool isNontemporal=false)
EmitLoadOfScalar - Load a scalar value from an address, taking care to appropriately convert from the...
LValue EmitExtVectorElementExpr(const ExtVectorElementExpr *E)
OpenMP 4.0 [2.4, Array Sections].
RValue EmitObjCMessageExpr(const ObjCMessageExpr *E, ReturnValueSlot Return=ReturnValueSlot())
const ValueDecl * getExtendingDecl() const
Get the declaration which triggered the lifetime-extension of this temporary, if any.
void EmitCXXConstructExpr(const CXXConstructExpr *E, AggValueSlot Dest)
static CharUnits One()
One - Construct a CharUnits quantity of one.
std::pair< llvm::Value *, llvm::Value * > ComplexPairTy
CXXRecordDecl * getAsCXXRecordDecl() const
Retrieves the CXXRecordDecl that this type refers to, either because the type is a RecordType or beca...
ASTContext & getContext() const
Represents a prototype with parameter type info, e.g.
bool EvaluateAsLValue(EvalResult &Result, const ASTContext &Ctx) const
EvaluateAsLValue - Evaluate an expression to see if we can fold it to an lvalue with link time known ...
llvm::CallInst * EmitNounwindRuntimeCall(llvm::Value *callee, const Twine &name="")
bool isDynamicClass() const
const TargetCodeGenInfo & getTargetCodeGenInfo()
void EmitAnyExprToMem(const Expr *E, Address Location, Qualifiers Quals, bool IsInitializer)
EmitAnyExprToMem - Emits the code necessary to evaluate an arbitrary expression into the given memory...
LValueBaseInfo getBaseInfo() const
static CheckRecoverableKind getRecoverableKind(SanitizerMask Kind)
RValue - This trivial value class is used to represent the result of an expression that is evaluated...
void EmitSanitizerStatReport(llvm::SanitizerStatKind SSK)
RValue EmitBuiltinExpr(const GlobalDecl GD, unsigned BuiltinID, const CallExpr *E, ReturnValueSlot ReturnValue)
Address getExtVectorAddress() const
virtual LValue EmitThreadLocalVarDeclLValue(CodeGenFunction &CGF, const VarDecl *VD, QualType LValType)=0
Emit a reference to a non-local thread_local variable (including triggering the initialization of all...
CleanupKind getARCCleanupKind()
Retrieves the default cleanup kind for an ARC cleanup.
const Type * getPointeeOrArrayElementType() const
If this is a pointer type, return the pointee type.
bool isPseudoDestructor() const
SourceLocation getLocation() const
QuantityType getQuantity() const
getQuantity - Get the raw integer representation of this quantity.
llvm::Value * DecodeAddrUsedInPrologue(llvm::Value *F, llvm::Value *EncodedAddr)
Decode an address used in a function prologue, encoded by EncodeAddrForUseInPrologue.
Represents a call to the builtin function __builtin_va_arg.
Address CreateDefaultAlignTempAlloca(llvm::Type *Ty, const Twine &Name="tmp")
CreateDefaultAlignedTempAlloca - This creates an alloca with the default ABI alignment of the given L...
ASTRecordLayout - This class contains layout information for one RecordDecl, which is a struct/union/...
llvm::Value * emitScalarConstant(const ConstantEmission &Constant, Expr *E)
llvm::Value * EmitARCStoreWeak(Address addr, llvm::Value *value, bool ignored)
i8* @objc_storeWeak(i8** addr, i8* value) Returns value.
CGObjCRuntime & getObjCRuntime()
Return a reference to the configured Objective-C runtime.
LValue EmitInitListLValue(const InitListExpr *E)
static TypeEvaluationKind getEvaluationKind(QualType T)
getEvaluationKind - Return the TypeEvaluationKind of QualType T.
void EmitStoreThroughExtVectorComponentLValue(RValue Src, LValue Dst)
QualType getElementType() const
Represent the declaration of a variable (in which case it is an lvalue) a function (in which case it ...
llvm::Function * generateDestroyHelper(Address addr, QualType type, Destroyer *destroyer, bool useEHCleanupForArray, const VarDecl *VD)
generateDestroyHelper - Generates a helper function which, when invoked, destroys the given object...
This represents one expression.
const AnnotatedLine * Line
Enters a new scope for capturing cleanups, all of which will be executed once the scope is exited...
LValue EmitCXXTypeidLValue(const CXXTypeidExpr *E)
llvm::Value * EmitComplexToScalarConversion(ComplexPairTy Src, QualType SrcTy, QualType DstTy, SourceLocation Loc)
Emit a conversion from the specified complex type to the specified destination type, where the destination type is an LLVM scalar type.
RValue EmitCXXPseudoDestructorExpr(const CXXPseudoDestructorExpr *E)
void EmitCallArgs(CallArgList &Args, const T *CallArgTypeInfo, llvm::iterator_range< CallExpr::const_arg_iterator > ArgRange, AbstractCallee AC=AbstractCallee(), unsigned ParamsToSkip=0, EvaluationOrder Order=EvaluationOrder::Default)
EmitCallArgs - Emit call arguments for a function.
llvm::Constant * GetAddrOfGlobalVar(const VarDecl *D, llvm::Type *Ty=nullptr, ForDefinition_t IsForDefinition=NotForDefinition)
Return the llvm::Constant for the address of the given global variable.
const T * castAs() const
Member-template castAs<specific type>.
void setObjCArray(bool Value)
unsigned getLine() const
Return the presumed line number of this location.
static CGCallee forDirect(llvm::Constant *functionPtr, const CGCalleeInfo &abstractInfo=CGCalleeInfo())
Represents a C++ destructor within a class.
QualType getTagDeclType(const TagDecl *Decl) const
Return the unique reference to the type for the specified TagDecl (struct/union/class/enum) decl...
static LValue EmitCapturedFieldLValue(CodeGenFunction &CGF, const FieldDecl *FD, llvm::Value *ThisValue)
void SetFPAccuracy(llvm::Value *Val, float Accuracy)
SetFPAccuracy - Set the minimum required accuracy of the given floating point operation, expressed as the maximum relative error in ulp.
AggValueSlot CreateAggTemp(QualType T, const Twine &Name="tmp")
CreateAggTemp - Create a temporary memory object for the given aggregate type.
VlaSizePair getVLASize(const VariableArrayType *vla)
Returns an LLVM value that corresponds to the size, in non-variably-sized elements, of a variable length array type, plus that largest non-variably-sized element type.
static bool isVptrCheckRequired(TypeCheckKind TCK, QualType Ty)
Determine whether the pointer type check TCK requires a vptr check.
llvm::PointerType * getType() const
Return the type of the pointer value.
ObjCLifetime getObjCLifetime() const
CharUnits getTypeAlignInChars(QualType T) const
Return the ABI-specified alignment of a (complete) type T, in characters.
llvm::Value * EmitToMemory(llvm::Value *Value, QualType Ty)
EmitToMemory - Change a scalar value from its value representation to its in-memory representation...
bool isAnyComplexType() const
ObjCSelectorExpr used for @selector in Objective-C.
TLSKind getTLSKind() const
static CharUnits fromQuantity(QuantityType Quantity)
fromQuantity - Construct a CharUnits quantity from a raw integer type.
FunctionDecl * getDirectCallee()
If the callee is a FunctionDecl, return it. Otherwise return null.
bool refersToEnclosingVariableOrCapture() const
Does this DeclRefExpr refer to an enclosing local or a captured variable?
static Optional< LValue > EmitLValueOrThrowExpression(CodeGenFunction &CGF, const Expr *Operand)
Emit the operand of a glvalue conditional operator.
static LValue MakeBitfield(Address Addr, const CGBitFieldInfo &Info, QualType type, LValueBaseInfo BaseInfo, TBAAAccessInfo TBAAInfo)
Create a new object to represent a bit-field access.
virtual void registerGlobalDtor(CodeGenFunction &CGF, const VarDecl &D, llvm::Constant *Dtor, llvm::Constant *Addr)=0
Emit code to force the execution of a destructor during global teardown.
llvm::LLVMContext & getLLVMContext()
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.
llvm::IntegerType * Int32Ty
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.
void EmitLambdaExpr(const LambdaExpr *E, AggValueSlot Dest)
TBAAAccessInfo getTBAAInfo() const
CharUnits alignmentOfArrayElement(CharUnits elementSize) const
Given that this is the alignment of the first element of an array, return the minimum alignment of an...
StorageDuration getStorageDuration() const
Retrieve the storage duration for the materialized temporary.
LValue MakeNaturalAlignAddrLValue(llvm::Value *V, QualType T)
An expression that sends a message to the given Objective-C object or class.
ConstantAddress GetAddrOfUuidDescriptor(const CXXUuidofExpr *E)
Get the address of a uuid descriptor .
ComplexPairTy EmitComplexPrePostIncDec(const UnaryOperator *E, LValue LV, bool isInc, bool isPre)
Represents an unpacked "presumed" location which can be presented to the user.
QualType getFunctionTypeWithExceptionSpec(QualType Orig, const FunctionProtoType::ExceptionSpecInfo &ESI)
Get a function type and produce the equivalent function type with the specified exception specificati...
UnaryOperator - This represents the unary-expression's (except sizeof and alignof), the postinc/postdec operators from postfix-expression, and various extensions.
Represents a GCC generic vector type.
llvm::Value * EmitCastToVoidPtr(llvm::Value *value)
Emit a cast to void* in the appropriate address space.
ConstantEmission tryEmitAsConstant(DeclRefExpr *refExpr)
Try to emit a reference to the given value without producing it as an l-value.
The scope of a CXXDefaultInitExpr.
const Type * getBaseElementTypeUnsafe() const
Get the base element type of this type, potentially discarding type qualifiers.
RValue EmitLoadOfGlobalRegLValue(LValue LV)
Load of global gamed gegisters are always calls to intrinsics.
Expr * getTrueExpr() const
const Qualifiers & getQuals() const
const LangOptions & getLangOpts() const
bool isObjCStrong() const
const Expr * getSubExpr() const
ASTContext & getContext() const
bool isNull() const
Return true if this QualType doesn't point to a type yet.
RValue EmitLoadOfBitfieldLValue(LValue LV, SourceLocation Loc)
ConstantEmissionKind
Can we constant-emit a load of a reference to a variable of the given type? This is different from pr...
Expr * getLHS()
An array access can be written A[4] or 4[A] (both are equivalent).
RValue EmitAtomicLoad(LValue LV, SourceLocation SL, AggValueSlot Slot=AggValueSlot::ignored())
Address GetAddrOfBlockDecl(const VarDecl *var)
static bool shouldBindAsLValue(const Expr *expr)
const SanitizerBlacklist & getSanitizerBlacklist() const
GlobalDecl - represents a global declaration.
TBAAAccessInfo mergeTBAAInfoForConditionalOperator(TBAAAccessInfo InfoA, TBAAAccessInfo InfoB)
mergeTBAAInfoForConditionalOperator - Get merged TBAA information for the purposes of conditional ope...
bool isThreadLocalRef() const
ConstantAddress GetAddrOfGlobalTemporary(const MaterializeTemporaryExpr *E, const Expr *Inner)
Returns a pointer to a global variable representing a temporary with static or thread storage duratio...
LValue EmitLoadOfPointerLValue(Address Ptr, const PointerType *PtrTy)
Dynamic storage duration.
The l-value was considered opaque, so the alignment was determined from a type.
RecordDecl * getDecl() const
const char * getFilename() const
Return the presumed filename of this location.
uint64_t getFieldOffset(unsigned FieldNo) const
getFieldOffset - Get the offset of the given field index, in bits.
CGCallee EmitCallee(const Expr *E)
llvm::Constant * getOrCreateStaticVarDecl(const VarDecl &D, llvm::GlobalValue::LinkageTypes Linkage)
bool EvaluateAsRValue(EvalResult &Result, const ASTContext &Ctx, bool InConstantContext=false) const
EvaluateAsRValue - Return true if this is a constant which we can fold to an rvalue using any crazy t...
There is no lifetime qualification on this type.
const SanitizerHandlerInfo SanitizerHandlers[]
virtual llvm::Value * getContextValue() const
OpaqueValueExpr - An expression referring to an opaque object of a fixed type and value class...
void set(SanitizerMask K, bool Value)
Enable or disable a certain (single) sanitizer.
Address CreateBitCast(Address Addr, llvm::Type *Ty, const llvm::Twine &Name="")
static StringRef getIdentKindName(IdentKind IK)
Assigning into this object requires the old value to be released and the new value to be retained...
QualType getCanonicalType() const
static LValue EmitGlobalNamedRegister(const VarDecl *VD, CodeGenModule &CGM)
Named Registers are named metadata pointing to the register name which will be read from/written to a...
PseudoObjectExpr - An expression which accesses a pseudo-object l-value.
LValue EmitVAArgExprLValue(const VAArgExpr *E)
llvm::Value * EmitCXXTypeidExpr(const CXXTypeidExpr *E)
unsigned getColumn() const
Return the presumed column number of this location.
StringLiteral * getFunctionName()
void pushDestroy(QualType::DestructionKind dtorKind, Address addr, QualType type)
pushDestroy - Push the standard destructor for the given type as at least a normal cleanup...
static llvm::Constant * EmitFunctionDeclPointer(CodeGenModule &CGM, const FunctionDecl *FD)
Encodes a location in the source.
bool LValueIsSuitableForInlineAtomic(LValue Src)
An LValue is a candidate for having its loads and stores be made atomic if we are operating under /vo...
void EnsureInsertPoint()
EnsureInsertPoint - Ensure that an insertion point is defined so that emitted IR has a place to go...
virtual LValue EmitObjCValueForIvar(CodeGen::CodeGenFunction &CGF, QualType ObjectTy, llvm::Value *BaseValue, const ObjCIvarDecl *Ivar, unsigned CVRQualifiers)=0
A helper class that allows the use of isa/cast/dyncast to detect TagType objects of enums...
llvm::Constant * getTypeDescriptorFromMap(QualType Ty)
LValue EmitDeclRefLValue(const DeclRefExpr *E)
LangAS getAddressSpace() const
Return the address space of this type.
llvm::MDNode * BaseType
BaseType - The base/leading access type.
Expr * getSubExpr() const
llvm::Value * EvaluateExprAsBool(const Expr *E)
EvaluateExprAsBool - Perform the usual unary conversions on the specified expression and compare the ...
LValue EmitCheckedLValue(const Expr *E, TypeCheckKind TCK)
Same as EmitLValue but additionally we generate checking code to guard against undefined behavior...
bool isVariablyModifiedType() const
Whether this type is a variably-modified type (C99 6.7.5).
llvm::Value * EmitFromMemory(llvm::Value *Value, QualType Ty)
EmitFromMemory - Change a scalar value from its memory representation to its value representation...
unsigned getBlockId(const BlockDecl *BD, bool Local)
CastKind getCastKind() const
Expr * getBaseIvarExp() const
CharUnits getNaturalPointeeTypeAlignment(QualType T, LValueBaseInfo *BaseInfo=nullptr, TBAAAccessInfo *TBAAInfo=nullptr)
const CGBitFieldInfo & getBitFieldInfo() const
LValue EmitAggExprToLValue(const Expr *E)
EmitAggExprToLValue - Emit the computation of the specified expression of aggregate type into a tempo...
llvm::Metadata * CreateMetadataIdentifierForType(QualType T)
Create a metadata identifier for the given type.
QualType getElementType() const
const Decl * getDecl() const
Checking the operand of a cast to a base object.
void ConvertArgToString(ArgumentKind Kind, intptr_t Val, StringRef Modifier, StringRef Argument, ArrayRef< ArgumentValue > PrevArgs, SmallVectorImpl< char > &Output, ArrayRef< intptr_t > QualTypeVals) const
Converts a diagnostic argument (as an intptr_t) into the string that represents it.
A scoped helper to set the current debug location to the specified location or preferred location of ...
llvm::Value * EmitLifetimeStart(uint64_t Size, llvm::Value *Addr)
Emit a lifetime.begin marker if some criteria are satisfied.
LValue EmitUnsupportedLValue(const Expr *E, const char *Name)
EmitUnsupportedLValue - Emit a dummy l-value using the type of E and issue an ErrorUnsupported style ...
Represents a static or instance method of a struct/union/class.
static bool hasAnyVptr(const QualType Type, const ASTContext &Context)
ConstantAddress GetAddrOfConstantStringFromLiteral(const StringLiteral *S, StringRef Name=".str")
Return a pointer to a constant array for the given string literal.
static LValue EmitGlobalVarDeclLValue(CodeGenFunction &CGF, const Expr *E, const VarDecl *VD)
SourceLocation getColonLoc() const
llvm::Metadata * CreateMetadataIdentifierGeneralized(QualType T)
Create a metadata identifier for the generalization of the given type.
virtual Address GetAddrOfSelector(CodeGenFunction &CGF, Selector Sel)=0
Get the address of a selector for the specified name and type values.
SanitizerSet SanOpts
Sanitizers enabled for this function.
static QualType getFixedSizeElementType(const ASTContext &ctx, const VariableArrayType *vla)
llvm::Constant * GetAddrOfRTTIDescriptor(QualType Ty, bool ForEH=false)
Get the address of the RTTI descriptor for the given type.
bool isNontemporal() const
const ArrayType * getAsArrayType(QualType T) const
Type Query functions.
bool isSignedIntegerOrEnumerationType() const
Determines whether this is an integer type that is signed or an enumeration types whose underlying ty...
void EmitCXXTemporary(const CXXTemporary *Temporary, QualType TempType, Address Ptr)
Emits all the code to cause the given temporary to be cleaned up.
llvm::Constant * emitAbstract(const Expr *E, QualType T)
Emit the result of the given expression as an abstract constant, asserting that it succeeded...
SanitizerSet SanitizeTrap
Set of sanitizer checks that trap rather than diagnose.
bool isObjCObjectPointerType() const
TypeCheckKind
Situations in which we might emit a check for the suitability of a pointer or glvalue.
llvm::MDNode * getTBAATypeInfo(QualType QTy)
getTBAATypeInfo - Get metadata used to describe accesses to objects of the given type.
ConstantAddress GetWeakRefReference(const ValueDecl *VD)
Get a reference to the target of VD.
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.
void setObjCIvar(bool Value)
DestructionKind isDestructedType() const
Returns a nonzero value if objects of this type require non-trivial work to clean up after...
uint64_t Size
Size - The size of access, in bytes.
All available information about a concrete callee.
Address getVectorAddress() const
MangleContext & getMangleContext()
Gets the mangle context.
bool isUsed(bool CheckUsedAttr=true) const
Whether any (re-)declaration of the entity was used, meaning that a definition is required...
Address EmitArrayToPointerDecay(const Expr *Array, LValueBaseInfo *BaseInfo=nullptr, TBAAAccessInfo *TBAAInfo=nullptr)
LValue EmitPointerToDataMemberBinaryExpr(const BinaryOperator *E)
EnumDecl * getDecl() const
const ObjCMethodDecl * getMethodDecl() const
bool isVectorType() const
Checking the object expression in a non-static data member access.
Assigning into this object requires a lifetime extension.
StmtExpr - This is the GNU Statement Expression extension: ({int X=4; X;}).
CharUnits getNaturalTypeAlignment(QualType T, LValueBaseInfo *BaseInfo=nullptr, TBAAAccessInfo *TBAAInfo=nullptr, bool forPointeeType=false)
RValue EmitCallExpr(const CallExpr *E, ReturnValueSlot ReturnValue=ReturnValueSlot())
llvm::Value * EmitARCRetain(QualType type, llvm::Value *value)
Produce the code to do a retain.
static ConstantEmission forReference(llvm::Constant *C)
const TargetCodeGenInfo & getTargetHooks() const
static Destroyer destroyARCStrongImprecise
void FinishFunction(SourceLocation EndLoc=SourceLocation())
FinishFunction - Complete IR generation of the current function.
SourceLocation getExprLoc() const LLVM_READONLY
getExprLoc - Return the preferred location for the arrow when diagnosing a problem with a generic exp...
const Expr * getInitializer() const
ConstantAddress GetAddrOfConstantCString(const std::string &Str, const char *GlobalName=nullptr)
Returns a pointer to a character array containing the literal and a terminating '\0' character...
void setExternallyDestructed(bool destructed=true)
llvm::Value * EmitScalarExpr(const Expr *E, bool IgnoreResultAssign=false)
EmitScalarExpr - Emit the computation of the specified expression of LLVM scalar type, returning the result.
const Expr * getBase() const
decl_iterator - Iterates through the declarations stored within this context.
! Language semantics require right-to-left evaluation.
void addUsedGlobal(llvm::GlobalValue *GV)
Add a global to a list to be added to the llvm.used metadata.
FunctionArgList - Type for representing both the decl and type of parameters to a function...
llvm::Value * getScalarVal() const
getScalarVal() - Return the Value* of this scalar value.
ast_type_traits::DynTypedNode Node
Expr * getResultExpr()
Return the result-bearing expression, or null if there is none.
TLS with a dynamic initializer.
CGFunctionInfo - Class to encapsulate the information about a function definition.
This class organizes the cross-function state that is used while generating LLVM code.
CharUnits alignmentAtOffset(CharUnits offset) const
Given that this is a non-zero alignment value, what is the alignment at the given offset...
CGOpenMPRuntime & getOpenMPRuntime()
Return a reference to the configured OpenMP runtime.
void EmitDeclRefExprDbgValue(const DeclRefExpr *E, const APValue &Init)
Dataflow Directional Tag Classes.
LValue EmitLoadOfReferenceLValue(LValue RefLVal)
bool isValid() const
Return true if this is a valid SourceLocation object.
void EmitVTablePtrCheckForCast(QualType T, llvm::Value *Derived, bool MayBeNull, CFITypeCheckKind TCK, SourceLocation Loc)
Derived is the presumed address of an object of type T after a cast.
[C99 6.4.2.2] - A predefined identifier such as func.
Address EmitFieldAnnotations(const FieldDecl *D, Address V)
Emit field annotations for the given field & value.
RValue EmitUnsupportedRValue(const Expr *E, const char *Name)
EmitUnsupportedRValue - Emit a dummy r-value using the type of E and issue an ErrorUnsupported style ...
static bool shouldBindAsLValue(const Expr *expr)
static RValue getComplex(llvm::Value *V1, llvm::Value *V2)
EvalResult is a struct with detailed info about an evaluated expression.
Decl * getReferencedDeclOfCallee()
llvm::MDNode * getTBAABaseTypeInfo(QualType QTy)
getTBAABaseTypeInfo - Get metadata that describes the given base access type.
static AggValueSlot ignored()
ignored - Returns an aggregate value slot indicating that the aggregate value is being ignored...
llvm::Value * EmitARCLoadWeakRetained(Address addr)
i8* @objc_loadWeakRetained(i8** addr)
Address CreateStructGEP(Address Addr, unsigned Index, CharUnits Offset, const llvm::Twine &Name="")
static CGCallee forBuiltin(unsigned builtinID, const FunctionDecl *builtinDecl)
LValue getOrCreateOpaqueLValueMapping(const OpaqueValueExpr *e)
Given an opaque value expression, return its LValue mapping if it exists, otherwise create one...
llvm::LoadInst * CreateAlignedLoad(llvm::Value *Addr, CharUnits Align, const llvm::Twine &Name="")
Checking the bound value in a reference binding.
LValue EmitCallExprLValue(const CallExpr *E)
bool isInConditionalBranch() const
isInConditionalBranch - Return true if we're currently emitting one branch or the other of a conditio...
LValue EmitPseudoObjectLValue(const PseudoObjectExpr *e)
unsigned IsSigned
Whether the bit-field is signed.
llvm::Constant * getPointer() const
llvm::LoadInst * CreateLoad(Address Addr, const llvm::Twine &Name="")
llvm::IntegerType * IntPtrTy
StmtClass getStmtClass() const
bool isBooleanType() const
QualType getFunctionNoProtoType(QualType ResultTy, const FunctionType::ExtInfo &Info) const
Return a K&R style C function type like 'int()'.
llvm::Constant * EmitNullConstant(QualType T)
Return the result of value-initializing the given type, i.e.
unsigned StorageSize
The storage size in bits which should be used when accessing this bitfield.
PresumedLoc getPresumedLoc(SourceLocation Loc, bool UseLineDirectives=true) const
Returns the "presumed" location of a SourceLocation specifies.
Address CreateConstInBoundsGEP(Address Addr, uint64_t Index, CharUnits EltSize, const llvm::Twine &Name="")
Given addr = T* ...
Checking the destination of a store. Must be suitably sized and aligned.
llvm::Function * getIntrinsic(unsigned IID, ArrayRef< llvm::Type *> Tys=None)
A pointer to member type per C++ 8.3.3 - Pointers to members.
llvm::StoreInst * CreateStore(llvm::Value *Val, Address Addr, bool IsVolatile=false)
semantics_iterator semantics_begin()
llvm::Module & getModule() const
QualType getCallReturnType(const ASTContext &Ctx) const
getCallReturnType - Get the return type of the call expr.
ExplicitCastExpr - An explicit cast written in the source code.
LValue MakeAddrLValue(Address Addr, QualType T, AlignmentSource Source=AlignmentSource::Type)
specific_decl_iterator - Iterates over a subrange of declarations stored in a DeclContext, providing only those that are of type SpecificDecl (or a class derived from it).
void EmitAggExpr(const Expr *E, AggValueSlot AS)
EmitAggExpr - Emit the computation of the specified expression of aggregate type. ...
Expr * IgnoreParenImpCasts() LLVM_READONLY
IgnoreParenImpCasts - Ignore parentheses and implicit casts.
unsigned getBuiltinID() const
Checking the operand of a static_cast to a derived reference type.
static bool hasAggregateEvaluationKind(QualType T)
virtual void EmitObjCWeakAssign(CodeGen::CodeGenFunction &CGF, llvm::Value *src, Address dest)=0
void EmitExplicitCastExprType(const ExplicitCastExpr *E, CodeGenFunction *CGF=nullptr)
Emit type info if type of an expression is a variably modified type.
bool HasSideEffects
Whether the evaluated expression has side effects.
virtual llvm::Optional< LangAS > getConstantAddressSpace() const
Return an AST address space which can be used opportunistically for constant global memory...
AlignmentSource getAlignmentSource() const
A helper class that allows the use of isa/cast/dyncast to detect TagType objects of structs/unions/cl...
Complex values, per C99 6.2.5p11.
Checking the operand of a static_cast to a derived pointer type.
ArraySubscriptExpr - [C99 6.5.2.1] Array Subscripting.
void DecorateInstructionWithTBAA(llvm::Instruction *Inst, TBAAAccessInfo TBAAInfo)
DecorateInstructionWithTBAA - Decorate the instruction with a TBAA tag.
AbstractConditionalOperator - An abstract base class for ConditionalOperator and BinaryConditionalOpe...
CodeGenTypes & getTypes() const
bool isIntegerType() const
isIntegerType() does not include complex integers (a GCC extension).
void EmitStoreOfComplex(ComplexPairTy V, LValue dest, bool isInit)
EmitStoreOfComplex - Store a complex number into the specified l-value.
RValue GetUndefRValue(QualType Ty)
GetUndefRValue - Get an appropriate 'undef' rvalue for the given type.
Address getBitFieldAddress() const
ObjCEncodeExpr, used for @encode in Objective-C.
virtual bool usesThreadWrapperFunction() const =0
LValue EmitArraySubscriptExpr(const ArraySubscriptExpr *E, bool Accessed=false)
llvm::Type * getElementType() const
Return the type of the values stored in this address.
uint64_t getCharWidth() const
Return the size of the character type, in bits.
bool isAtomicType() const
static Address emitOMPArraySectionBase(CodeGenFunction &CGF, const Expr *Base, LValueBaseInfo &BaseInfo, TBAAAccessInfo &TBAAInfo, QualType BaseTy, QualType ElTy, bool IsLowerBound)
bool isFunctionType() const
llvm::Value * EmitCheckedInBoundsGEP(llvm::Value *Ptr, ArrayRef< llvm::Value *> IdxList, bool SignedIndices, bool IsSubtraction, SourceLocation Loc, const Twine &Name="")
Same as IRBuilder::CreateInBoundsGEP, but additionally emits a check to detect undefined behavior whe...
RValue EmitRValueForField(LValue LV, const FieldDecl *FD, SourceLocation Loc)
llvm::PointerType * Int8PtrTy
llvm::AssertingVH< llvm::Instruction > AllocaInsertPt
AllocaInsertPoint - This is an instruction in the entry block before which we prefer to insert alloca...
static CGCallee forPseudoDestructor(const CXXPseudoDestructorExpr *E)
LValue EmitLValueForIvar(QualType ObjectTy, llvm::Value *Base, const ObjCIvarDecl *Ivar, unsigned CVRQualifiers)
static llvm::Value * emitHash16Bytes(CGBuilderTy &Builder, llvm::Value *Low, llvm::Value *High)
Emit the hash_16_bytes function from include/llvm/ADT/Hashing.h.
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.
llvm::Value * EmitIvarOffset(const ObjCInterfaceDecl *Interface, const ObjCIvarDecl *Ivar)
static void emitCheckHandlerCall(CodeGenFunction &CGF, llvm::FunctionType *FnType, ArrayRef< llvm::Value *> FnArgs, SanitizerHandler CheckHandler, CheckRecoverableKind RecoverKind, bool IsFatal, llvm::BasicBlock *ContBB)
LValue EmitCastLValue(const CastExpr *E)
EmitCastLValue - Casts are never lvalues unless that cast is to a reference type. ...
void EmitBlock(llvm::BasicBlock *BB, bool IsFinished=false)
EmitBlock - Emit the given block.
void setGlobalObjCRef(bool Value)
void EmitARCInitWeak(Address addr, llvm::Value *value)
i8* @objc_initWeak(i8** addr, i8* value) Returns value.
void EmitCfiSlowPathCheck(SanitizerMask Kind, llvm::Value *Cond, llvm::ConstantInt *TypeId, llvm::Value *Ptr, ArrayRef< llvm::Constant *> StaticArgs)
Emit a slow path cross-DSO CFI check which calls __cfi_slowpath if Cond if false. ...
const Expr * getBase() const
void checkTargetFeatures(const CallExpr *E, const FunctionDecl *TargetDecl)
ConstantAddress GetAddrOfConstantCompoundLiteral(const CompoundLiteralExpr *E)
Returns a pointer to a constant global variable for the given file-scope compound literal expression...
void EmitUnreachable(SourceLocation Loc)
Emit a reached-unreachable diagnostic if Loc is valid and runtime checking is enabled.
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.
RValue asAggregateRValue() const
uint64_t getTypeSize(QualType T) const
Return the size of the specified (complete) type T, in bits.
ObjCIvarRefExpr - A reference to an ObjC instance variable.
SourceManager & getSourceManager()
LValue EmitConditionalOperatorLValue(const AbstractConditionalOperator *E)
bool isIncompleteType(NamedDecl **Def=nullptr) const
Types are partitioned into 3 broad categories (C99 6.2.5p1): object types, function types...
llvm::ConstantInt * getSize(CharUnits numChars)
Emit the given number of characters as a value of type size_t.
RValue getOrCreateOpaqueRValueMapping(const OpaqueValueExpr *e)
Given an opaque value expression, return its RValue mapping if it exists, otherwise create one...
QualType withCVRQualifiers(unsigned CVR) const
virtual void EmitObjCStrongCastAssign(CodeGen::CodeGenFunction &CGF, llvm::Value *src, Address dest)=0
Address CreateTempAllocaWithoutCast(llvm::Type *Ty, CharUnits align, const Twine &Name="tmp", llvm::Value *ArraySize=nullptr)
CreateTempAlloca - This creates a alloca and inserts it into the entry block.
CanQualType getCanonicalType(QualType T) const
Return the canonical (structural) type corresponding to the specified potentially non-canonical type ...
CharUnits toCharUnitsFromBits(int64_t BitSize) const
Convert a size in bits to a size in characters.
Reading or writing from this object requires a barrier call.
void setCurrentStmt(const Stmt *S)
If the execution count for the current statement is known, record that as the current count...
MemberExpr - [C99 6.5.2.3] Structure and Union Members.
static bool isConstantEmittableObjectType(QualType type)
Given an object of the given canonical type, can we safely copy a value out of it based on its initia...
A non-RAII class containing all the information about a bound opaque value.
QualType getUnqualifiedType() const
Retrieve the unqualified variant of the given type, removing as little sugar as possible.
void ErrorUnsupported(const Stmt *S, const char *Type)
ErrorUnsupported - Print out an error that codegen doesn't support the specified stmt yet...
Represents a C++ struct/union/class.
LValue EmitCoawaitLValue(const CoawaitExpr *E)
unsigned getBuiltinID() const
Returns a value indicating whether this function corresponds to a builtin function.
static bool isNullPointerAllowed(TypeCheckKind TCK)
Determine whether the pointer type check TCK permits null pointers.
static QualType getBaseOriginalType(const Expr *Base)
Return original type of the base expression for array section.
llvm::Type * ConvertType(QualType T)
static Destroyer destroyCXXObject
Qualifiers getQualifiers() const
Retrieve the set of qualifiers applied to this type.
A specialization of Address that requires the address to be an LLVM Constant.
unsigned getNumNegativeBits() const
Returns the width in bits required to store all the negative enumerators of this enum.
ObjCIvarDecl - Represents an ObjC instance variable.
! No language constraints on evaluation order.
static CGCallee EmitDirectCallee(CodeGenFunction &CGF, const FunctionDecl *FD)
const GlobalDecl getCalleeDecl() const
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 EmitTrapCheck(llvm::Value *Checked)
Create a basic block that will call the trap intrinsic, and emit a conditional branch to it...
static llvm::Value * getArrayIndexingBound(CodeGenFunction &CGF, const Expr *Base, QualType &IndexedType)
If Base is known to point to the start of an array, return the length of that array.
unsigned getVRQualifiers() const
QualType getPointerType(QualType T) const
Return the uniqued reference to the type for a pointer to the specified type.
llvm::ConstantInt * CreateCrossDsoCfiTypeId(llvm::Metadata *MD)
Generate a cross-DSO type identifier for MD.
LValue EmitCompoundLiteralLValue(const CompoundLiteralExpr *E)
RValue EmitLoadOfLValue(LValue V, SourceLocation Loc)
EmitLoadOfLValue - Given an expression that represents a value lvalue, this method emits the address ...
bool has(SanitizerMask K) const
Check if a certain (single) sanitizer is enabled.
LValue EmitPredefinedLValue(const PredefinedExpr *E)
StringLiteral - This represents a string literal expression, e.g.
Full-expression storage duration (for temporaries).
CallExpr - Represents a function call (C99 6.5.2.2, C++ [expr.call]).
static bool IsWrappedCXXThis(const Expr *E)
Check if E is a C++ "this" pointer wrapped in value-preserving casts.
Address EmitCXXUuidofExpr(const CXXUuidofExpr *E)
const MemberPointerType * MPT
LangAS getASTAllocaAddressSpace() const
Address EmitExtVectorElementLValue(LValue V)
Generates lvalue for partial ext_vector access.
QualType getIntegerType() const
Return the integer type this enum decl corresponds to.
llvm::Constant * tryEmitAbstract(const Expr *E, QualType T)
Try to emit the result of the given expression as an abstract constant.
StringRef getName() const
Get the name of identifier for this declaration as a StringRef.
unsigned getCVRQualifiers() const
LValue EmitCompoundAssignmentLValue(const CompoundAssignOperator *E)
CGCapturedStmtInfo * CapturedStmtInfo
llvm::Value * EmitScalarConversion(llvm::Value *Src, QualType SrcTy, QualType DstTy, SourceLocation Loc)
Emit a conversion from the specified type to the specified destination type, both of which are LLVM s...
CGCXXABI & getCXXABI() const
const VariableArrayType * getAsVariableArrayType(QualType T) const
std::string TrapFuncName
If not an empty string, trap intrinsics are lowered to calls to this function instead of to trap inst...
__DEVICE__ int max(int __a, int __b)
static LValue MakeGlobalReg(Address Reg, QualType type)
unsigned getNumElements() const
LValue EmitMemberExpr(const MemberExpr *E)
A reference to a declared variable, function, enum, etc.
static RValue get(llvm::Value *V)
RValue EmitBlockCallExpr(const CallExpr *E, ReturnValueSlot ReturnValue)
static ConstantEmissionKind checkVarTypeForConstantEmission(QualType type)
bool isPointerType() const
__DEVICE__ int min(int __a, int __b)
bool isExtVectorElt() const
const CGFunctionInfo & arrangeFreeFunctionCall(const CallArgList &Args, const FunctionType *Ty, bool ChainCall)
Figure out the rules for calling a function with the given formal type using the given arguments...
CharUnits getTypeSizeInChars(QualType T) const
Return the size of the specified (complete) type T, in characters.
llvm::Constant * EmitCheckSourceLocation(SourceLocation Loc)
Emit a description of a source location in a format suitable for passing to a runtime sanitizer handl...
uint64_t Offset
Offset - The byte offset of the final access within the base one.
bool isOBJCGCCandidate(ASTContext &Ctx) const
isOBJCGCCandidate - Return true if this expression may be used in a read/ write barrier.
bool isFloatingType() const
static RValue getAggregate(Address addr, bool isVolatile=false)
LValue - This represents an lvalue references.
SourceLocation getBeginLoc() const LLVM_READONLY
This represents a decl that may have a name.
llvm::Value * EmitObjCConsumeObject(QualType T, llvm::Value *Ptr)
Produce the code for a CK_ARCConsumeObject.
CGCalleeInfo getAbstractInfo() const
Represents a C array with a specified size that is not an integer-constant-expression.
bool DeclMustBeEmitted(const Decl *D)
Determines if the decl can be CodeGen'ed or deserialized from PCH lazily, only when used; this is onl...
A Microsoft C++ __uuidof expression, which gets the _GUID that corresponds to the supplied type or ex...
Automatic storage duration (most local variables).
SanitizerMetadata * getSanitizerMetadata()
const LangOptions & getLangOpts() const
unsigned getTargetAddressSpace(QualType T) const
void EmitCfiCheckStub()
Emit a stub for the cross-DSO CFI check function.
const CXXRecordDecl * DerivedClass
bool isFunctionPointerType() const
RValue EmitCXXOperatorMemberCallExpr(const CXXOperatorCallExpr *E, const CXXMethodDecl *MD, ReturnValueSlot ReturnValue)
static LValue MakeAddr(Address address, QualType type, ASTContext &Context, LValueBaseInfo BaseInfo, TBAAAccessInfo TBAAInfo)
llvm::Value * getVectorIdx() const
const CGRecordLayout & getCGRecordLayout(const RecordDecl *)
getCGRecordLayout - Return record layout info for the given record decl.
Address GetAddressOfBaseClass(Address Value, const CXXRecordDecl *Derived, CastExpr::path_const_iterator PathBegin, CastExpr::path_const_iterator PathEnd, bool NullCheckValue, SourceLocation Loc)
GetAddressOfBaseClass - This function will add the necessary delta to the load of 'this' and returns ...
CallArgList - Type for representing both the value and type of arguments in a call.
const LangOptions & getLangOpts() const
static TBAAAccessInfo getMayAliasInfo()
llvm::Value * getPointer() const
LValue EmitStringLiteralLValue(const StringLiteral *E)
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...
Abstract information about a function or function prototype.
void EmitCXXThrowExpr(const CXXThrowExpr *E, bool KeepInsertionPoint=true)
SourceLocation getLocation() const
void mergeForCast(const LValueBaseInfo &Info)
llvm::Constant * getExtVectorElts() const
Expr * getLength()
Get length of array section.
Structure with information about how a bitfield should be accessed.
CheckRecoverableKind
Specify under what conditions this check can be recovered.
Expr * IgnoreParens() LLVM_READONLY
IgnoreParens - Ignore parentheses.
static OMPLinearClause * Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation LParenLoc, OpenMPLinearClauseKind Modifier, SourceLocation ModifierLoc, SourceLocation ColonLoc, SourceLocation EndLoc, ArrayRef< Expr *> VL, ArrayRef< Expr *> PL, ArrayRef< Expr *> IL, Expr *Step, Expr *CalcStep, Stmt *PreInit, Expr *PostUpdate)
Creates clause with a list of variables VL and a linear step Step.
CanQualType getSizeType() const
Return the unique type for "size_t" (C99 7.17), defined in <stddef.h>.
void Destroyer(CodeGenFunction &CGF, Address addr, QualType ty)
Expr * getBase()
An array section can be written only as Base[LowerBound:Length].
Qualifiers::ObjCLifetime getObjCLifetime() const
Returns lifetime attribute of this type.
unsigned getLLVMFieldNo(const FieldDecl *FD) const
Return llvm::StructType element number that corresponds to the field FD.
virtual llvm::Value * EmitObjCWeakRead(CodeGen::CodeGenFunction &CGF, Address AddrWeakObj)=0
SourceLocation getExprLoc() const
llvm::FunctionType * GetFunctionType(const CGFunctionInfo &Info)
GetFunctionType - Get the LLVM function type for.
static const Expr * isSimpleArrayDecayOperand(const Expr *E)
isSimpleArrayDecayOperand - If the specified expr is a simple decay from an array to pointer...
static unsigned getAccessedFieldNo(unsigned Idx, const llvm::Constant *Elts)
getAccessedFieldNo - Given an encoded value and a result number, return the input field number being ...