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");
428 if (
auto *Var = dyn_cast<llvm::GlobalVariable>(Object.
getPointer())) {
429 Object =
Address(llvm::ConstantExpr::getBitCast(Var,
440 if (Var->hasInitializer())
449 default: llvm_unreachable(
"expected scalar or aggregate expression");
472 for (
const auto &Ignored : CommaLHSs)
475 if (
const auto *opaque = dyn_cast<OpaqueValueExpr>(E)) {
476 if (opaque->getType()->isRecordType()) {
477 assert(Adjustments.empty());
485 if (
auto *Var = dyn_cast<llvm::GlobalVariable>(
487 Object =
Address(llvm::ConstantExpr::getBitCast(
494 if (!Var->hasInitializer()) {
523 for (
unsigned I = Adjustments.size(); I != 0; --I) {
525 switch (Adjustment.
Kind) {
537 assert(LV.isSimple() &&
538 "materialized temporary field is not a simple lvalue");
539 Object = LV.getAddress();
579 const llvm::Constant *Elts) {
580 return cast<llvm::ConstantInt>(Elts->getAggregateElement(Idx))
587 llvm::Value *KMul = Builder.getInt64(0x9ddfea08eb382d69ULL);
589 llvm::Value *A0 = Builder.CreateMul(Builder.CreateXor(Low, High), KMul);
590 llvm::Value *A1 = Builder.CreateXor(Builder.CreateLShr(A0, K47), A0);
591 llvm::Value *B0 = Builder.CreateMul(Builder.CreateXor(High, A1), KMul);
592 llvm::Value *B1 = Builder.CreateXor(Builder.CreateLShr(B0, K47), B0);
593 return Builder.CreateMul(B1, KMul);
626 if (Ptr->getType()->getPointerAddressSpace())
637 llvm::BasicBlock *Done =
nullptr;
643 dyn_cast<llvm::AllocaInst>(Ptr->stripPointerCastsNoFollowAliases());
647 bool IsGuaranteedNonNull =
648 SkippedChecks.
has(SanitizerKind::Null) || PtrToAlloca;
650 if ((
SanOpts.
has(SanitizerKind::Null) || AllowNullPointers) &&
651 !IsGuaranteedNonNull) {
653 IsNonNull =
Builder.CreateIsNotNull(Ptr);
657 IsGuaranteedNonNull = IsNonNull == True;
660 if (!IsGuaranteedNonNull) {
661 if (AllowNullPointers) {
666 Builder.CreateCondBr(IsNonNull, Rest, Done);
669 Checks.push_back(std::make_pair(IsNonNull, SanitizerKind::Null));
675 !SkippedChecks.
has(SanitizerKind::ObjectSize) &&
689 Builder.CreateCall(F, {CastAddr, Min, NullIsUnknown}),
690 llvm::ConstantInt::get(
IntPtrTy, Size));
691 Checks.push_back(std::make_pair(LargeEnough, SanitizerKind::ObjectSize));
694 uint64_t AlignVal = 0;
698 !SkippedChecks.
has(SanitizerKind::Alignment)) {
705 (!PtrToAlloca || PtrToAlloca->getAlignment() < AlignVal)) {
708 PtrAsInt, llvm::ConstantInt::get(
IntPtrTy, AlignVal - 1));
712 Checks.push_back(std::make_pair(Aligned, SanitizerKind::Alignment));
716 if (Checks.size() > 0) {
719 assert(!AlignVal || (uint64_t)1 << llvm::Log2_64(AlignVal) == AlignVal);
720 llvm::Constant *StaticData[] = {
722 llvm::ConstantInt::get(
Int8Ty, AlignVal ? llvm::Log2_64(AlignVal) : 1),
723 llvm::ConstantInt::get(
Int8Ty, TCK)};
724 EmitCheck(Checks, SanitizerHandler::TypeMismatch, StaticData,
725 PtrAsInt ? PtrAsInt : Ptr);
740 if (!IsGuaranteedNonNull) {
742 IsNonNull =
Builder.CreateIsNotNull(Ptr);
746 Builder.CreateCondBr(IsNonNull, VptrNotNull, Done);
756 llvm::raw_svector_ostream Out(MangledName);
762 SanitizerKind::Vptr, Out.str())) {
763 llvm::hash_code TypeHash = hash_value(Out.str());
776 const int CacheSize = 128;
779 "__ubsan_vptr_type_cache");
793 llvm::Constant *StaticData[] = {
797 llvm::ConstantInt::get(
Int8Ty, TCK)
800 EmitCheck(std::make_pair(EqualHash, SanitizerKind::Vptr),
801 SanitizerHandler::DynamicTypeCacheMiss, StaticData,
818 if (
const auto *CAT = dyn_cast<ConstantArrayType>(AT)) {
819 if (CAT->getSize().ugt(1))
821 }
else if (!isa<IncompleteArrayType>(AT))
827 if (
const auto *ME = dyn_cast<MemberExpr>(E)) {
830 if (
const auto *FD = dyn_cast<FieldDecl>(ME->getMemberDecl())) {
833 return ++FI == FD->getParent()->field_end();
835 }
else if (
const auto *IRE = dyn_cast<ObjCIvarRefExpr>(E)) {
836 return IRE->getDecl()->getNextIvar() ==
nullptr;
853 auto *ParamDecl = dyn_cast<
ParmVarDecl>(ArrayDeclRef->getDecl());
857 auto *POSAttr = ParamDecl->
getAttr<PassObjectSizeAttr>();
862 int POSType = POSAttr->getType();
863 if (POSType != 0 && POSType != 1)
867 auto PassedSizeIt = SizeArguments.find(ParamDecl);
868 if (PassedSizeIt == SizeArguments.end())
872 assert(LocalDeclMap.count(PassedSizeDecl) &&
"Passed size not loadable");
873 Address AddrOfSize = LocalDeclMap.find(PassedSizeDecl)->second;
877 llvm::ConstantInt::get(SizeInBytes->getType(), EltSize);
878 return Builder.CreateUDiv(SizeInBytes, SizeOfElement);
888 return CGF.
Builder.getInt32(VT->getNumElements());
893 if (
const auto *CE = dyn_cast<CastExpr>(Base)) {
894 if (CE->getCastKind() == CK_ArrayToPointerDecay &&
896 IndexedType = CE->getSubExpr()->getType();
898 if (
const auto *CAT = dyn_cast<ConstantArrayType>(AT))
899 return CGF.
Builder.getInt(CAT->getSize());
900 else if (
const auto *VAT = dyn_cast<VariableArrayType>(AT))
918 assert(
SanOpts.
has(SanitizerKind::ArrayBounds) &&
919 "should not be called unless adding bounds checks");
931 llvm::Constant *StaticData[] = {
937 :
Builder.CreateICmpULE(IndexVal, BoundVal);
938 EmitCheck(std::make_pair(Check, SanitizerKind::ArrayBounds),
939 SanitizerHandler::OutOfBounds, StaticData, Index);
945 bool isInc,
bool isPre) {
949 if (isa<llvm::IntegerType>(InVal.first->getType())) {
950 uint64_t AmountVal = isInc ? 1 : -1;
951 NextVal = llvm::ConstantInt::get(InVal.first->getType(), AmountVal,
true);
954 NextVal =
Builder.CreateAdd(InVal.first, NextVal, isInc ?
"inc" :
"dec");
957 llvm::APFloat FVal(
getContext().getFloatTypeSemantics(ElemTy), 1);
963 NextVal =
Builder.CreateFAdd(InVal.first, NextVal, isInc ?
"inc" :
"dec");
973 return isPre ? IncVal : InVal;
983 DI->EmitExplicitCastType(E->
getType());
1001 if (
const CastExpr *CE = dyn_cast<CastExpr>(E)) {
1002 if (
const auto *ECE = dyn_cast<ExplicitCastExpr>(CE))
1005 switch (CE->getCastKind()) {
1009 case CK_AddressSpaceConversion:
1010 if (
auto PtrTy = CE->getSubExpr()->getType()->getAs<
PointerType>()) {
1011 if (PtrTy->getPointeeType()->isVoidType())
1019 if (BaseInfo) *BaseInfo = InnerBaseInfo;
1020 if (TBAAInfo) *TBAAInfo = InnerTBAAInfo;
1022 if (isa<ExplicitCastExpr>(CE)) {
1026 &TargetTypeBaseInfo,
1027 &TargetTypeTBAAInfo);
1030 TargetTypeTBAAInfo);
1040 if (
SanOpts.
has(SanitizerKind::CFIUnrelatedCast) &&
1041 CE->getCastKind() == CK_BitCast) {
1048 return CE->getCastKind() != CK_AddressSpaceConversion
1056 case CK_ArrayToPointerDecay:
1060 case CK_UncheckedDerivedToBase:
1061 case CK_DerivedToBase: {
1068 auto Derived = CE->getSubExpr()->
getType()->getPointeeCXXRecordDecl();
1070 CE->path_begin(), CE->path_end(),
1084 if (UO->getOpcode() == UO_AddrOf) {
1123 llvm_unreachable(
"bad evaluation kind");
1142 while (!isa<CXXThisExpr>(Base)) {
1144 if (isa<CXXDynamicCastExpr>(Base))
1147 if (
const auto *CE = dyn_cast<CastExpr>(Base)) {
1148 Base = CE->getSubExpr();
1149 }
else if (
const auto *PE = dyn_cast<ParenExpr>(Base)) {
1150 Base = PE->getSubExpr();
1151 }
else if (
const auto *UO = dyn_cast<UnaryOperator>(Base)) {
1152 if (UO->getOpcode() == UO_Extension)
1153 Base = UO->getSubExpr();
1165 if (
SanOpts.
has(SanitizerKind::ArrayBounds) && isa<ArraySubscriptExpr>(E))
1171 if (
const auto *ME = dyn_cast<MemberExpr>(E)) {
1174 SkippedChecks.
set(SanitizerKind::Alignment,
true);
1175 if (IsBaseCXXThis || isa<DeclRefExpr>(ME->getBase()))
1176 SkippedChecks.
set(SanitizerKind::Null,
true);
1204 case Expr::ObjCPropertyRefExprClass:
1205 llvm_unreachable(
"cannot emit a property reference directly");
1207 case Expr::ObjCSelectorExprClass:
1209 case Expr::ObjCIsaExprClass:
1211 case Expr::BinaryOperatorClass:
1213 case Expr::CompoundAssignOperatorClass: {
1216 Ty = AT->getValueType();
1221 case Expr::CallExprClass:
1222 case Expr::CXXMemberCallExprClass:
1223 case Expr::CXXOperatorCallExprClass:
1224 case Expr::UserDefinedLiteralClass:
1226 case Expr::VAArgExprClass:
1228 case Expr::DeclRefExprClass:
1230 case Expr::ParenExprClass:
1231 return EmitLValue(cast<ParenExpr>(E)->getSubExpr());
1232 case Expr::GenericSelectionExprClass:
1233 return EmitLValue(cast<GenericSelectionExpr>(E)->getResultExpr());
1234 case Expr::PredefinedExprClass:
1236 case Expr::StringLiteralClass:
1238 case Expr::ObjCEncodeExprClass:
1240 case Expr::PseudoObjectExprClass:
1242 case Expr::InitListExprClass:
1244 case Expr::CXXTemporaryObjectExprClass:
1245 case Expr::CXXConstructExprClass:
1247 case Expr::CXXBindTemporaryExprClass:
1249 case Expr::CXXUuidofExprClass:
1251 case Expr::LambdaExprClass:
1254 case Expr::ExprWithCleanupsClass: {
1255 const auto *cleanups = cast<ExprWithCleanups>(E);
1272 case Expr::CXXDefaultArgExprClass:
1273 return EmitLValue(cast<CXXDefaultArgExpr>(E)->getExpr());
1274 case Expr::CXXDefaultInitExprClass: {
1276 return EmitLValue(cast<CXXDefaultInitExpr>(E)->getExpr());
1278 case Expr::CXXTypeidExprClass:
1281 case Expr::ObjCMessageExprClass:
1283 case Expr::ObjCIvarRefExprClass:
1285 case Expr::StmtExprClass:
1287 case Expr::UnaryOperatorClass:
1289 case Expr::ArraySubscriptExprClass:
1291 case Expr::OMPArraySectionExprClass:
1293 case Expr::ExtVectorElementExprClass:
1295 case Expr::MemberExprClass:
1297 case Expr::CompoundLiteralExprClass:
1299 case Expr::ConditionalOperatorClass:
1301 case Expr::BinaryConditionalOperatorClass:
1303 case Expr::ChooseExprClass:
1304 return EmitLValue(cast<ChooseExpr>(E)->getChosenSubExpr());
1305 case Expr::OpaqueValueExprClass:
1307 case Expr::SubstNonTypeTemplateParmExprClass:
1308 return EmitLValue(cast<SubstNonTypeTemplateParmExpr>(E)->getReplacement());
1309 case Expr::ImplicitCastExprClass:
1310 case Expr::CStyleCastExprClass:
1311 case Expr::CXXFunctionalCastExprClass:
1312 case Expr::CXXStaticCastExprClass:
1313 case Expr::CXXDynamicCastExprClass:
1314 case Expr::CXXReinterpretCastExprClass:
1315 case Expr::CXXConstCastExprClass:
1316 case Expr::ObjCBridgedCastExprClass:
1319 case Expr::MaterializeTemporaryExprClass:
1322 case Expr::CoawaitExprClass:
1324 case Expr::CoyieldExprClass:
1337 if (!qs.hasConst() || qs.hasVolatile())
return false;
1341 if (
const auto *RT = dyn_cast<RecordType>(type))
1342 if (
const auto *RD = dyn_cast<CXXRecordDecl>(RT->getDecl()))
1343 if (RD->hasMutableFields() || !RD->isTrivial())
1364 if (
const auto *ref = dyn_cast<ReferenceType>(type)) {
1385 if (isa<ParmVarDecl>(value)) {
1387 }
else if (
auto *var = dyn_cast<VarDecl>(value)) {
1389 }
else if (isa<EnumConstantDecl>(value)) {
1397 bool resultIsReference;
1403 resultIsReference =
false;
1404 resultType = refExpr->
getType();
1409 resultIsReference =
true;
1410 resultType = value->
getType();
1423 result.
Val, resultType);
1427 if (isa<VarDecl>(value)) {
1431 assert(isa<EnumConstantDecl>(value));
1436 if (resultIsReference)
1473 return ET->getDecl()->getIntegerType()->isBooleanType();
1482 llvm::APInt &Min, llvm::APInt &
End,
1483 bool StrictEnums,
bool IsBool) {
1485 bool IsRegularCPlusPlusEnum = CGF.
getLangOpts().CPlusPlus && StrictEnums &&
1487 if (!IsBool && !IsRegularCPlusPlusEnum)
1496 unsigned Bitwidth = LTy->getScalarSizeInBits();
1500 if (NumNegativeBits) {
1501 unsigned NumBits =
std::max(NumNegativeBits, NumPositiveBits + 1);
1502 assert(NumBits <= Bitwidth);
1503 End = llvm::APInt(Bitwidth, 1) << (NumBits - 1);
1506 assert(NumPositiveBits <= Bitwidth);
1507 End = llvm::APInt(Bitwidth, 1) << NumPositiveBits;
1508 Min = llvm::APInt(Bitwidth, 0);
1514 llvm::MDNode *CodeGenFunction::getRangeForLoadFromType(
QualType Ty) {
1515 llvm::APInt Min,
End;
1521 return MDHelper.createRange(Min, End);
1526 bool HasBoolCheck =
SanOpts.
has(SanitizerKind::Bool);
1527 bool HasEnumCheck =
SanOpts.
has(SanitizerKind::Enum);
1528 if (!HasBoolCheck && !HasEnumCheck)
1533 bool NeedsBoolCheck = HasBoolCheck && IsBool;
1534 bool NeedsEnumCheck = HasEnumCheck && Ty->
getAs<
EnumType>();
1535 if (!NeedsBoolCheck && !NeedsEnumCheck)
1542 cast<llvm::IntegerType>(Value->getType())->getBitWidth() == 1)
1545 llvm::APInt Min,
End;
1554 Check =
Builder.CreateICmpULE(Value, llvm::ConstantInt::get(Ctx, End));
1557 Builder.CreateICmpSLE(Value, llvm::ConstantInt::get(Ctx, End));
1559 Builder.CreateICmpSGE(Value, llvm::ConstantInt::get(Ctx, Min));
1560 Check =
Builder.CreateAnd(Upper, Lower);
1565 NeedsEnumCheck ? SanitizerKind::Enum : SanitizerKind::Bool;
1566 EmitCheck(std::make_pair(Check, Kind), SanitizerHandler::LoadInvalidValue,
1576 bool isNontemporal) {
1582 const auto *VTy = cast<llvm::VectorType>(EltTy);
1585 if (VTy->getNumElements() == 3) {
1588 llvm::VectorType *vec4Ty =
1589 llvm::VectorType::get(VTy->getElementType(), 4);
1595 V =
Builder.CreateShuffleVector(V, llvm::UndefValue::get(vec4Ty),
1596 {0, 1, 2},
"extractVec");
1610 if (isNontemporal) {
1611 llvm::MDNode *
Node = llvm::MDNode::get(
1612 Load->getContext(), llvm::ConstantAsMetadata::get(
Builder.getInt32(1)));
1622 if (llvm::MDNode *RangeInfo = getRangeForLoadFromType(Ty))
1623 Load->setMetadata(llvm::LLVMContext::MD_range, RangeInfo);
1633 if (Value->getType()->isIntegerTy(1))
1636 "wrong value rep of bool");
1646 "wrong value rep of bool");
1647 return Builder.CreateTrunc(Value,
Builder.getInt1Ty(),
"tobool");
1657 bool isInit,
bool isNontemporal) {
1662 auto *VecTy = dyn_cast<llvm::VectorType>(SrcTy);
1664 if (VecTy && VecTy->getNumElements() == 3) {
1666 llvm::Constant *Mask[] = {
Builder.getInt32(0),
Builder.getInt32(1),
1668 llvm::UndefValue::get(
Builder.getInt32Ty())};
1669 llvm::Value *MaskV = llvm::ConstantVector::get(Mask);
1670 Value =
Builder.CreateShuffleVector(Value, llvm::UndefValue::get(VecTy),
1671 MaskV,
"extractVec");
1672 SrcTy = llvm::VectorType::get(VecTy->getElementType(), 4);
1691 if (isNontemporal) {
1692 llvm::MDNode *
Node =
1693 llvm::MDNode::get(Store->getContext(),
1694 llvm::ConstantAsMetadata::get(
Builder.getInt32(1)));
1753 assert(LV.
isBitField() &&
"Unknown LValue type!");
1771 Val =
Builder.CreateShl(Val, HighBits,
"bf.shl");
1772 if (Info.
Offset + HighBits)
1773 Val =
Builder.CreateAShr(Val, Info.
Offset + HighBits,
"bf.ashr");
1808 for (
unsigned i = 0; i != NumResultElts; ++i)
1811 llvm::Value *MaskV = llvm::ConstantVector::get(Mask);
1812 Vec =
Builder.CreateShuffleVector(Vec, llvm::UndefValue::get(Vec->getType()),
1824 Address CastToPointerElement =
1826 "conv.ptr.element");
1836 return VectorBasePtrPlusIx;
1842 "Bad type for register variable");
1843 llvm::MDNode *RegName = cast<llvm::MDNode>(
1844 cast<llvm::MetadataAsValue>(LV.
getGlobalReg())->getMetadata());
1849 if (OrigTy->isPointerTy())
1855 F, llvm::MetadataAsValue::get(Ty->getContext(), RegName));
1856 if (OrigTy->isPointerTy())
1857 Call =
Builder.CreateIntToPtr(Call, OrigTy);
1887 assert(Dst.
isBitField() &&
"Unknown LValue type");
1895 llvm_unreachable(
"present but none");
1942 RHS =
Builder.CreatePtrToInt(RHS, ResultType,
"sub.ptr.rhs.cast");
1945 "sub.ptr.lhs.cast");
1958 assert(Src.
isScalar() &&
"Can't emit an agg store with this method");
1972 SrcVal =
Builder.CreateIntCast(SrcVal, Ptr.getElementType(),
1985 SrcVal =
Builder.CreateAnd(SrcVal,
2001 SrcVal =
Builder.CreateOr(Val, SrcVal,
"bf.set");
2003 assert(Info.
Offset == 0);
2018 ResultVal =
Builder.CreateShl(ResultVal, HighBits,
"bf.result.shl");
2019 ResultVal =
Builder.CreateAShr(ResultVal, HighBits,
"bf.result.ashr");
2040 unsigned NumSrcElts = VTy->getNumElements();
2041 unsigned NumDstElts = Vec->getType()->getVectorNumElements();
2042 if (NumDstElts == NumSrcElts) {
2047 for (
unsigned i = 0; i != NumSrcElts; ++i)
2050 llvm::Value *MaskV = llvm::ConstantVector::get(Mask);
2051 Vec =
Builder.CreateShuffleVector(SrcVal,
2052 llvm::UndefValue::get(Vec->getType()),
2054 }
else if (NumDstElts > NumSrcElts) {
2060 for (
unsigned i = 0; i != NumSrcElts; ++i)
2061 ExtMask.push_back(
Builder.getInt32(i));
2062 ExtMask.resize(NumDstElts, llvm::UndefValue::get(
Int32Ty));
2063 llvm::Value *ExtMaskV = llvm::ConstantVector::get(ExtMask);
2065 Builder.CreateShuffleVector(SrcVal,
2066 llvm::UndefValue::get(SrcVal->getType()),
2070 for (
unsigned i = 0; i != NumDstElts; ++i)
2071 Mask.push_back(
Builder.getInt32(i));
2080 for (
unsigned i = 0; i != NumSrcElts; ++i)
2082 llvm::Value *MaskV = llvm::ConstantVector::get(Mask);
2083 Vec =
Builder.CreateShuffleVector(Vec, ExtSrcVal, MaskV);
2086 llvm_unreachable(
"unexpected shorten vector length");
2092 Vec =
Builder.CreateInsertElement(Vec, SrcVal, Elt);
2102 "Bad type for register variable");
2103 llvm::MDNode *RegName = cast<llvm::MDNode>(
2104 cast<llvm::MetadataAsValue>(Dst.
getGlobalReg())->getMetadata());
2105 assert(RegName &&
"Register LValue is not metadata");
2110 if (OrigTy->isPointerTy())
2116 if (OrigTy->isPointerTy())
2117 Value =
Builder.CreatePtrToInt(Value, Ty);
2119 F, {llvm::MetadataAsValue::get(Ty->getContext(), RegName), Value});
2127 bool IsMemberAccess=
false) {
2131 if (isa<ObjCIvarRefExpr>(E)) {
2144 auto *Exp = cast<ObjCIvarRefExpr>(
const_cast<Expr *
>(E));
2150 if (
const auto *Exp = dyn_cast<DeclRefExpr>(E)) {
2151 if (
const auto *VD = dyn_cast<VarDecl>(Exp->getDecl())) {
2152 if (VD->hasGlobalStorage()) {
2161 if (
const auto *Exp = dyn_cast<UnaryOperator>(E)) {
2166 if (
const auto *Exp = dyn_cast<ParenExpr>(E)) {
2180 if (
const auto *Exp = dyn_cast<GenericSelectionExpr>(E)) {
2185 if (
const auto *Exp = dyn_cast<ImplicitCastExpr>(E)) {
2190 if (
const auto *Exp = dyn_cast<CStyleCastExpr>(E)) {
2195 if (
const auto *Exp = dyn_cast<ObjCBridgedCastExpr>(E)) {
2200 if (
const auto *Exp = dyn_cast<ArraySubscriptExpr>(E)) {
2213 if (
const auto *Exp = dyn_cast<MemberExpr>(E)) {
2225 StringRef Name = StringRef()) {
2226 unsigned AS = cast<llvm::PointerType>(V->getType())->getAddressSpace();
2240 for (
const auto *D : VD->
redecls()) {
2243 if (
const auto *
Attr = D->getAttr<OMPDeclareTargetDeclAttr>())
2244 if (
Attr->getMapType() == OMPDeclareTargetDeclAttr::MT_Link) {
2263 PointeeBaseInfo, PointeeTBAAInfo,
2274 PointeeBaseInfo, PointeeTBAAInfo);
2319 VD->
hasAttr<OMPThreadPrivateDeclAttr>()) {
2333 if (FD->
hasAttr<WeakRefAttr>()) {
2348 V = llvm::ConstantExpr::getBitCast(V,
2378 AsmLabelAttr *Asm = VD->
getAttr<AsmLabelAttr>();
2379 assert(Asm->getLabel().size() < 64-Name.size() &&
2380 "Register name too big");
2381 Name.append(Asm->getLabel());
2382 llvm::NamedMDNode *M =
2383 CGM.
getModule().getOrInsertNamedMetadata(Name);
2384 if (M->getNumOperands() == 0) {
2387 llvm::Metadata *Ops[] = {Str};
2394 llvm::MetadataAsValue::get(CGM.
getLLVMContext(), M->getOperand(0));
2402 if (
const auto *VD = dyn_cast<VarDecl>(ND)) {
2405 VD->hasAttr<AsmLabelAttr>() && !VD->isLocalVarDecl())
2410 const Expr *Init = VD->getAnyInitializer(VD);
2411 const auto *BD = dyn_cast_or_null<BlockDecl>(
CurCodeDecl);
2413 VD->isUsableInConstantExpressions(
getContext()) &&
2414 VD->checkInitIsICE() &&
2418 (LocalDeclMap.count(VD->getCanonicalDecl()) ||
2421 (BD && BD->capturesVariable(VD))))) {
2422 llvm::Constant *Val =
2424 *VD->evaluateValue(),
2426 assert(Val &&
"failed to emit reference constant expression");
2439 VD = VD->getCanonicalDecl();
2443 auto I = LocalDeclMap.find(VD);
2444 if (I != LocalDeclMap.end()) {
2445 if (VD->getType()->isReferenceType())
2468 assert((ND->
isUsed(
false) || !isa<VarDecl>(ND) ||
2470 "Should not use decl without marking it used!");
2472 if (ND->
hasAttr<WeakRefAttr>()) {
2473 const auto *VD = cast<ValueDecl>(ND);
2478 if (
const auto *VD = dyn_cast<VarDecl>(ND)) {
2480 if (VD->hasLinkage() || VD->isStaticDataMember())
2486 auto iter = LocalDeclMap.find(VD);
2487 if (iter != LocalDeclMap.end()) {
2488 addr = iter->second;
2492 }
else if (VD->isStaticLocal()) {
2499 llvm_unreachable(
"DeclRefExpr for Decl not entered in LocalDeclMap?");
2505 VD->hasAttr<OMPThreadPrivateDeclAttr>()) {
2512 bool isBlockByref = VD->hasAttr<BlocksAttr>();
2522 bool isLocalStorage = VD->hasLocalStorage();
2524 bool NonGCable = isLocalStorage &&
2525 !VD->getType()->isReferenceType() &&
2532 bool isImpreciseLifetime =
2533 (isLocalStorage && !VD->hasAttr<ObjCPreciseLifetimeAttr>());
2534 if (isImpreciseLifetime)
2540 if (
const auto *FD = dyn_cast<FunctionDecl>(ND))
2546 if (
const auto *BD = dyn_cast<BindingDecl>(ND))
2549 llvm_unreachable(
"Unhandled DeclRefExpr");
2559 default: llvm_unreachable(
"Unknown unary operator lvalue!");
2562 assert(!T.
isNull() &&
"CodeGenFunction::EmitUnaryOpLValue: Illegal type");
2584 assert(LV.
isSimple() &&
"real/imag on non-ordinary l-value");
2608 bool isInc = E->
getOpcode() == UO_PreInc;
2631 assert(SL !=
nullptr &&
"No StringLiteral name in PredefinedExpr");
2632 StringRef FnName =
CurFn->getName();
2633 if (FnName.startswith(
"\01"))
2634 FnName = FnName.substr(1);
2635 StringRef NameItems[] = {
2637 std::string GVName = llvm::join(NameItems, NameItems + 2,
".");
2638 if (
auto *BD = dyn_cast_or_null<BlockDecl>(
CurCodeDecl)) {
2639 std::string Name = SL->getString();
2640 if (!Name.empty()) {
2641 unsigned Discriminator =
2644 Name +=
"_" + Twine(Discriminator + 1).str();
2670 uint16_t TypeKind = -1;
2687 StringRef(), StringRef(), None, Buffer,
2690 llvm::Constant *Components[] = {
2694 llvm::Constant *Descriptor = llvm::ConstantStruct::getAnon(Components);
2696 auto *GV =
new llvm::GlobalVariable(
2698 true, llvm::GlobalVariable::PrivateLinkage, Descriptor);
2699 GV->setUnnamedAddr(llvm::GlobalValue::UnnamedAddr::Global);
2711 if (V->getType() == TargetTy)
2716 if (V->getType()->isFloatingPointTy()) {
2717 unsigned Bits = V->getType()->getPrimitiveSizeInBits();
2718 if (Bits <= TargetTy->getIntegerBitWidth())
2724 if (V->getType()->isIntegerTy() &&
2725 V->getType()->getIntegerBitWidth() <= TargetTy->getIntegerBitWidth())
2726 return Builder.CreateZExt(V, TargetTy);
2729 if (!V->getType()->isPointerTy()) {
2734 return Builder.CreatePtrToInt(V, TargetTy);
2754 int PathComponentsToStrip =
2756 if (PathComponentsToStrip < 0) {
2757 assert(PathComponentsToStrip !=
INT_MIN);
2758 int PathComponentsToKeep = -PathComponentsToStrip;
2759 auto I = llvm::sys::path::rbegin(FilenameString);
2760 auto E = llvm::sys::path::rend(FilenameString);
2761 while (I != E && --PathComponentsToKeep)
2764 FilenameString = FilenameString.substr(I - E);
2765 }
else if (PathComponentsToStrip > 0) {
2766 auto I = llvm::sys::path::begin(FilenameString);
2767 auto E = llvm::sys::path::end(FilenameString);
2768 while (I != E && PathComponentsToStrip--)
2773 FilenameString.substr(I - llvm::sys::path::begin(FilenameString));
2775 FilenameString = llvm::sys::path::filename(FilenameString);
2780 cast<llvm::GlobalVariable>(FilenameGV.getPointer()));
2781 Filename = FilenameGV.getPointer();
2785 Filename = llvm::Constant::getNullValue(
Int8PtrTy);
2792 return llvm::ConstantStruct::getAnon(Data);
2809 assert(llvm::countPopulation(Kind) == 1);
2811 case SanitizerKind::Vptr:
2813 case SanitizerKind::Return:
2814 case SanitizerKind::Unreachable:
2817 return CheckRecoverableKind::Recoverable;
2822 struct SanitizerHandlerInfo {
2823 char const *
const Name;
2829 #define SANITIZER_CHECK(Enum, Name, Version) {#Name, Version}, 2831 #undef SANITIZER_CHECK 2835 llvm::FunctionType *FnType,
2839 llvm::BasicBlock *ContBB) {
2841 bool NeedsAbortSuffix =
2844 const SanitizerHandlerInfo &CheckInfo = SanitizerHandlers[CheckHandler];
2845 const StringRef CheckName = CheckInfo.Name;
2846 std::string FnName =
"__ubsan_handle_" + CheckName.str();
2847 if (CheckInfo.Version && !MinimalRuntime)
2848 FnName +=
"_v" + llvm::utostr(CheckInfo.Version);
2850 FnName +=
"_minimal";
2851 if (NeedsAbortSuffix)
2856 llvm::AttrBuilder B;
2858 B.addAttribute(llvm::Attribute::NoReturn)
2859 .addAttribute(llvm::Attribute::NoUnwind);
2861 B.addAttribute(llvm::Attribute::UWTable);
2866 llvm::AttributeList::FunctionIndex, B),
2870 HandlerCall->setDoesNotReturn();
2871 CGF.
Builder.CreateUnreachable();
2878 ArrayRef<std::pair<llvm::Value *, SanitizerMask>> Checked,
2882 assert(Checked.size() > 0);
2883 assert(CheckHandler >= 0 &&
2884 size_t(CheckHandler) < llvm::array_lengthof(SanitizerHandlers));
2885 const StringRef CheckName = SanitizerHandlers[CheckHandler].Name;
2890 for (
int i = 0, n = Checked.size(); i < n; ++i) {
2899 Cond = Cond ?
Builder.CreateAnd(Cond, Check) : Check;
2904 if (!FatalCond && !RecoverableCond)
2908 if (FatalCond && RecoverableCond)
2909 JointCond =
Builder.CreateAnd(FatalCond, RecoverableCond);
2911 JointCond = FatalCond ? FatalCond : RecoverableCond;
2917 for (
int i = 1, n = Checked.size(); i < n; ++i) {
2919 "All recoverable kinds in a single check must be same!");
2926 llvm::Instruction *Branch =
Builder.CreateCondBr(JointCond, Cont, Handlers);
2930 llvm::MDNode *
Node = MDHelper.createBranchWeights((1U << 20) - 1, 1);
2931 Branch->setMetadata(llvm::LLVMContext::MD_prof, Node);
2940 Args.reserve(DynamicArgs.size() + 1);
2941 ArgTypes.reserve(DynamicArgs.size() + 1);
2944 if (!StaticArgs.empty()) {
2945 llvm::Constant *Info = llvm::ConstantStruct::getAnon(StaticArgs);
2947 new llvm::GlobalVariable(
CGM.
getModule(), Info->getType(),
false,
2948 llvm::GlobalVariable::PrivateLinkage, Info);
2949 InfoPtr->setUnnamedAddr(llvm::GlobalValue::UnnamedAddr::Global);
2955 for (
size_t i = 0, n = DynamicArgs.size(); i != n; ++i) {
2961 llvm::FunctionType *FnType =
2962 llvm::FunctionType::get(
CGM.
VoidTy, ArgTypes,
false);
2964 if (!FatalCond || !RecoverableCond) {
2968 (FatalCond !=
nullptr), Cont);
2972 llvm::BasicBlock *NonFatalHandlerBB =
2975 Builder.CreateCondBr(FatalCond, NonFatalHandlerBB, FatalHandlerBB);
2993 llvm::BranchInst *BI =
Builder.CreateCondBr(Cond, Cont, CheckBB);
2996 llvm::MDNode *
Node = MDHelper.createBranchWeights((1U << 20) - 1, 1);
2997 BI->setMetadata(llvm::LLVMContext::MD_prof, Node);
3003 llvm::CallInst *CheckCall;
3004 llvm::Constant *SlowPathFn;
3006 llvm::Constant *Info = llvm::ConstantStruct::getAnon(StaticArgs);
3008 new llvm::GlobalVariable(
CGM.
getModule(), Info->getType(),
false,
3009 llvm::GlobalVariable::PrivateLinkage, Info);
3010 InfoPtr->setUnnamedAddr(llvm::GlobalValue::UnnamedAddr::Global);
3014 "__cfi_slowpath_diag",
3017 CheckCall =
Builder.CreateCall(
3023 CheckCall =
Builder.CreateCall(SlowPathFn, {TypeId, Ptr});
3026 CGM.
setDSOLocal(cast<llvm::GlobalValue>(SlowPathFn->stripPointerCasts()));
3027 CheckCall->setDoesNotThrow();
3036 auto &Ctx = M->getContext();
3039 llvm::GlobalValue::WeakAnyLinkage,
"__cfi_check", M);
3047 llvm::Intrinsic::getDeclaration(M, llvm::Intrinsic::trap),
"", BB);
3065 Args.push_back(&ArgData);
3066 Args.push_back(&ArgAddr);
3073 llvm::GlobalValue::WeakODRLinkage,
"__cfi_check_fail", &
CGM.
getModule());
3096 llvm::StructType *SourceLocationTy =
3098 llvm::StructType *CfiCheckFailDataTy =
3099 llvm::StructType::get(
Int8Ty, SourceLocationTy, VoidPtrTy);
3103 Builder.CreatePointerCast(Data, CfiCheckFailDataTy->getPointerTo(0)), 0,
3108 llvm::Value *AllVtables = llvm::MetadataAsValue::get(
3113 {Addr, AllVtables}),
3116 const std::pair<int, SanitizerMask> CheckKinds[] = {
3124 for (
auto CheckKindMaskPair : CheckKinds) {
3125 int Kind = CheckKindMaskPair.first;
3128 Builder.CreateICmpNE(CheckKind, llvm::ConstantInt::get(
Int8Ty, Kind));
3130 EmitCheck(std::make_pair(Cond, Mask), SanitizerHandler::CFICheckFail, {},
3131 {Data, Addr, ValidVtable});
3143 if (
SanOpts.
has(SanitizerKind::Unreachable)) {
3146 SanitizerKind::Unreachable),
3147 SanitizerHandler::BuiltinUnreachable,
3160 Builder.CreateCondBr(Checked, Cont, TrapBB);
3162 llvm::CallInst *TrapCall =
EmitTrapCall(llvm::Intrinsic::trap);
3163 TrapCall->setDoesNotReturn();
3164 TrapCall->setDoesNotThrow();
3167 Builder.CreateCondBr(Checked, Cont, TrapBB);
3177 auto A = llvm::Attribute::get(
getLLVMContext(),
"trap-func-name",
3179 TrapCall->addAttribute(llvm::AttributeList::FunctionIndex, A);
3189 "Array to pointer decay must have array source type!");
3193 Address Addr = LV.getAddress();
3203 assert(isa<llvm::ArrayType>(Addr.getElementType()) &&
3204 "Expected pointer to array");
3214 if (BaseInfo) *BaseInfo = LV.getBaseInfo();
3224 const auto *CE = dyn_cast<
CastExpr>(E);
3225 if (!CE || CE->getCastKind() != CK_ArrayToPointerDecay)
3229 const Expr *SubExpr = CE->getSubExpr();
3242 const llvm::Twine &name =
"arrayidx") {
3248 return CGF.
Builder.CreateGEP(ptr, indices, name);
3257 if (
auto constantIdx = dyn_cast<llvm::ConstantInt>(idx)) {
3258 CharUnits offset = constantIdx->getZExtValue() * eltSize;
3280 const llvm::Twine &name =
"arrayidx") {
3283 for (
auto idx : indices.drop_back())
3284 assert(isa<llvm::ConstantInt>(idx) &&
3285 cast<llvm::ConstantInt>(idx)->
isZero());
3300 CGF, addr.
getPointer(), indices, inbounds, signedIndices, loc, name);
3301 return Address(eltPtr, eltAlign);
3310 bool SignedIndices =
false;
3311 auto EmitIdxAfterBase = [&, IdxPre](
bool Promote) ->
llvm::Value * {
3314 assert(E->
getRHS() == E->
getIdx() &&
"index was neither LHS nor RHS");
3320 SignedIndices |= IdxSigned;
3326 if (Promote && Idx->getType() !=
IntPtrTy)
3336 !isa<ExtVectorElementExpr>(E->
getBase())) {
3339 auto *Idx = EmitIdxAfterBase(
false);
3340 assert(LHS.
isSimple() &&
"Can only subscript lvalue vectors here!");
3348 if (isa<ExtVectorElementExpr>(E->
getBase())) {
3350 auto *Idx = EmitIdxAfterBase(
true);
3369 auto *Idx = EmitIdxAfterBase(
true);
3379 Idx =
Builder.CreateMul(Idx, numElements);
3381 Idx =
Builder.CreateNSWMul(Idx, numElements);
3393 auto *Idx = EmitIdxAfterBase(
true);
3397 llvm::ConstantInt::get(Idx->getType(), InterfaceSize.
getQuantity());
3414 Addr =
Address(EltPtr, EltAlign);
3423 assert(Array->getType()->isArrayType() &&
3424 "Array to pointer decay must have array source type!");
3428 if (
const auto *ASE = dyn_cast<ArraySubscriptExpr>(Array))
3432 auto *Idx = EmitIdxAfterBase(
true);
3439 EltBaseInfo = ArrayLV.getBaseInfo();
3444 auto *Idx = EmitIdxAfterBase(
true);
3464 bool IsLowerBound) {
3481 "Expected pointer to array");
3501 bool IsLowerBound) {
3505 ResultExprTy = AT->getElementType();
3516 LowerBound->getType()->hasSignedIntegerRepresentation());
3518 Idx = llvm::ConstantInt::getNullValue(
IntPtrTy);
3525 llvm::APSInt ConstLength;
3528 if (Length->isIntegerConstantExpr(ConstLength, C)) {
3534 if (LowerBound && LowerBound->isIntegerConstantExpr(ConstLowerBound, C)) {
3536 LowerBound =
nullptr;
3540 else if (!LowerBound)
3543 if (Length || LowerBound) {
3544 auto *LowerBoundVal =
3548 LowerBound->getType()->hasSignedIntegerRepresentation())
3549 : llvm::ConstantInt::get(
IntPtrTy, ConstLowerBound);
3554 Length->getType()->hasSignedIntegerRepresentation())
3555 : llvm::ConstantInt::get(
IntPtrTy, ConstLength);
3556 Idx =
Builder.CreateAdd(LowerBoundVal, LengthVal,
"lb_add_len",
3559 if (Length && LowerBound) {
3561 Idx, llvm::ConstantInt::get(
IntPtrTy, 1),
"idx_sub_1",
3565 Idx = llvm::ConstantInt::get(
IntPtrTy, ConstLength + ConstLowerBound);
3571 if (
auto *VAT = C.getAsVariableArrayType(ArrayTy)) {
3572 Length = VAT->getSizeExpr();
3573 if (Length->isIntegerConstantExpr(ConstLength, C))
3576 auto *CAT = C.getAsConstantArrayType(ArrayTy);
3577 ConstLength = CAT->getSize();
3580 auto *LengthVal =
Builder.CreateIntCast(
3582 Length->getType()->hasSignedIntegerRepresentation());
3584 LengthVal, llvm::ConstantInt::get(
IntPtrTy, 1),
"len_sub_1",
3589 Idx = llvm::ConstantInt::get(
IntPtrTy, ConstLength);
3598 if (
auto *VLA =
getContext().getAsVariableArrayType(ResultExprTy)) {
3604 BaseTy, VLA->getElementType(), IsLowerBound);
3613 Idx =
Builder.CreateMul(Idx, NumElements);
3615 Idx =
Builder.CreateNSWMul(Idx, NumElements);
3624 assert(Array->getType()->isArrayType() &&
3625 "Array to pointer decay must have array source type!");
3629 if (
const auto *ASE = dyn_cast<ArraySubscriptExpr>(Array))
3639 BaseInfo = ArrayLV.getBaseInfo();
3643 TBAAInfo, BaseTy, ResultExprTy,
3666 Base =
MakeAddrLValue(Ptr, PT->getPointeeType(), BaseInfo, TBAAInfo);
3667 Base.getQuals().removeObjCGCAttr();
3676 "Result must be a vector");
3694 llvm::Constant *CV =
3699 assert(Base.
isExtVectorElt() &&
"Can only subscript lvalue vec elts here!");
3704 for (
unsigned i = 0, e = Indices.size(); i != e; ++i)
3705 CElts.push_back(BaseElts->getAggregateElement(Indices[i]));
3706 llvm::Constant *CV = llvm::ConstantVector::get(CElts);
3728 SkippedChecks.
set(SanitizerKind::Alignment,
true);
3729 if (IsBaseCXXThis || isa<DeclRefExpr>(BaseExpr))
3730 SkippedChecks.
set(SanitizerKind::Null,
true);
3738 if (
auto *Field = dyn_cast<FieldDecl>(ND)) {
3744 if (
const auto *FD = dyn_cast<FunctionDecl>(ND))
3747 llvm_unreachable(
"Unhandled member declaration!");
3753 assert(cast<CXXMethodDecl>(
CurCodeDecl)->getParent()->isLambda());
3778 "LLVM field at index zero had non-zero offset?");
3793 if (RD->isDynamicClass())
3796 for (
const auto &
Base : RD->bases())
3800 for (
const FieldDecl *Field : RD->fields())
3855 assert(!FieldTBAAInfo.
Offset &&
3856 "Nonzero offset for an access with no base type!");
3869 FieldTBAAInfo.
Size =
3874 if (
auto *ClassDef = dyn_cast<CXXRecordDecl>(rec)) {
3876 ClassDef->isDynamicClass()) {
3889 assert(!FieldType->
isReferenceType() &&
"union has reference member");
3921 if (field->
hasAttr<AnnotateAttr>())
3983 assert(E->
isTransparent() &&
"non-transparent glvalue init list");
3991 const Expr *Operand) {
3992 if (
auto *ThrowExpr = dyn_cast<CXXThrowExpr>(Operand->
IgnoreParens())) {
4005 "Unexpected conditional operator!");
4015 if (!CondExprBool) std::swap(live, dead);
4040 if (lhs && !lhs->isSimple())
4043 lhsBlock =
Builder.GetInsertBlock();
4053 if (rhs && !rhs->isSimple())
4055 rhsBlock =
Builder.GetInsertBlock();
4060 llvm::PHINode *phi =
Builder.CreatePHI(lhs->getPointer()->getType(),
4062 phi->addIncoming(lhs->getPointer(), lhsBlock);
4063 phi->addIncoming(rhs->getPointer(), rhsBlock);
4064 Address result(phi,
std::min(lhs->getAlignment(), rhs->getAlignment()));
4066 std::max(lhs->getBaseInfo().getAlignmentSource(),
4067 rhs->getBaseInfo().getAlignmentSource());
4069 lhs->getTBAAInfo(), rhs->getTBAAInfo());
4073 assert((lhs || rhs) &&
4074 "both operands of glvalue conditional are throw-expressions?");
4075 return lhs ? *lhs : *rhs;
4090 case CK_ArrayToPointerDecay:
4091 case CK_FunctionToPointerDecay:
4092 case CK_NullToMemberPointer:
4093 case CK_NullToPointer:
4094 case CK_IntegralToPointer:
4095 case CK_PointerToIntegral:
4096 case CK_PointerToBoolean:
4097 case CK_VectorSplat:
4098 case CK_IntegralCast:
4099 case CK_BooleanToSignedIntegral:
4100 case CK_IntegralToBoolean:
4101 case CK_IntegralToFloating:
4102 case CK_FloatingToIntegral:
4103 case CK_FloatingToBoolean:
4104 case CK_FloatingCast:
4105 case CK_FloatingRealToComplex:
4106 case CK_FloatingComplexToReal:
4107 case CK_FloatingComplexToBoolean:
4108 case CK_FloatingComplexCast:
4109 case CK_FloatingComplexToIntegralComplex:
4110 case CK_IntegralRealToComplex:
4111 case CK_IntegralComplexToReal:
4112 case CK_IntegralComplexToBoolean:
4113 case CK_IntegralComplexCast:
4114 case CK_IntegralComplexToFloatingComplex:
4115 case CK_DerivedToBaseMemberPointer:
4116 case CK_BaseToDerivedMemberPointer:
4117 case CK_MemberPointerToBoolean:
4118 case CK_ReinterpretMemberPointer:
4119 case CK_AnyPointerToBlockPointerCast:
4120 case CK_ARCProduceObject:
4121 case CK_ARCConsumeObject:
4122 case CK_ARCReclaimReturnedObject:
4123 case CK_ARCExtendBlockObject:
4124 case CK_CopyAndAutoreleaseBlockObject:
4125 case CK_AddressSpaceConversion:
4126 case CK_IntToOCLSampler:
4130 llvm_unreachable(
"dependent cast kind in IR gen!");
4132 case CK_BuiltinFnToFnPtr:
4133 llvm_unreachable(
"builtin functions are handled elsewhere");
4136 case CK_NonAtomicToAtomic:
4137 case CK_AtomicToNonAtomic:
4143 const auto *DCE = cast<CXXDynamicCastExpr>(E);
4147 case CK_ConstructorConversion:
4148 case CK_UserDefinedConversion:
4149 case CK_CPointerToObjCPointerCast:
4150 case CK_BlockPointerToObjCPointerCast:
4152 case CK_LValueToRValue:
4155 case CK_UncheckedDerivedToBase:
4156 case CK_DerivedToBase: {
4159 auto *DerivedClassDecl = cast<CXXRecordDecl>(DerivedClassTy->
getDecl());
4162 Address This = LV.getAddress();
4177 case CK_BaseToDerived: {
4179 auto *DerivedClassDecl = cast<CXXRecordDecl>(DerivedClassTy->
getDecl());
4193 Derived.getPointer(), E->
getType());
4195 if (
SanOpts.
has(SanitizerKind::CFIDerivedCast))
4203 case CK_LValueBitCast: {
4205 const auto *CE = cast<ExplicitCastExpr>(E);
4212 if (
SanOpts.
has(SanitizerKind::CFIUnrelatedCast))
4220 case CK_ObjCObjectLValueCast: {
4227 case CK_ZeroToOCLQueue:
4228 llvm_unreachable(
"NULL to OpenCL queue lvalue cast is not valid");
4229 case CK_ZeroToOCLEvent:
4230 llvm_unreachable(
"NULL to OpenCL event lvalue cast is not valid");
4233 llvm_unreachable(
"Unhandled lvalue cast kind?");
4245 llvm::DenseMap<const OpaqueValueExpr*,LValue>::iterator
4246 it = OpaqueLValues.find(e);
4248 if (it != OpaqueLValues.end())
4251 assert(e->
isUnique() &&
"LValue for a nonunique OVE hasn't been emitted");
4259 llvm::DenseMap<const OpaqueValueExpr*,RValue>::iterator
4260 it = OpaqueRValues.find(e);
4262 if (it != OpaqueRValues.end())
4265 assert(e->
isUnique() &&
"RValue for a nonunique OVE hasn't been emitted");
4286 llvm_unreachable(
"bad evaluation kind");
4299 if (
const auto *CE = dyn_cast<CXXMemberCallExpr>(E))
4302 if (
const auto *CE = dyn_cast<CUDAKernelCallExpr>(E))
4305 if (
const auto *CE = dyn_cast<CXXOperatorCallExpr>(E))
4307 dyn_cast_or_null<CXXMethodDecl>(CE->getCalleeDecl()))
4344 if (
auto ICE = dyn_cast<ImplicitCastExpr>(E)) {
4345 if (ICE->getCastKind() == CK_FunctionToPointerDecay ||
4346 ICE->getCastKind() == CK_BuiltinFnToFnPtr) {
4351 }
else if (
auto DRE = dyn_cast<DeclRefExpr>(E)) {
4352 if (
auto FD = dyn_cast<FunctionDecl>(DRE->getDecl())) {
4355 }
else if (
auto ME = dyn_cast<MemberExpr>(E)) {
4356 if (
auto FD = dyn_cast<FunctionDecl>(ME->getMemberDecl())) {
4362 }
else if (
auto NTTP = dyn_cast<SubstNonTypeTemplateParmExpr>(E)) {
4366 }
else if (
auto PDE = dyn_cast<CXXPseudoDestructorExpr>(E)) {
4383 CGCallee callee(calleeInfo, calleePtr);
4399 assert(E->
getOpcode() == BO_Assign &&
"unexpected binary l-value");
4434 llvm_unreachable(
"bad evaluation kind");
4445 "Can't have a scalar return unless the return type is a " 4458 &&
"binding l-value to type which needs a temporary");
4503 "Can't have a scalar return unless the return type is a " 4523 unsigned CVRQualifiers) {
4525 Ivar, CVRQualifiers);
4541 ObjectTy = BaseExpr->
getType();
4565 "Call must have function pointer type!");
4569 if (
const FunctionDecl *FD = dyn_cast_or_null<FunctionDecl>(TargetDecl))
4576 if (TargetDecl->hasAttr<AlwaysInlineAttr>() &&
4577 TargetDecl->hasAttr<TargetAttr>())
4582 auto PointeeType = cast<PointerType>(CalleeType)->getPointeeType();
4587 (!TargetDecl || !isa<FunctionDecl>(TargetDecl))) {
4588 if (llvm::Constant *PrefixSig =
4595 llvm::Constant *FTRTTIConst =
4598 llvm::StructType *PrefixStructTy = llvm::StructType::get(
4604 CalleePtr, llvm::PointerType::getUnqual(PrefixStructTy));
4606 Builder.CreateConstGEP2_32(PrefixStructTy, CalleePrefixStruct, 0, 0);
4613 Builder.CreateCondBr(CalleeSigMatch, TypeCheck, Cont);
4617 Builder.CreateConstGEP2_32(PrefixStructTy, CalleePrefixStruct, 0, 1);
4623 Builder.CreateICmpEQ(CalleeRTTI, FTRTTIConst);
4624 llvm::Constant *StaticData[] = {
4628 EmitCheck(std::make_pair(CalleeRTTIMatch, SanitizerKind::Function),
4629 SanitizerHandler::FunctionTypeMismatch, StaticData, CalleePtr);
4636 const auto *FnType = cast<FunctionType>(PointeeType);
4641 (!TargetDecl || !isa<FunctionDecl>(TargetDecl))) {
4656 CGM.
getIntrinsic(llvm::Intrinsic::type_test), {CastedCallee, TypeId});
4659 llvm::Constant *StaticData[] = {
4666 CastedCallee, StaticData);
4668 EmitCheck(std::make_pair(TypeTest, SanitizerKind::CFIICall),
4669 SanitizerHandler::CFICheckFail, StaticData,
4670 {CastedCallee, llvm::UndefValue::get(
IntPtrTy)});
4686 if (
auto *OCE = dyn_cast<CXXOperatorCallExpr>(E)) {
4687 if (OCE->isAssignmentOp())
4690 switch (OCE->getOperator()) {
4692 case OO_GreaterGreater:
4709 Args, FnType, Chain);
4731 if (isa<FunctionNoProtoType>(FnType) || Chain) {
4733 CalleeTy = CalleeTy->getPointerTo();
4763 return MakeAddrLValue(MemberAddr, MPT->getPointeeType(), BaseInfo, TBAAInfo);
4780 llvm_unreachable(
"bad evaluation kind");
4784 assert(Val->getType()->isFPOrFPVectorTy());
4785 if (Accuracy == 0.0 || !isa<llvm::Instruction>(Val))
4789 llvm::MDNode *
Node = MDHelper.createFPMath(Accuracy);
4791 cast<llvm::Instruction>(Val)->setMetadata(llvm::LLVMContext::MD_fpmath, Node);
4795 struct LValueOrRValue {
4809 LValueOrRValue result;
4813 const Expr *semantic = *i;
4817 if (
const auto *ov = dyn_cast<OpaqueValueExpr>(semantic)) {
4819 if (ov->isUnique()) {
4820 assert(ov != resultExpr &&
4821 "A unique OVE cannot be used as the result expression");
4829 if (ov == resultExpr && ov->
isRValue() && !forLValue &&
4834 opaqueData = OVMA::bind(CGF, ov, LV);
4839 opaqueData = OVMA::bind(CGF, ov, ov->getSourceExpr());
4842 if (ov == resultExpr) {
4850 opaques.push_back(opaqueData);
4854 }
else if (semantic == resultExpr) {
4867 for (
unsigned i = 0, e = opaques.size(); i != e; ++i)
4868 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.
bool isSignedOverflowDefined() const
no exception specification
bool EvaluateAsRValue(EvalResult &Result, const ASTContext &Ctx) const
EvaluateAsRValue - Return true if this is a constant which we can fold to an rvalue using any crazy t...
LValue EmitComplexCompoundAssignmentLValue(const CompoundAssignOperator *E)
PointerType - C99 6.7.5.1 - Pointer Declarators.
QualType getPointeeType() 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
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...
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...
const Decl * getCalleeDecl() const
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.
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)
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...
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 GetAddrOfBlockDecl(const VarDecl *var, bool ByRef)
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
RValue EmitBuiltinExpr(const FunctionDecl *FD, unsigned BuiltinID, const CallExpr *E, ReturnValueSlot ReturnValue)
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)
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 * 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...
Expr - 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...
const Expr * getCallee() const
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.
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())
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)
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="")
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)
void setVolatile(bool flag)
redecl_range redecls() const
Returns an iterator range for all the redeclarations of the same decl.
unsigned getColumn() const
Return the presumed column number of this location.
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 ...
SourceLocation getExprLoc() const LLVM_READONLY
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.
SourceLocation getLocStart() const LLVM_READONLY
QualType getElementType() 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.
StringLiteral * getFunctionName()
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)
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)
IdentType getIdentType() const
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)
void enterFullExpression(const ExprWithCleanups *E)
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()
FunctionDecl * getDirectCallee()
If the callee is a FunctionDecl, return it. Otherwise return 0.
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)
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()'.
SourceLocation getLocStart() const LLVM_READONLY
enum clang::SubobjectAdjustment::@36 Kind
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
static StringRef getIdentTypeName(IdentType IT)
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)
SourceLocation getExprLoc() const LLVM_READONLY
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)
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.
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)
Attr - This represents one attribute.
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
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 ...