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;
67 bool CastToDefaultAddrSpace) {
77 llvm::IRBuilderBase::InsertPointGuard IPG(
Builder);
85 Ty->getPointerTo(DestAddrSpace),
true);
98 return Builder.CreateAlloca(Ty, ArraySize, Name);
115 assert(isa<llvm::AllocaInst>(Var.
getPointer()));
128 bool CastToDefaultAddrSpace) {
131 CastToDefaultAddrSpace);
136 bool CastToDefaultAddrSpace) {
138 CastToDefaultAddrSpace);
182 if (!ignoreResult && aggSlot.
isIgnored())
187 llvm_unreachable(
"bad evaluation kind");
228 llvm_unreachable(
"bad evaluation kind");
269 VD && isa<VarDecl>(VD) && VD->
hasAttr<ObjCPreciseLifetimeAttr>();
290 llvm_unreachable(
"temporary cannot have dynamic storage duration");
292 llvm_unreachable(
"unknown storage duration");
300 auto *ClassDecl = cast<CXXRecordDecl>(RT->getDecl());
301 if (!ClassDecl->hasTrivialDestructor())
302 ReferenceTemporaryDtor = ClassDecl->getDestructor();
305 if (!ReferenceTemporaryDtor)
312 llvm::Constant *CleanupFn;
313 llvm::Constant *CleanupArg;
316 ReferenceTemporary, E->
getType(),
319 CleanupArg = llvm::Constant::getNullValue(CGF.
Int8PtrTy);
323 CleanupArg = cast<llvm::Constant>(ReferenceTemporary.
getPointer());
338 ReferenceTemporary, E->
getType(),
344 llvm_unreachable(
"temporary cannot have dynamic storage duration");
365 auto AS = AddrSpace.getValue();
366 auto *GV =
new llvm::GlobalVariable(
368 llvm::GlobalValue::PrivateLinkage, Init,
".ref.tmp",
nullptr,
369 llvm::GlobalValue::NotThreadLocal,
372 GV->setAlignment(alignment.getQuantity());
373 llvm::Constant *C = GV;
375 C = TCG.performAddrSpaceCast(
377 GV->getValueType()->getPointerTo(
390 llvm_unreachable(
"temporary can't have dynamic storage duration");
392 llvm_unreachable(
"unknown storage duration");
405 if (
auto *Var = dyn_cast<llvm::GlobalVariable>(Object.
getPointer())) {
406 Object =
Address(llvm::ConstantExpr::getBitCast(Var,
417 if (Var->hasInitializer())
426 default: llvm_unreachable(
"expected scalar or aggregate expression");
448 for (
const auto &Ignored : CommaLHSs)
451 if (
const auto *opaque = dyn_cast<OpaqueValueExpr>(E)) {
452 if (opaque->getType()->isRecordType()) {
453 assert(Adjustments.empty());
460 if (
auto *Var = dyn_cast<llvm::GlobalVariable>(
462 Object =
Address(llvm::ConstantExpr::getBitCast(
469 if (!Var->hasInitializer()) {
498 for (
unsigned I = Adjustments.size(); I != 0; --I) {
500 switch (Adjustment.
Kind) {
512 assert(LV.isSimple() &&
513 "materialized temporary field is not a simple lvalue");
514 Object = LV.getAddress();
554 const llvm::Constant *Elts) {
555 return cast<llvm::ConstantInt>(Elts->getAggregateElement(Idx))
562 llvm::Value *KMul = Builder.getInt64(0x9ddfea08eb382d69ULL);
564 llvm::Value *A0 = Builder.CreateMul(Builder.CreateXor(Low, High), KMul);
565 llvm::Value *A1 = Builder.CreateXor(Builder.CreateLShr(A0, K47), A0);
566 llvm::Value *B0 = Builder.CreateMul(Builder.CreateXor(High, A1), KMul);
567 llvm::Value *B1 = Builder.CreateXor(Builder.CreateLShr(B0, K47), B0);
568 return Builder.CreateMul(B1, KMul);
601 if (Ptr->getType()->getPointerAddressSpace())
612 llvm::BasicBlock *Done =
nullptr;
618 dyn_cast<llvm::AllocaInst>(Ptr->stripPointerCastsNoFollowAliases());
622 bool IsGuaranteedNonNull =
623 SkippedChecks.
has(SanitizerKind::Null) || PtrToAlloca;
625 if ((
SanOpts.
has(SanitizerKind::Null) || AllowNullPointers) &&
626 !IsGuaranteedNonNull) {
628 IsNonNull =
Builder.CreateIsNotNull(Ptr);
632 IsGuaranteedNonNull = IsNonNull == True;
635 if (!IsGuaranteedNonNull) {
636 if (AllowNullPointers) {
641 Builder.CreateCondBr(IsNonNull, Rest, Done);
644 Checks.push_back(std::make_pair(IsNonNull, SanitizerKind::Null));
650 !SkippedChecks.
has(SanitizerKind::ObjectSize) &&
664 Builder.CreateCall(F, {CastAddr, Min, NullIsUnknown}),
665 llvm::ConstantInt::get(
IntPtrTy, Size));
666 Checks.push_back(std::make_pair(LargeEnough, SanitizerKind::ObjectSize));
669 uint64_t AlignVal = 0;
673 !SkippedChecks.
has(SanitizerKind::Alignment)) {
680 (!PtrToAlloca || PtrToAlloca->getAlignment() < AlignVal)) {
683 PtrAsInt, llvm::ConstantInt::get(
IntPtrTy, AlignVal - 1));
687 Checks.push_back(std::make_pair(Aligned, SanitizerKind::Alignment));
691 if (Checks.size() > 0) {
694 assert(!AlignVal || (uint64_t)1 << llvm::Log2_64(AlignVal) == AlignVal);
695 llvm::Constant *StaticData[] = {
697 llvm::ConstantInt::get(
Int8Ty, AlignVal ? llvm::Log2_64(AlignVal) : 1),
698 llvm::ConstantInt::get(
Int8Ty, TCK)};
699 EmitCheck(Checks, SanitizerHandler::TypeMismatch, StaticData,
700 PtrAsInt ? PtrAsInt : Ptr);
715 if (!IsGuaranteedNonNull) {
717 IsNonNull =
Builder.CreateIsNotNull(Ptr);
721 Builder.CreateCondBr(IsNonNull, VptrNotNull, Done);
731 llvm::raw_svector_ostream Out(MangledName);
737 SanitizerKind::Vptr, Out.str())) {
738 llvm::hash_code TypeHash = hash_value(Out.str());
751 const int CacheSize = 128;
754 "__ubsan_vptr_type_cache");
768 llvm::Constant *StaticData[] = {
772 llvm::ConstantInt::get(
Int8Ty, TCK)
775 EmitCheck(std::make_pair(EqualHash, SanitizerKind::Vptr),
776 SanitizerHandler::DynamicTypeCacheMiss, StaticData,
793 if (
const auto *CAT = dyn_cast<ConstantArrayType>(AT)) {
794 if (CAT->getSize().ugt(1))
796 }
else if (!isa<IncompleteArrayType>(AT))
802 if (
const auto *ME = dyn_cast<MemberExpr>(E)) {
805 if (
const auto *FD = dyn_cast<FieldDecl>(ME->getMemberDecl())) {
808 return ++FI == FD->getParent()->field_end();
810 }
else if (
const auto *IRE = dyn_cast<ObjCIvarRefExpr>(E)) {
811 return IRE->getDecl()->getNextIvar() ==
nullptr;
828 auto *ParamDecl = dyn_cast<
ParmVarDecl>(ArrayDeclRef->getDecl());
832 auto *POSAttr = ParamDecl->
getAttr<PassObjectSizeAttr>();
837 int POSType = POSAttr->getType();
838 if (POSType != 0 && POSType != 1)
842 auto PassedSizeIt = SizeArguments.find(ParamDecl);
843 if (PassedSizeIt == SizeArguments.end())
847 assert(LocalDeclMap.count(PassedSizeDecl) &&
"Passed size not loadable");
848 Address AddrOfSize = LocalDeclMap.find(PassedSizeDecl)->second;
852 llvm::ConstantInt::get(SizeInBytes->getType(), EltSize);
853 return Builder.CreateUDiv(SizeInBytes, SizeOfElement);
863 return CGF.
Builder.getInt32(VT->getNumElements());
868 if (
const auto *CE = dyn_cast<CastExpr>(Base)) {
869 if (CE->getCastKind() == CK_ArrayToPointerDecay &&
871 IndexedType = CE->getSubExpr()->getType();
873 if (
const auto *CAT = dyn_cast<ConstantArrayType>(AT))
874 return CGF.
Builder.getInt(CAT->getSize());
875 else if (
const auto *VAT = dyn_cast<VariableArrayType>(AT))
893 assert(
SanOpts.
has(SanitizerKind::ArrayBounds) &&
894 "should not be called unless adding bounds checks");
906 llvm::Constant *StaticData[] = {
912 :
Builder.CreateICmpULE(IndexVal, BoundVal);
913 EmitCheck(std::make_pair(Check, SanitizerKind::ArrayBounds),
914 SanitizerHandler::OutOfBounds, StaticData, Index);
920 bool isInc,
bool isPre) {
924 if (isa<llvm::IntegerType>(InVal.first->getType())) {
925 uint64_t AmountVal = isInc ? 1 : -1;
926 NextVal = llvm::ConstantInt::get(InVal.first->getType(), AmountVal,
true);
929 NextVal =
Builder.CreateAdd(InVal.first, NextVal, isInc ?
"inc" :
"dec");
932 llvm::APFloat FVal(
getContext().getFloatTypeSemantics(ElemTy), 1);
938 NextVal =
Builder.CreateFAdd(InVal.first, NextVal, isInc ?
"inc" :
"dec");
948 return isPre ? IncVal : InVal;
958 DI->EmitExplicitCastType(E->
getType());
976 if (
const CastExpr *CE = dyn_cast<CastExpr>(E)) {
977 if (
const auto *ECE = dyn_cast<ExplicitCastExpr>(CE))
980 switch (CE->getCastKind()) {
984 case CK_AddressSpaceConversion:
985 if (
auto PtrTy = CE->getSubExpr()->getType()->getAs<
PointerType>()) {
986 if (PtrTy->getPointeeType()->isVoidType())
994 if (BaseInfo) *BaseInfo = InnerBaseInfo;
995 if (TBAAInfo) *TBAAInfo = InnerTBAAInfo;
997 if (isa<ExplicitCastExpr>(CE)) {
1001 &TargetTypeBaseInfo,
1002 &TargetTypeTBAAInfo);
1005 TargetTypeTBAAInfo);
1015 if (
SanOpts.
has(SanitizerKind::CFIUnrelatedCast) &&
1016 CE->getCastKind() == CK_BitCast) {
1023 return CE->getCastKind() != CK_AddressSpaceConversion
1031 case CK_ArrayToPointerDecay:
1035 case CK_UncheckedDerivedToBase:
1036 case CK_DerivedToBase: {
1039 auto Derived = CE->getSubExpr()->
getType()->getPointeeCXXRecordDecl();
1041 CE->path_begin(), CE->path_end(),
1055 if (UO->getOpcode() == UO_AddrOf) {
1094 llvm_unreachable(
"bad evaluation kind");
1113 while (!isa<CXXThisExpr>(Base)) {
1115 if (isa<CXXDynamicCastExpr>(Base))
1118 if (
const auto *CE = dyn_cast<CastExpr>(Base)) {
1119 Base = CE->getSubExpr();
1120 }
else if (
const auto *PE = dyn_cast<ParenExpr>(Base)) {
1121 Base = PE->getSubExpr();
1122 }
else if (
const auto *UO = dyn_cast<UnaryOperator>(Base)) {
1123 if (UO->getOpcode() == UO_Extension)
1124 Base = UO->getSubExpr();
1136 if (
SanOpts.
has(SanitizerKind::ArrayBounds) && isa<ArraySubscriptExpr>(E))
1142 if (
const auto *ME = dyn_cast<MemberExpr>(E)) {
1145 SkippedChecks.
set(SanitizerKind::Alignment,
true);
1146 if (IsBaseCXXThis || isa<DeclRefExpr>(ME->getBase()))
1147 SkippedChecks.
set(SanitizerKind::Null,
true);
1175 case Expr::ObjCPropertyRefExprClass:
1176 llvm_unreachable(
"cannot emit a property reference directly");
1178 case Expr::ObjCSelectorExprClass:
1180 case Expr::ObjCIsaExprClass:
1182 case Expr::BinaryOperatorClass:
1184 case Expr::CompoundAssignOperatorClass: {
1187 Ty = AT->getValueType();
1192 case Expr::CallExprClass:
1193 case Expr::CXXMemberCallExprClass:
1194 case Expr::CXXOperatorCallExprClass:
1195 case Expr::UserDefinedLiteralClass:
1197 case Expr::VAArgExprClass:
1199 case Expr::DeclRefExprClass:
1201 case Expr::ParenExprClass:
1202 return EmitLValue(cast<ParenExpr>(E)->getSubExpr());
1203 case Expr::GenericSelectionExprClass:
1204 return EmitLValue(cast<GenericSelectionExpr>(E)->getResultExpr());
1205 case Expr::PredefinedExprClass:
1207 case Expr::StringLiteralClass:
1209 case Expr::ObjCEncodeExprClass:
1211 case Expr::PseudoObjectExprClass:
1213 case Expr::InitListExprClass:
1215 case Expr::CXXTemporaryObjectExprClass:
1216 case Expr::CXXConstructExprClass:
1218 case Expr::CXXBindTemporaryExprClass:
1220 case Expr::CXXUuidofExprClass:
1222 case Expr::LambdaExprClass:
1225 case Expr::ExprWithCleanupsClass: {
1226 const auto *cleanups = cast<ExprWithCleanups>(E);
1243 case Expr::CXXDefaultArgExprClass:
1244 return EmitLValue(cast<CXXDefaultArgExpr>(E)->getExpr());
1245 case Expr::CXXDefaultInitExprClass: {
1247 return EmitLValue(cast<CXXDefaultInitExpr>(E)->getExpr());
1249 case Expr::CXXTypeidExprClass:
1252 case Expr::ObjCMessageExprClass:
1254 case Expr::ObjCIvarRefExprClass:
1256 case Expr::StmtExprClass:
1258 case Expr::UnaryOperatorClass:
1260 case Expr::ArraySubscriptExprClass:
1262 case Expr::OMPArraySectionExprClass:
1264 case Expr::ExtVectorElementExprClass:
1266 case Expr::MemberExprClass:
1268 case Expr::CompoundLiteralExprClass:
1270 case Expr::ConditionalOperatorClass:
1272 case Expr::BinaryConditionalOperatorClass:
1274 case Expr::ChooseExprClass:
1275 return EmitLValue(cast<ChooseExpr>(E)->getChosenSubExpr());
1276 case Expr::OpaqueValueExprClass:
1278 case Expr::SubstNonTypeTemplateParmExprClass:
1279 return EmitLValue(cast<SubstNonTypeTemplateParmExpr>(E)->getReplacement());
1280 case Expr::ImplicitCastExprClass:
1281 case Expr::CStyleCastExprClass:
1282 case Expr::CXXFunctionalCastExprClass:
1283 case Expr::CXXStaticCastExprClass:
1284 case Expr::CXXDynamicCastExprClass:
1285 case Expr::CXXReinterpretCastExprClass:
1286 case Expr::CXXConstCastExprClass:
1287 case Expr::ObjCBridgedCastExprClass:
1290 case Expr::MaterializeTemporaryExprClass:
1293 case Expr::CoawaitExprClass:
1295 case Expr::CoyieldExprClass:
1308 if (!qs.hasConst() || qs.hasVolatile())
return false;
1312 if (
const auto *RT = dyn_cast<RecordType>(type))
1313 if (
const auto *RD = dyn_cast<CXXRecordDecl>(RT->getDecl()))
1314 if (RD->hasMutableFields() || !RD->isTrivial())
1335 if (
const auto *ref = dyn_cast<ReferenceType>(type)) {
1356 if (isa<ParmVarDecl>(value)) {
1358 }
else if (
auto *var = dyn_cast<VarDecl>(value)) {
1360 }
else if (isa<EnumConstantDecl>(value)) {
1368 bool resultIsReference;
1374 resultIsReference =
false;
1375 resultType = refExpr->
getType();
1380 resultIsReference =
true;
1381 resultType = value->
getType();
1394 result.
Val, resultType);
1398 if (isa<VarDecl>(value)) {
1402 assert(isa<EnumConstantDecl>(value));
1407 if (resultIsReference)
1444 return ET->getDecl()->getIntegerType()->isBooleanType();
1453 llvm::APInt &Min, llvm::APInt &
End,
1454 bool StrictEnums,
bool IsBool) {
1456 bool IsRegularCPlusPlusEnum = CGF.
getLangOpts().CPlusPlus && StrictEnums &&
1458 if (!IsBool && !IsRegularCPlusPlusEnum)
1467 unsigned Bitwidth = LTy->getScalarSizeInBits();
1471 if (NumNegativeBits) {
1472 unsigned NumBits =
std::max(NumNegativeBits, NumPositiveBits + 1);
1473 assert(NumBits <= Bitwidth);
1474 End = llvm::APInt(Bitwidth, 1) << (NumBits - 1);
1477 assert(NumPositiveBits <= Bitwidth);
1478 End = llvm::APInt(Bitwidth, 1) << NumPositiveBits;
1479 Min = llvm::APInt(Bitwidth, 0);
1485 llvm::MDNode *CodeGenFunction::getRangeForLoadFromType(
QualType Ty) {
1486 llvm::APInt Min,
End;
1492 return MDHelper.createRange(Min, End);
1497 bool HasBoolCheck =
SanOpts.
has(SanitizerKind::Bool);
1498 bool HasEnumCheck =
SanOpts.
has(SanitizerKind::Enum);
1499 if (!HasBoolCheck && !HasEnumCheck)
1504 bool NeedsBoolCheck = HasBoolCheck && IsBool;
1505 bool NeedsEnumCheck = HasEnumCheck && Ty->
getAs<
EnumType>();
1506 if (!NeedsBoolCheck && !NeedsEnumCheck)
1513 cast<llvm::IntegerType>(Value->getType())->getBitWidth() == 1)
1516 llvm::APInt Min,
End;
1525 Check =
Builder.CreateICmpULE(Value, llvm::ConstantInt::get(Ctx, End));
1528 Builder.CreateICmpSLE(Value, llvm::ConstantInt::get(Ctx, End));
1530 Builder.CreateICmpSGE(Value, llvm::ConstantInt::get(Ctx, Min));
1531 Check =
Builder.CreateAnd(Upper, Lower);
1536 NeedsEnumCheck ? SanitizerKind::Enum : SanitizerKind::Bool;
1537 EmitCheck(std::make_pair(Check, Kind), SanitizerHandler::LoadInvalidValue,
1547 bool isNontemporal) {
1553 const auto *VTy = cast<llvm::VectorType>(EltTy);
1556 if (VTy->getNumElements() == 3) {
1559 llvm::VectorType *vec4Ty =
1560 llvm::VectorType::get(VTy->getElementType(), 4);
1566 V =
Builder.CreateShuffleVector(V, llvm::UndefValue::get(vec4Ty),
1567 {0, 1, 2},
"extractVec");
1581 if (isNontemporal) {
1582 llvm::MDNode *
Node = llvm::MDNode::get(
1583 Load->getContext(), llvm::ConstantAsMetadata::get(
Builder.getInt32(1)));
1593 if (llvm::MDNode *RangeInfo = getRangeForLoadFromType(Ty))
1594 Load->setMetadata(llvm::LLVMContext::MD_range, RangeInfo);
1604 if (Value->getType()->isIntegerTy(1))
1607 "wrong value rep of bool");
1617 "wrong value rep of bool");
1618 return Builder.CreateTrunc(Value,
Builder.getInt1Ty(),
"tobool");
1628 bool isInit,
bool isNontemporal) {
1633 auto *VecTy = dyn_cast<llvm::VectorType>(SrcTy);
1635 if (VecTy && VecTy->getNumElements() == 3) {
1637 llvm::Constant *Mask[] = {
Builder.getInt32(0),
Builder.getInt32(1),
1639 llvm::UndefValue::get(
Builder.getInt32Ty())};
1640 llvm::Value *MaskV = llvm::ConstantVector::get(Mask);
1641 Value =
Builder.CreateShuffleVector(Value, llvm::UndefValue::get(VecTy),
1642 MaskV,
"extractVec");
1643 SrcTy = llvm::VectorType::get(VecTy->getElementType(), 4);
1662 if (isNontemporal) {
1663 llvm::MDNode *
Node =
1664 llvm::MDNode::get(Store->getContext(),
1665 llvm::ConstantAsMetadata::get(
Builder.getInt32(1)));
1724 assert(LV.
isBitField() &&
"Unknown LValue type!");
1742 Val =
Builder.CreateShl(Val, HighBits,
"bf.shl");
1743 if (Info.
Offset + HighBits)
1744 Val =
Builder.CreateAShr(Val, Info.
Offset + HighBits,
"bf.ashr");
1779 for (
unsigned i = 0; i != NumResultElts; ++i)
1782 llvm::Value *MaskV = llvm::ConstantVector::get(Mask);
1783 Vec =
Builder.CreateShuffleVector(Vec, llvm::UndefValue::get(Vec->getType()),
1795 Address CastToPointerElement =
1797 "conv.ptr.element");
1807 return VectorBasePtrPlusIx;
1813 "Bad type for register variable");
1814 llvm::MDNode *RegName = cast<llvm::MDNode>(
1815 cast<llvm::MetadataAsValue>(LV.
getGlobalReg())->getMetadata());
1820 if (OrigTy->isPointerTy())
1826 F, llvm::MetadataAsValue::get(Ty->getContext(), RegName));
1827 if (OrigTy->isPointerTy())
1828 Call =
Builder.CreateIntToPtr(Call, OrigTy);
1858 assert(Dst.
isBitField() &&
"Unknown LValue type");
1866 llvm_unreachable(
"present but none");
1913 RHS =
Builder.CreatePtrToInt(RHS, ResultType,
"sub.ptr.rhs.cast");
1916 "sub.ptr.lhs.cast");
1929 assert(Src.
isScalar() &&
"Can't emit an agg store with this method");
1943 SrcVal =
Builder.CreateIntCast(SrcVal, Ptr.getElementType(),
1956 SrcVal =
Builder.CreateAnd(SrcVal,
1972 SrcVal =
Builder.CreateOr(Val, SrcVal,
"bf.set");
1974 assert(Info.
Offset == 0);
1989 ResultVal =
Builder.CreateShl(ResultVal, HighBits,
"bf.result.shl");
1990 ResultVal =
Builder.CreateAShr(ResultVal, HighBits,
"bf.result.ashr");
2011 unsigned NumSrcElts = VTy->getNumElements();
2012 unsigned NumDstElts = Vec->getType()->getVectorNumElements();
2013 if (NumDstElts == NumSrcElts) {
2018 for (
unsigned i = 0; i != NumSrcElts; ++i)
2021 llvm::Value *MaskV = llvm::ConstantVector::get(Mask);
2022 Vec =
Builder.CreateShuffleVector(SrcVal,
2023 llvm::UndefValue::get(Vec->getType()),
2025 }
else if (NumDstElts > NumSrcElts) {
2031 for (
unsigned i = 0; i != NumSrcElts; ++i)
2032 ExtMask.push_back(
Builder.getInt32(i));
2033 ExtMask.resize(NumDstElts, llvm::UndefValue::get(
Int32Ty));
2034 llvm::Value *ExtMaskV = llvm::ConstantVector::get(ExtMask);
2036 Builder.CreateShuffleVector(SrcVal,
2037 llvm::UndefValue::get(SrcVal->getType()),
2041 for (
unsigned i = 0; i != NumDstElts; ++i)
2042 Mask.push_back(
Builder.getInt32(i));
2051 for (
unsigned i = 0; i != NumSrcElts; ++i)
2053 llvm::Value *MaskV = llvm::ConstantVector::get(Mask);
2054 Vec =
Builder.CreateShuffleVector(Vec, ExtSrcVal, MaskV);
2057 llvm_unreachable(
"unexpected shorten vector length");
2063 Vec =
Builder.CreateInsertElement(Vec, SrcVal, Elt);
2073 "Bad type for register variable");
2074 llvm::MDNode *RegName = cast<llvm::MDNode>(
2075 cast<llvm::MetadataAsValue>(Dst.
getGlobalReg())->getMetadata());
2076 assert(RegName &&
"Register LValue is not metadata");
2081 if (OrigTy->isPointerTy())
2087 if (OrigTy->isPointerTy())
2088 Value =
Builder.CreatePtrToInt(Value, Ty);
2090 F, {llvm::MetadataAsValue::get(Ty->getContext(), RegName), Value});
2098 bool IsMemberAccess=
false) {
2102 if (isa<ObjCIvarRefExpr>(E)) {
2115 auto *Exp = cast<ObjCIvarRefExpr>(
const_cast<Expr *
>(E));
2121 if (
const auto *Exp = dyn_cast<DeclRefExpr>(E)) {
2122 if (
const auto *VD = dyn_cast<VarDecl>(Exp->getDecl())) {
2123 if (VD->hasGlobalStorage()) {
2132 if (
const auto *Exp = dyn_cast<UnaryOperator>(E)) {
2137 if (
const auto *Exp = dyn_cast<ParenExpr>(E)) {
2151 if (
const auto *Exp = dyn_cast<GenericSelectionExpr>(E)) {
2156 if (
const auto *Exp = dyn_cast<ImplicitCastExpr>(E)) {
2161 if (
const auto *Exp = dyn_cast<CStyleCastExpr>(E)) {
2166 if (
const auto *Exp = dyn_cast<ObjCBridgedCastExpr>(E)) {
2171 if (
const auto *Exp = dyn_cast<ArraySubscriptExpr>(E)) {
2184 if (
const auto *Exp = dyn_cast<MemberExpr>(E)) {
2196 StringRef Name = StringRef()) {
2197 unsigned AS = cast<llvm::PointerType>(V->getType())->getAddressSpace();
2218 PointeeBaseInfo, PointeeTBAAInfo,
2229 PointeeBaseInfo, PointeeTBAAInfo);
2267 VD->
hasAttr<OMPThreadPrivateDeclAttr>()) {
2281 if (FD->
hasAttr<WeakRefAttr>()) {
2296 V = llvm::ConstantExpr::getBitCast(V,
2326 AsmLabelAttr *Asm = VD->
getAttr<AsmLabelAttr>();
2327 assert(Asm->getLabel().size() < 64-Name.size() &&
2328 "Register name too big");
2329 Name.append(Asm->getLabel());
2330 llvm::NamedMDNode *M =
2331 CGM.
getModule().getOrInsertNamedMetadata(Name);
2332 if (M->getNumOperands() == 0) {
2335 llvm::Metadata *Ops[] = {Str};
2342 llvm::MetadataAsValue::get(CGM.
getLLVMContext(), M->getOperand(0));
2350 if (
const auto *VD = dyn_cast<VarDecl>(ND)) {
2353 VD->hasAttr<AsmLabelAttr>() && !VD->isLocalVarDecl())
2358 const Expr *Init = VD->getAnyInitializer(VD);
2360 VD->isUsableInConstantExpressions(
getContext()) &&
2361 VD->checkInitIsICE() &&
2365 (LocalDeclMap.count(VD->getCanonicalDecl()) ||
2369 llvm::Constant *Val =
2371 *VD->evaluateValue(),
2373 assert(Val &&
"failed to emit reference constant expression");
2386 VD = VD->getCanonicalDecl();
2390 auto I = LocalDeclMap.find(VD);
2391 if (I != LocalDeclMap.end()) {
2392 if (VD->getType()->isReferenceType())
2415 assert((ND->
isUsed(
false) || !isa<VarDecl>(ND) ||
2417 "Should not use decl without marking it used!");
2419 if (ND->
hasAttr<WeakRefAttr>()) {
2420 const auto *VD = cast<ValueDecl>(ND);
2425 if (
const auto *VD = dyn_cast<VarDecl>(ND)) {
2427 if (VD->hasLinkage() || VD->isStaticDataMember())
2433 auto iter = LocalDeclMap.find(VD);
2434 if (iter != LocalDeclMap.end()) {
2435 addr = iter->second;
2439 }
else if (VD->isStaticLocal()) {
2446 llvm_unreachable(
"DeclRefExpr for Decl not entered in LocalDeclMap?");
2452 VD->hasAttr<OMPThreadPrivateDeclAttr>()) {
2459 bool isBlockByref = VD->hasAttr<BlocksAttr>();
2469 bool isLocalStorage = VD->hasLocalStorage();
2471 bool NonGCable = isLocalStorage &&
2472 !VD->getType()->isReferenceType() &&
2479 bool isImpreciseLifetime =
2480 (isLocalStorage && !VD->hasAttr<ObjCPreciseLifetimeAttr>());
2481 if (isImpreciseLifetime)
2487 if (
const auto *FD = dyn_cast<FunctionDecl>(ND))
2493 if (
const auto *BD = dyn_cast<BindingDecl>(ND))
2496 llvm_unreachable(
"Unhandled DeclRefExpr");
2506 default: llvm_unreachable(
"Unknown unary operator lvalue!");
2509 assert(!T.
isNull() &&
"CodeGenFunction::EmitUnaryOpLValue: Illegal type");
2531 assert(LV.
isSimple() &&
"real/imag on non-ordinary l-value");
2555 bool isInc = E->
getOpcode() == UO_PreInc;
2578 assert(SL !=
nullptr &&
"No StringLiteral name in PredefinedExpr");
2579 StringRef FnName =
CurFn->getName();
2580 if (FnName.startswith(
"\01"))
2581 FnName = FnName.substr(1);
2582 StringRef NameItems[] = {
2584 std::string GVName = llvm::join(NameItems, NameItems + 2,
".");
2585 if (
auto *BD = dyn_cast<BlockDecl>(
CurCodeDecl)) {
2586 std::string Name = SL->getString();
2587 if (!Name.empty()) {
2588 unsigned Discriminator =
2591 Name +=
"_" + Twine(Discriminator + 1).str();
2617 uint16_t TypeKind = -1;
2634 StringRef(), StringRef(), None, Buffer,
2637 llvm::Constant *Components[] = {
2641 llvm::Constant *Descriptor = llvm::ConstantStruct::getAnon(Components);
2643 auto *GV =
new llvm::GlobalVariable(
2645 true, llvm::GlobalVariable::PrivateLinkage, Descriptor);
2646 GV->setUnnamedAddr(llvm::GlobalValue::UnnamedAddr::Global);
2658 if (V->getType() == TargetTy)
2663 if (V->getType()->isFloatingPointTy()) {
2664 unsigned Bits = V->getType()->getPrimitiveSizeInBits();
2665 if (Bits <= TargetTy->getIntegerBitWidth())
2671 if (V->getType()->isIntegerTy() &&
2672 V->getType()->getIntegerBitWidth() <= TargetTy->getIntegerBitWidth())
2673 return Builder.CreateZExt(V, TargetTy);
2676 if (!V->getType()->isPointerTy()) {
2681 return Builder.CreatePtrToInt(V, TargetTy);
2701 int PathComponentsToStrip =
2703 if (PathComponentsToStrip < 0) {
2704 assert(PathComponentsToStrip !=
INT_MIN);
2705 int PathComponentsToKeep = -PathComponentsToStrip;
2706 auto I = llvm::sys::path::rbegin(FilenameString);
2707 auto E = llvm::sys::path::rend(FilenameString);
2708 while (I != E && --PathComponentsToKeep)
2711 FilenameString = FilenameString.substr(I - E);
2712 }
else if (PathComponentsToStrip > 0) {
2713 auto I = llvm::sys::path::begin(FilenameString);
2714 auto E = llvm::sys::path::end(FilenameString);
2715 while (I != E && PathComponentsToStrip--)
2720 FilenameString.substr(I - llvm::sys::path::begin(FilenameString));
2722 FilenameString = llvm::sys::path::filename(FilenameString);
2727 cast<llvm::GlobalVariable>(FilenameGV.getPointer()));
2728 Filename = FilenameGV.getPointer();
2732 Filename = llvm::Constant::getNullValue(
Int8PtrTy);
2739 return llvm::ConstantStruct::getAnon(Data);
2756 assert(llvm::countPopulation(Kind) == 1);
2758 case SanitizerKind::Vptr:
2759 return CheckRecoverableKind::AlwaysRecoverable;
2760 case SanitizerKind::Return:
2761 case SanitizerKind::Unreachable:
2764 return CheckRecoverableKind::Recoverable;
2769 struct SanitizerHandlerInfo {
2770 char const *
const Name;
2776 #define SANITIZER_CHECK(Enum, Name, Version) {#Name, Version}, 2778 #undef SANITIZER_CHECK 2782 llvm::FunctionType *FnType,
2786 llvm::BasicBlock *ContBB) {
2788 bool NeedsAbortSuffix =
2791 const SanitizerHandlerInfo &CheckInfo = SanitizerHandlers[CheckHandler];
2792 const StringRef CheckName = CheckInfo.Name;
2793 std::string FnName =
"__ubsan_handle_" + CheckName.str();
2794 if (CheckInfo.Version && !MinimalRuntime)
2795 FnName +=
"_v" + llvm::utostr(CheckInfo.Version);
2797 FnName +=
"_minimal";
2798 if (NeedsAbortSuffix)
2801 !IsFatal || RecoverKind == CheckRecoverableKind::AlwaysRecoverable;
2803 llvm::AttrBuilder B;
2805 B.addAttribute(llvm::Attribute::NoReturn)
2806 .addAttribute(llvm::Attribute::NoUnwind);
2808 B.addAttribute(llvm::Attribute::UWTable);
2813 llvm::AttributeList::FunctionIndex, B),
2817 HandlerCall->setDoesNotReturn();
2818 CGF.
Builder.CreateUnreachable();
2825 ArrayRef<std::pair<llvm::Value *, SanitizerMask>> Checked,
2829 assert(Checked.size() > 0);
2830 assert(CheckHandler >= 0 &&
2831 size_t(CheckHandler) < llvm::array_lengthof(SanitizerHandlers));
2832 const StringRef CheckName = SanitizerHandlers[CheckHandler].Name;
2837 for (
int i = 0, n = Checked.size(); i < n; ++i) {
2846 Cond = Cond ?
Builder.CreateAnd(Cond, Check) : Check;
2851 if (!FatalCond && !RecoverableCond)
2855 if (FatalCond && RecoverableCond)
2856 JointCond =
Builder.CreateAnd(FatalCond, RecoverableCond);
2858 JointCond = FatalCond ? FatalCond : RecoverableCond;
2864 for (
int i = 1, n = Checked.size(); i < n; ++i) {
2866 "All recoverable kinds in a single check must be same!");
2873 llvm::Instruction *Branch =
Builder.CreateCondBr(JointCond, Cont, Handlers);
2877 llvm::MDNode *
Node = MDHelper.createBranchWeights((1U << 20) - 1, 1);
2878 Branch->setMetadata(llvm::LLVMContext::MD_prof, Node);
2887 Args.reserve(DynamicArgs.size() + 1);
2888 ArgTypes.reserve(DynamicArgs.size() + 1);
2891 if (!StaticArgs.empty()) {
2892 llvm::Constant *Info = llvm::ConstantStruct::getAnon(StaticArgs);
2894 new llvm::GlobalVariable(
CGM.
getModule(), Info->getType(),
false,
2895 llvm::GlobalVariable::PrivateLinkage, Info);
2896 InfoPtr->setUnnamedAddr(llvm::GlobalValue::UnnamedAddr::Global);
2902 for (
size_t i = 0, n = DynamicArgs.size(); i != n; ++i) {
2908 llvm::FunctionType *FnType =
2909 llvm::FunctionType::get(
CGM.
VoidTy, ArgTypes,
false);
2911 if (!FatalCond || !RecoverableCond) {
2915 (FatalCond !=
nullptr), Cont);
2919 llvm::BasicBlock *NonFatalHandlerBB =
2922 Builder.CreateCondBr(FatalCond, NonFatalHandlerBB, FatalHandlerBB);
2940 llvm::BranchInst *BI =
Builder.CreateCondBr(Cond, Cont, CheckBB);
2943 llvm::MDNode *
Node = MDHelper.createBranchWeights((1U << 20) - 1, 1);
2944 BI->setMetadata(llvm::LLVMContext::MD_prof, Node);
2950 llvm::CallInst *CheckCall;
2952 llvm::Constant *Info = llvm::ConstantStruct::getAnon(StaticArgs);
2954 new llvm::GlobalVariable(
CGM.
getModule(), Info->getType(),
false,
2955 llvm::GlobalVariable::PrivateLinkage, Info);
2956 InfoPtr->setUnnamedAddr(llvm::GlobalValue::UnnamedAddr::Global);
2959 llvm::Constant *SlowPathDiagFn =
CGM.
getModule().getOrInsertFunction(
2960 "__cfi_slowpath_diag",
2963 CheckCall =
Builder.CreateCall(
2967 llvm::Constant *SlowPathFn =
CGM.
getModule().getOrInsertFunction(
2970 CheckCall =
Builder.CreateCall(SlowPathFn, {TypeId, Ptr});
2973 CheckCall->setDoesNotThrow();
2982 auto &Ctx = M->getContext();
2985 llvm::GlobalValue::WeakAnyLinkage,
"__cfi_check", M);
2992 llvm::Intrinsic::getDeclaration(M, llvm::Intrinsic::trap),
"", BB);
3010 Args.push_back(&ArgData);
3011 Args.push_back(&ArgAddr);
3018 llvm::GlobalValue::WeakODRLinkage,
"__cfi_check_fail", &
CGM.
getModule());
3036 llvm::StructType *SourceLocationTy =
3038 llvm::StructType *CfiCheckFailDataTy =
3039 llvm::StructType::get(
Int8Ty, SourceLocationTy, VoidPtrTy);
3043 Builder.CreatePointerCast(Data, CfiCheckFailDataTy->getPointerTo(0)), 0,
3048 llvm::Value *AllVtables = llvm::MetadataAsValue::get(
3053 {Addr, AllVtables}),
3056 const std::pair<int, SanitizerMask> CheckKinds[] = {
3064 for (
auto CheckKindMaskPair : CheckKinds) {
3065 int Kind = CheckKindMaskPair.first;
3068 Builder.CreateICmpNE(CheckKind, llvm::ConstantInt::get(
Int8Ty, Kind));
3070 EmitCheck(std::make_pair(Cond, Mask), SanitizerHandler::CFICheckFail, {},
3071 {Data, Addr, ValidVtable});
3083 if (
SanOpts.
has(SanitizerKind::Unreachable)) {
3086 SanitizerKind::Unreachable),
3087 SanitizerHandler::BuiltinUnreachable,
3100 Builder.CreateCondBr(Checked, Cont, TrapBB);
3102 llvm::CallInst *TrapCall =
EmitTrapCall(llvm::Intrinsic::trap);
3103 TrapCall->setDoesNotReturn();
3104 TrapCall->setDoesNotThrow();
3107 Builder.CreateCondBr(Checked, Cont, TrapBB);
3117 auto A = llvm::Attribute::get(
getLLVMContext(),
"trap-func-name",
3119 TrapCall->addAttribute(llvm::AttributeList::FunctionIndex, A);
3129 "Array to pointer decay must have array source type!");
3133 Address Addr = LV.getAddress();
3143 assert(isa<llvm::ArrayType>(Addr.getElementType()) &&
3144 "Expected pointer to array");
3154 if (BaseInfo) *BaseInfo = LV.getBaseInfo();
3164 const auto *CE = dyn_cast<
CastExpr>(E);
3165 if (!CE || CE->getCastKind() != CK_ArrayToPointerDecay)
3169 const Expr *SubExpr = CE->getSubExpr();
3182 const llvm::Twine &name =
"arrayidx") {
3188 return CGF.
Builder.CreateGEP(ptr, indices, name);
3197 if (
auto constantIdx = dyn_cast<llvm::ConstantInt>(idx)) {
3198 CharUnits offset = constantIdx->getZExtValue() * eltSize;
3220 const llvm::Twine &name =
"arrayidx") {
3223 for (
auto idx : indices.drop_back())
3224 assert(isa<llvm::ConstantInt>(idx) &&
3225 cast<llvm::ConstantInt>(idx)->isZero());
3240 CGF, addr.
getPointer(), indices, inbounds, signedIndices, loc, name);
3241 return Address(eltPtr, eltAlign);
3250 bool SignedIndices =
false;
3251 auto EmitIdxAfterBase = [&, IdxPre](
bool Promote) ->
llvm::Value * {
3254 assert(E->
getRHS() == E->
getIdx() &&
"index was neither LHS nor RHS");
3260 SignedIndices |= IdxSigned;
3266 if (Promote && Idx->getType() !=
IntPtrTy)
3276 !isa<ExtVectorElementExpr>(E->
getBase())) {
3279 auto *Idx = EmitIdxAfterBase(
false);
3280 assert(LHS.
isSimple() &&
"Can only subscript lvalue vectors here!");
3288 if (isa<ExtVectorElementExpr>(E->
getBase())) {
3290 auto *Idx = EmitIdxAfterBase(
true);
3309 auto *Idx = EmitIdxAfterBase(
true);
3319 Idx =
Builder.CreateMul(Idx, numElements);
3321 Idx =
Builder.CreateNSWMul(Idx, numElements);
3333 auto *Idx = EmitIdxAfterBase(
true);
3337 llvm::ConstantInt::get(Idx->getType(), InterfaceSize.
getQuantity());
3354 Addr =
Address(EltPtr, EltAlign);
3363 assert(Array->getType()->isArrayType() &&
3364 "Array to pointer decay must have array source type!");
3368 if (
const auto *ASE = dyn_cast<ArraySubscriptExpr>(Array))
3372 auto *Idx = EmitIdxAfterBase(
true);
3379 EltBaseInfo = ArrayLV.getBaseInfo();
3384 auto *Idx = EmitIdxAfterBase(
true);
3404 bool IsLowerBound) {
3421 "Expected pointer to array");
3441 bool IsLowerBound) {
3445 ResultExprTy = AT->getElementType();
3456 LowerBound->getType()->hasSignedIntegerRepresentation());
3458 Idx = llvm::ConstantInt::getNullValue(
IntPtrTy);
3465 llvm::APSInt ConstLength;
3468 if (Length->isIntegerConstantExpr(ConstLength, C)) {
3474 if (LowerBound && LowerBound->isIntegerConstantExpr(ConstLowerBound, C)) {
3476 LowerBound =
nullptr;
3480 else if (!LowerBound)
3483 if (Length || LowerBound) {
3484 auto *LowerBoundVal =
3488 LowerBound->getType()->hasSignedIntegerRepresentation())
3489 : llvm::ConstantInt::get(
IntPtrTy, ConstLowerBound);
3494 Length->getType()->hasSignedIntegerRepresentation())
3495 : llvm::ConstantInt::get(
IntPtrTy, ConstLength);
3496 Idx =
Builder.CreateAdd(LowerBoundVal, LengthVal,
"lb_add_len",
3499 if (Length && LowerBound) {
3501 Idx, llvm::ConstantInt::get(
IntPtrTy, 1),
"idx_sub_1",
3505 Idx = llvm::ConstantInt::get(
IntPtrTy, ConstLength + ConstLowerBound);
3511 if (
auto *VAT = C.getAsVariableArrayType(ArrayTy)) {
3512 Length = VAT->getSizeExpr();
3513 if (Length->isIntegerConstantExpr(ConstLength, C))
3516 auto *CAT = C.getAsConstantArrayType(ArrayTy);
3517 ConstLength = CAT->getSize();
3520 auto *LengthVal =
Builder.CreateIntCast(
3522 Length->getType()->hasSignedIntegerRepresentation());
3524 LengthVal, llvm::ConstantInt::get(
IntPtrTy, 1),
"len_sub_1",
3529 Idx = llvm::ConstantInt::get(
IntPtrTy, ConstLength);
3538 if (
auto *VLA =
getContext().getAsVariableArrayType(ResultExprTy)) {
3544 BaseTy, VLA->getElementType(), IsLowerBound);
3553 Idx =
Builder.CreateMul(Idx, NumElements);
3555 Idx =
Builder.CreateNSWMul(Idx, NumElements);
3564 assert(Array->getType()->isArrayType() &&
3565 "Array to pointer decay must have array source type!");
3569 if (
const auto *ASE = dyn_cast<ArraySubscriptExpr>(Array))
3579 BaseInfo = ArrayLV.getBaseInfo();
3583 TBAAInfo, BaseTy, ResultExprTy,
3606 Base =
MakeAddrLValue(Ptr, PT->getPointeeType(), BaseInfo, TBAAInfo);
3607 Base.getQuals().removeObjCGCAttr();
3616 "Result must be a vector");
3634 llvm::Constant *CV =
3639 assert(Base.
isExtVectorElt() &&
"Can only subscript lvalue vec elts here!");
3644 for (
unsigned i = 0, e = Indices.size(); i != e; ++i)
3645 CElts.push_back(BaseElts->getAggregateElement(Indices[i]));
3646 llvm::Constant *CV = llvm::ConstantVector::get(CElts);
3668 SkippedChecks.
set(SanitizerKind::Alignment,
true);
3669 if (IsBaseCXXThis || isa<DeclRefExpr>(BaseExpr))
3670 SkippedChecks.
set(SanitizerKind::Null,
true);
3678 if (
auto *Field = dyn_cast<FieldDecl>(ND)) {
3684 if (
const auto *FD = dyn_cast<FunctionDecl>(ND))
3687 llvm_unreachable(
"Unhandled member declaration!");
3693 assert(cast<CXXMethodDecl>(
CurCodeDecl)->getParent()->isLambda());
3718 "LLVM field at index zero had non-zero offset?");
3733 if (RD->isDynamicClass())
3736 for (
const auto &
Base : RD->bases())
3740 for (
const FieldDecl *Field : RD->fields())
3795 assert(!FieldTBAAInfo.
Offset &&
3796 "Nonzero offset for an access with no base type!");
3809 FieldTBAAInfo.
Size =
3817 assert(!FieldType->
isReferenceType() &&
"union has reference member");
3849 if (field->
hasAttr<AnnotateAttr>())
3911 assert(E->
isTransparent() &&
"non-transparent glvalue init list");
3919 const Expr *Operand) {
3920 if (
auto *ThrowExpr = dyn_cast<CXXThrowExpr>(Operand->
IgnoreParens())) {
3933 "Unexpected conditional operator!");
3943 if (!CondExprBool) std::swap(live, dead);
3968 if (lhs && !lhs->isSimple())
3971 lhsBlock =
Builder.GetInsertBlock();
3981 if (rhs && !rhs->isSimple())
3983 rhsBlock =
Builder.GetInsertBlock();
3988 llvm::PHINode *phi =
Builder.CreatePHI(lhs->getPointer()->getType(),
3990 phi->addIncoming(lhs->getPointer(), lhsBlock);
3991 phi->addIncoming(rhs->getPointer(), rhsBlock);
3992 Address result(phi,
std::min(lhs->getAlignment(), rhs->getAlignment()));
3994 std::max(lhs->getBaseInfo().getAlignmentSource(),
3995 rhs->getBaseInfo().getAlignmentSource());
3997 lhs->getTBAAInfo(), rhs->getTBAAInfo());
4001 assert((lhs || rhs) &&
4002 "both operands of glvalue conditional are throw-expressions?");
4003 return lhs ? *lhs : *rhs;
4018 case CK_ArrayToPointerDecay:
4019 case CK_FunctionToPointerDecay:
4020 case CK_NullToMemberPointer:
4021 case CK_NullToPointer:
4022 case CK_IntegralToPointer:
4023 case CK_PointerToIntegral:
4024 case CK_PointerToBoolean:
4025 case CK_VectorSplat:
4026 case CK_IntegralCast:
4027 case CK_BooleanToSignedIntegral:
4028 case CK_IntegralToBoolean:
4029 case CK_IntegralToFloating:
4030 case CK_FloatingToIntegral:
4031 case CK_FloatingToBoolean:
4032 case CK_FloatingCast:
4033 case CK_FloatingRealToComplex:
4034 case CK_FloatingComplexToReal:
4035 case CK_FloatingComplexToBoolean:
4036 case CK_FloatingComplexCast:
4037 case CK_FloatingComplexToIntegralComplex:
4038 case CK_IntegralRealToComplex:
4039 case CK_IntegralComplexToReal:
4040 case CK_IntegralComplexToBoolean:
4041 case CK_IntegralComplexCast:
4042 case CK_IntegralComplexToFloatingComplex:
4043 case CK_DerivedToBaseMemberPointer:
4044 case CK_BaseToDerivedMemberPointer:
4045 case CK_MemberPointerToBoolean:
4046 case CK_ReinterpretMemberPointer:
4047 case CK_AnyPointerToBlockPointerCast:
4048 case CK_ARCProduceObject:
4049 case CK_ARCConsumeObject:
4050 case CK_ARCReclaimReturnedObject:
4051 case CK_ARCExtendBlockObject:
4052 case CK_CopyAndAutoreleaseBlockObject:
4053 case CK_AddressSpaceConversion:
4054 case CK_IntToOCLSampler:
4058 llvm_unreachable(
"dependent cast kind in IR gen!");
4060 case CK_BuiltinFnToFnPtr:
4061 llvm_unreachable(
"builtin functions are handled elsewhere");
4064 case CK_NonAtomicToAtomic:
4065 case CK_AtomicToNonAtomic:
4071 const auto *DCE = cast<CXXDynamicCastExpr>(E);
4075 case CK_ConstructorConversion:
4076 case CK_UserDefinedConversion:
4077 case CK_CPointerToObjCPointerCast:
4078 case CK_BlockPointerToObjCPointerCast:
4080 case CK_LValueToRValue:
4083 case CK_UncheckedDerivedToBase:
4084 case CK_DerivedToBase: {
4087 auto *DerivedClassDecl = cast<CXXRecordDecl>(DerivedClassTy->
getDecl());
4090 Address This = LV.getAddress();
4105 case CK_BaseToDerived: {
4107 auto *DerivedClassDecl = cast<CXXRecordDecl>(DerivedClassTy->
getDecl());
4121 Derived.getPointer(), E->
getType());
4123 if (
SanOpts.
has(SanitizerKind::CFIDerivedCast))
4131 case CK_LValueBitCast: {
4133 const auto *CE = cast<ExplicitCastExpr>(E);
4140 if (
SanOpts.
has(SanitizerKind::CFIUnrelatedCast))
4148 case CK_ObjCObjectLValueCast: {
4155 case CK_ZeroToOCLQueue:
4156 llvm_unreachable(
"NULL to OpenCL queue lvalue cast is not valid");
4157 case CK_ZeroToOCLEvent:
4158 llvm_unreachable(
"NULL to OpenCL event lvalue cast is not valid");
4161 llvm_unreachable(
"Unhandled lvalue cast kind?");
4186 llvm_unreachable(
"bad evaluation kind");
4199 if (
const auto *CE = dyn_cast<CXXMemberCallExpr>(E))
4202 if (
const auto *CE = dyn_cast<CUDAKernelCallExpr>(E))
4205 if (
const auto *CE = dyn_cast<CXXOperatorCallExpr>(E))
4207 dyn_cast_or_null<CXXMethodDecl>(CE->getCalleeDecl()))
4244 if (
auto ICE = dyn_cast<ImplicitCastExpr>(E)) {
4245 if (ICE->getCastKind() == CK_FunctionToPointerDecay ||
4246 ICE->getCastKind() == CK_BuiltinFnToFnPtr) {
4251 }
else if (
auto DRE = dyn_cast<DeclRefExpr>(E)) {
4252 if (
auto FD = dyn_cast<FunctionDecl>(DRE->getDecl())) {
4255 }
else if (
auto ME = dyn_cast<MemberExpr>(E)) {
4256 if (
auto FD = dyn_cast<FunctionDecl>(ME->getMemberDecl())) {
4262 }
else if (
auto NTTP = dyn_cast<SubstNonTypeTemplateParmExpr>(E)) {
4266 }
else if (
auto PDE = dyn_cast<CXXPseudoDestructorExpr>(E)) {
4283 CGCallee callee(calleeInfo, calleePtr);
4299 assert(E->
getOpcode() == BO_Assign &&
"unexpected binary l-value");
4334 llvm_unreachable(
"bad evaluation kind");
4345 "Can't have a scalar return unless the return type is a " 4358 &&
"binding l-value to type which needs a temporary");
4403 "Can't have a scalar return unless the return type is a " 4423 unsigned CVRQualifiers) {
4425 Ivar, CVRQualifiers);
4441 ObjectTy = BaseExpr->
getType();
4465 "Call must have function pointer type!");
4469 if (
const FunctionDecl *FD = dyn_cast_or_null<FunctionDecl>(TargetDecl))
4476 if (TargetDecl->hasAttr<AlwaysInlineAttr>() &&
4477 TargetDecl->hasAttr<TargetAttr>())
4482 const auto *FnType =
4483 cast<FunctionType>(cast<PointerType>(CalleeType)->getPointeeType());
4488 (!TargetDecl || !isa<FunctionDecl>(TargetDecl))) {
4489 if (llvm::Constant *PrefixSig =
4492 llvm::Constant *FTRTTIConst =
4495 llvm::StructType *PrefixStructTy = llvm::StructType::get(
4498 llvm::Value *CalleePtr = Callee.getFunctionPointer();
4501 CalleePtr, llvm::PointerType::getUnqual(PrefixStructTy));
4503 Builder.CreateConstGEP2_32(PrefixStructTy, CalleePrefixStruct, 0, 0);
4510 Builder.CreateCondBr(CalleeSigMatch, TypeCheck, Cont);
4514 Builder.CreateConstGEP2_32(PrefixStructTy, CalleePrefixStruct, 0, 1);
4520 Builder.CreateICmpEQ(CalleeRTTI, FTRTTIConst);
4521 llvm::Constant *StaticData[] = {
4525 EmitCheck(std::make_pair(CalleeRTTIMatch, SanitizerKind::Function),
4526 SanitizerHandler::FunctionTypeMismatch, StaticData, CalleePtr);
4536 (!TargetDecl || !isa<FunctionDecl>(TargetDecl))) {
4548 llvm::Value *CalleePtr = Callee.getFunctionPointer();
4551 CGM.
getIntrinsic(llvm::Intrinsic::type_test), {CastedCallee, TypeId});
4554 llvm::Constant *StaticData[] = {
4561 CastedCallee, StaticData);
4563 EmitCheck(std::make_pair(TypeTest, SanitizerKind::CFIICall),
4564 SanitizerHandler::CFICheckFail, StaticData,
4565 {CastedCallee, llvm::UndefValue::get(
IntPtrTy)});
4581 if (
auto *OCE = dyn_cast<CXXOperatorCallExpr>(E)) {
4582 if (OCE->isAssignmentOp())
4585 switch (OCE->getOperator()) {
4587 case OO_GreaterGreater:
4604 Args, FnType, Chain);
4626 if (isa<FunctionNoProtoType>(FnType) || Chain) {
4628 CalleeTy = CalleeTy->getPointerTo();
4630 llvm::Value *CalleePtr = Callee.getFunctionPointer();
4632 Callee.setFunctionPointer(CalleePtr);
4658 return MakeAddrLValue(MemberAddr, MPT->getPointeeType(), BaseInfo, TBAAInfo);
4675 llvm_unreachable(
"bad evaluation kind");
4679 assert(Val->getType()->isFPOrFPVectorTy());
4680 if (Accuracy == 0.0 || !isa<llvm::Instruction>(Val))
4684 llvm::MDNode *
Node = MDHelper.createFPMath(Accuracy);
4686 cast<llvm::Instruction>(Val)->setMetadata(llvm::LLVMContext::MD_fpmath, Node);
4690 struct LValueOrRValue {
4704 LValueOrRValue result;
4708 const Expr *semantic = *i;
4712 if (
const auto *ov = dyn_cast<OpaqueValueExpr>(semantic)) {
4718 if (ov == resultExpr && ov->
isRValue() && !forLValue &&
4723 opaqueData = OVMA::bind(CGF, ov, LV);
4728 opaqueData = OVMA::bind(CGF, ov, ov->getSourceExpr());
4731 if (ov == resultExpr) {
4739 opaques.push_back(opaqueData);
4743 }
else if (semantic == resultExpr) {
4756 for (
unsigned i = 0, e = opaques.size(); i != e; ++i)
4757 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.
An instance of this class is created to represent 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
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...
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
getFieldIndex - Returns the index of this field within its record, as appropriate for passing to ASTR...
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
const void * Store
Store - This opaque type encapsulates an immutable mapping from locations to values.
static Destroyer destroyARCStrongPrecise
Expr * getLowerBound()
Get lower bound of array section.
const RecordDecl * getParent() const
getParent - Returns the parent of this field declaration, which is the struct in which this field is ...
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...
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)
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.
VarDecl - An instance of this class is created to represent 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.
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)
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 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
ParmVarDecl - 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.
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.
RecordDecl - 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
FieldDecl - An instance of this class is created by Sema::ActOnField to represent a member of a struc...
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)
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)
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 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.
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
ValueDecl - Represent the declaration of a variable (in which case it is an lvalue) a function (in wh...
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...
const FunctionProtoType * T
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.
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.
void add(RValue rvalue, QualType type, bool needscopy=false)
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.
char __ovld __cnfn min(char x, char y)
Returns y if y < x, otherwise it returns x.
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.
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...
static AggValueSlot forAddr(Address addr, Qualifiers quals, IsDestructed_t isDestructed, NeedsGCBarriers_t needsGC, IsAliased_t isAliased, IsZeroed_t isZeroed=IsNotZeroed)
forAddr - Make a slot for an aggregate value.
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)
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.
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.
const CGCalleeInfo & getAbstractInfo() const
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 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)
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()'.
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.
EnumDecl - Represents an enum.
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
static Address createReferenceTemporary(CodeGenFunction &CGF, const MaterializeTemporaryExpr *M, const Expr *Inner)
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.
const LValue & getOpaqueLValueMapping(const OpaqueValueExpr *e)
getOpaqueLValueMapping - Given an opaque value expression (which must be mapped to an l-value)...
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
SourceLocation getLocStart() const LLVM_READONLY
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.
char __ovld __cnfn max(char x, char y)
Returns y if x < y, otherwise it returns x.
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.
QualType withCVRQualifiers(unsigned CVR) const
virtual void EmitObjCStrongCastAssign(CodeGen::CodeGenFunction &CGF, llvm::Value *src, Address dest)=0
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)
std::pair< llvm::Value *, QualType > getVLASize(const VariableArrayType *vla)
getVLASize - Returns an LLVM value that corresponds to the size, in non-variably-sized elements...
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
getIntegerType - 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
getName - 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...
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
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.
NamedDecl - This represents a decl with a name.
llvm::Value * EmitObjCConsumeObject(QualType T, llvm::Value *Ptr)
Produce the code for a CK_ARCConsumeObject.
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
SourceLocation getLocStart() const LLVM_READONLY
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.
Address CreateMemTemp(QualType T, const Twine &Name="tmp", bool CastToDefaultAddrSpace=true)
CreateMemTemp - Create a temporary memory object of the given type, with appropriate alignment...
const LangOptions & getLangOpts() const
static TBAAAccessInfo getMayAliasInfo()
llvm::Value * getPointer() const
LValue EmitStringLiteralLValue(const StringLiteral *E)
Address emitBlockByrefAddress(Address baseAddr, const VarDecl *V, bool followForward=true)
BuildBlockByrefAddress - Computes the location of the data in a variable which is declared as __block...
Abstract information about a function or function prototype.
void EmitCXXThrowExpr(const CXXThrowExpr *E, bool KeepInsertionPoint=true)
SourceLocation getLocation() const
void mergeForCast(const LValueBaseInfo &Info)
llvm::Constant * getExtVectorElts() const
Expr * getLength()
Get length of array section.
Structure with information about how a bitfield should be accessed.
CheckRecoverableKind
Specify under what conditions this check can be recovered.
Expr * IgnoreParens() LLVM_READONLY
IgnoreParens - Ignore parentheses.
static OMPLinearClause * Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation LParenLoc, OpenMPLinearClauseKind Modifier, SourceLocation ModifierLoc, SourceLocation ColonLoc, SourceLocation EndLoc, ArrayRef< Expr *> VL, ArrayRef< Expr *> PL, ArrayRef< Expr *> IL, Expr *Step, Expr *CalcStep, Stmt *PreInit, Expr *PostUpdate)
Creates clause with a list of variables VL and a linear step Step.
CanQualType getSizeType() const
Return the unique type for "size_t" (C99 7.17), defined in <stddef.h>.
void Destroyer(CodeGenFunction &CGF, Address addr, QualType ty)
Expr * getBase()
An array section can be written only as Base[LowerBound:Length].
Qualifiers::ObjCLifetime getObjCLifetime() const
Returns lifetime attribute of this type.
unsigned getLLVMFieldNo(const FieldDecl *FD) const
Return llvm::StructType element number that corresponds to the field FD.
virtual llvm::Value * EmitObjCWeakRead(CodeGen::CodeGenFunction &CGF, Address AddrWeakObj)=0
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 ...