24#include "llvm/IR/Constants.h"
25#include "llvm/IR/Function.h"
26#include "llvm/IR/GlobalVariable.h"
27#include "llvm/IR/IntrinsicInst.h"
28#include "llvm/IR/Intrinsics.h"
30using namespace CodeGen;
41class AggExprEmitter :
public StmtVisitor<AggExprEmitter> {
62 void withReturnValueSlot(
const Expr *E,
67 : CGF(cgf), Builder(CGF.Builder), Dest(Dest),
68 IsResultUnused(IsResultUnused) { }
77 void EmitAggLoadOfLValue(
const Expr *E);
92 void EmitArrayInit(
Address DestPtr, llvm::ArrayType *AType,
QualType ArrayQTy,
97 if (CGF.
getLangOpts().getGC() && TypeRequiresGCollection(
T))
102 bool TypeRequiresGCollection(
QualType T);
113 void VisitStmt(
Stmt *S) {
135 if (llvm::Value *Result =
ConstantEmitter(CGF).tryEmitConstantExpr(E)) {
140 if (Result->getType() != StoreDest.
getType())
151 void VisitDeclRefExpr(
DeclRefExpr *E) { EmitAggLoadOfLValue(E); }
152 void VisitMemberExpr(
MemberExpr *ME) { EmitAggLoadOfLValue(ME); }
153 void VisitUnaryDeref(
UnaryOperator *E) { EmitAggLoadOfLValue(E); }
154 void VisitStringLiteral(
StringLiteral *E) { EmitAggLoadOfLValue(E); }
157 EmitAggLoadOfLValue(E);
160 EmitAggLoadOfLValue(E);
165 void VisitCallExpr(
const CallExpr *E);
166 void VisitStmtExpr(
const StmtExpr *E);
168 void VisitPointerToDataMemberBinaryOperator(
const BinaryOperator *BO);
178 EmitAggLoadOfLValue(E);
189 llvm::Value *outerBegin =
nullptr);
193 CodeGenFunction::CXXDefaultArgExprScope
Scope(CGF, DAE);
197 CodeGenFunction::CXXDefaultInitExprScope
Scope(CGF, DIE);
207 void VisitCXXTypeidExpr(
CXXTypeidExpr *E) { EmitAggLoadOfLValue(E); }
214 return EmitFinalDestCopy(E->
getType(), LV);
218 bool NeedsDestruction =
221 if (NeedsDestruction)
224 if (NeedsDestruction)
240 EmitFinalDestCopy(E->
getType(), Res);
255void AggExprEmitter::EmitAggLoadOfLValue(
const Expr *E) {
264 EmitFinalDestCopy(E->
getType(), LV);
268bool AggExprEmitter::TypeRequiresGCollection(
QualType T) {
271 if (!RecordTy)
return false;
275 if (isa<CXXRecordDecl>(
Record) &&
276 (cast<CXXRecordDecl>(
Record)->hasNonTrivialCopyConstructor() ||
277 !cast<CXXRecordDecl>(
Record)->hasTrivialDestructor()))
284void AggExprEmitter::withReturnValueSlot(
287 bool RequiresDestruction =
297 (RequiresDestruction && Dest.
isIgnored());
303 llvm::Value *LifetimeSizePtr =
nullptr;
304 llvm::IntrinsicInst *LifetimeStartInst =
nullptr;
309 llvm::TypeSize
Size =
312 if (LifetimeSizePtr) {
314 cast<llvm::IntrinsicInst>(std::prev(Builder.GetInsertPoint()));
315 assert(LifetimeStartInst->getIntrinsicID() ==
316 llvm::Intrinsic::lifetime_start &&
317 "Last insertion wasn't a lifetime.start?");
334 EmitFinalDestCopy(E->
getType(), Src);
336 if (!RequiresDestruction && LifetimeStartInst) {
347 assert(src.
isAggregate() &&
"value must be aggregate value!");
349 EmitFinalDestCopy(
type, srcLV, EVK_RValue);
366 if (SrcValueKind == EVK_RValue) {
387 EmitCopy(
type, Dest, srcAgg);
423 assert(Array.isSimple() &&
"initializer_list array not a simple lvalue");
424 Address ArrayPtr = Array.getAddress(CGF);
428 assert(
ArrayType &&
"std::initializer_list constructed from non-array");
433 if (Field ==
Record->field_end()) {
439 if (!
Field->getType()->isPointerType() ||
449 llvm::Value *
Zero = llvm::ConstantInt::get(CGF.
PtrDiffTy, 0);
450 llvm::Value *IdxStart[] = {
Zero,
Zero };
451 llvm::Value *ArrayStart = Builder.CreateInBoundsGEP(
457 if (Field ==
Record->field_end()) {
464 if (
Field->getType()->isPointerType() &&
468 llvm::Value *IdxEnd[] = {
Zero,
Size };
469 llvm::Value *ArrayEnd = Builder.CreateInBoundsGEP(
488 if (isa<ImplicitValueInitExpr>(E))
491 if (
auto *ILE = dyn_cast<InitListExpr>(E)) {
492 if (ILE->getNumInits())
497 if (
auto *Cons = dyn_cast_or_null<CXXConstructExpr>(E))
498 return Cons->getConstructor()->isDefaultConstructor() &&
499 Cons->getConstructor()->isTrivial();
507void AggExprEmitter::EmitArrayInit(
Address DestPtr, llvm::ArrayType *AType,
510 uint64_t NumInitElements = Args.size();
512 uint64_t NumArrayElements = AType->getNumElements();
513 assert(NumInitElements <= NumArrayElements);
520 llvm::Value *zero = llvm::ConstantInt::get(CGF.
SizeTy, 0);
521 llvm::Value *indices[] = { zero, zero };
522 llvm::Value *begin = Builder.CreateInBoundsGEP(DestPtr.
getElementType(),
524 indices,
"arrayinit.begin");
534 if (NumInitElements * elementSize.
getQuantity() > 16 &&
539 if (llvm::Constant *
C =
540 Emitter.tryEmitForInitializer(ExprToVisit, AS, ArrayQTy)) {
541 auto GV =
new llvm::GlobalVariable(
543 true, llvm::GlobalValue::PrivateLinkage,
C,
545 nullptr, llvm::GlobalVariable::NotThreadLocal,
550 Address GVAddr(GV, GV->getValueType(), Align);
551 EmitFinalDestCopy(ArrayQTy, CGF.
MakeAddrLValue(GVAddr, ArrayQTy));
562 llvm::Instruction *cleanupDominator =
nullptr;
569 "arrayinit.endOfInit");
570 cleanupDominator = Builder.CreateStore(begin, endOfInit);
581 llvm::Value *one = llvm::ConstantInt::get(CGF.
SizeTy, 1);
588 llvm::Value *element = begin;
591 for (uint64_t i = 0; i != NumInitElements; ++i) {
594 element = Builder.CreateInBoundsGEP(
595 llvmElementType, element, one,
"arrayinit.element");
600 if (endOfInit.
isValid()) Builder.CreateStore(element, endOfInit);
604 Address(element, llvmElementType, elementAlign), elementType);
605 EmitInitializationToLValue(Args[i], elementLV);
614 if (NumInitElements != NumArrayElements &&
615 !(Dest.
isZeroed() && hasTrivialFiller &&
622 if (NumInitElements) {
623 element = Builder.CreateInBoundsGEP(
624 llvmElementType, element, one,
"arrayinit.start");
625 if (endOfInit.
isValid()) Builder.CreateStore(element, endOfInit);
629 llvm::Value *end = Builder.CreateInBoundsGEP(
630 llvmElementType, begin,
631 llvm::ConstantInt::get(CGF.
SizeTy, NumArrayElements),
"arrayinit.end");
633 llvm::BasicBlock *entryBB = Builder.GetInsertBlock();
638 llvm::PHINode *currentElement =
639 Builder.CreatePHI(element->getType(), 2,
"arrayinit.cur");
640 currentElement->addIncoming(element, entryBB);
649 CodeGenFunction::RunCleanupsScope CleanupsScope(CGF);
651 Address(currentElement, llvmElementType, elementAlign), elementType);
653 EmitInitializationToLValue(ArrayFiller, elementLV);
655 EmitNullInitializationToLValue(elementLV);
659 llvm::Value *nextElement = Builder.CreateInBoundsGEP(
660 llvmElementType, currentElement, one,
"arrayinit.next");
663 if (endOfInit.
isValid()) Builder.CreateStore(nextElement, endOfInit);
666 llvm::Value *done = Builder.CreateICmpEQ(nextElement, end,
669 Builder.CreateCondBr(done, endBB, bodyBB);
670 currentElement->addIncoming(nextElement, Builder.GetInsertBlock());
701 EmitAggLoadOfLValue(E);
727 if (
auto castE = dyn_cast<CastExpr>(op)) {
728 if (castE->getCastKind() == kind)
729 return castE->getSubExpr();
734void AggExprEmitter::VisitCastExpr(
CastExpr *E) {
735 if (
const auto *ECE = dyn_cast<ExplicitCastExpr>(E))
740 assert(isa<CXXDynamicCastExpr>(E) &&
"CK_Dynamic without a dynamic_cast?");
742 CodeGenFunction::TCK_Load);
770 case CK_LValueToRValueBitCast: {
781 llvm::Value *SizeVal = llvm::ConstantInt::get(
784 Builder.CreateMemCpy(DestAddress, SourceAddress, SizeVal);
788 case CK_DerivedToBase:
789 case CK_BaseToDerived:
790 case CK_UncheckedDerivedToBase: {
791 llvm_unreachable(
"cannot perform hierarchy conversion in EmitAggExpr: "
792 "should have been unpacked before we got here");
795 case CK_NonAtomicToAtomic:
796 case CK_AtomicToNonAtomic: {
797 bool isToAtomic = (E->
getCastKind() == CK_NonAtomicToAtomic);
802 if (isToAtomic) std::swap(
atomicType, valueType);
815 (isToAtomic ? CK_AtomicToNonAtomic : CK_NonAtomicToAtomic);
822 "peephole significantly changed types?");
860 return EmitFinalDestCopy(valueType, rvalue);
862 case CK_AddressSpaceConversion:
865 case CK_LValueToRValue:
886 case CK_HLSLArrayRValue:
891 case CK_UserDefinedConversion:
892 case CK_ConstructorConversion:
895 "Implicit cast types must be compatible");
899 case CK_LValueBitCast:
900 llvm_unreachable(
"should not be emitting lvalue bitcast as rvalue");
904 case CK_ArrayToPointerDecay:
905 case CK_FunctionToPointerDecay:
906 case CK_NullToPointer:
907 case CK_NullToMemberPointer:
908 case CK_BaseToDerivedMemberPointer:
909 case CK_DerivedToBaseMemberPointer:
910 case CK_MemberPointerToBoolean:
911 case CK_ReinterpretMemberPointer:
912 case CK_IntegralToPointer:
913 case CK_PointerToIntegral:
914 case CK_PointerToBoolean:
917 case CK_IntegralCast:
918 case CK_BooleanToSignedIntegral:
919 case CK_IntegralToBoolean:
920 case CK_IntegralToFloating:
921 case CK_FloatingToIntegral:
922 case CK_FloatingToBoolean:
923 case CK_FloatingCast:
924 case CK_CPointerToObjCPointerCast:
925 case CK_BlockPointerToObjCPointerCast:
926 case CK_AnyPointerToBlockPointerCast:
927 case CK_ObjCObjectLValueCast:
928 case CK_FloatingRealToComplex:
929 case CK_FloatingComplexToReal:
930 case CK_FloatingComplexToBoolean:
931 case CK_FloatingComplexCast:
932 case CK_FloatingComplexToIntegralComplex:
933 case CK_IntegralRealToComplex:
934 case CK_IntegralComplexToReal:
935 case CK_IntegralComplexToBoolean:
936 case CK_IntegralComplexCast:
937 case CK_IntegralComplexToFloatingComplex:
938 case CK_ARCProduceObject:
939 case CK_ARCConsumeObject:
940 case CK_ARCReclaimReturnedObject:
941 case CK_ARCExtendBlockObject:
942 case CK_CopyAndAutoreleaseBlockObject:
943 case CK_BuiltinFnToFnPtr:
944 case CK_ZeroToOCLOpaqueType:
946 case CK_HLSLVectorTruncation:
948 case CK_IntToOCLSampler:
949 case CK_FloatingToFixedPoint:
950 case CK_FixedPointToFloating:
951 case CK_FixedPointCast:
952 case CK_FixedPointToBoolean:
953 case CK_FixedPointToIntegral:
954 case CK_IntegralToFixedPoint:
955 llvm_unreachable(
"cast kind invalid for aggregate types");
959void AggExprEmitter::VisitCallExpr(
const CallExpr *E) {
961 EmitAggLoadOfLValue(E);
981void AggExprEmitter::VisitStmtExpr(
const StmtExpr *E) {
982 CodeGenFunction::StmtExprEvaluation eval(CGF);
995 const char *NameSuffix =
"") {
998 ArgTy = CT->getElementType();
1002 "member pointers may only be compared for equality");
1004 CGF, LHS, RHS, MPT,
false);
1008 struct CmpInstInfo {
1010 llvm::CmpInst::Predicate FCmp;
1011 llvm::CmpInst::Predicate SCmp;
1012 llvm::CmpInst::Predicate UCmp;
1014 CmpInstInfo InstInfo = [&]() -> CmpInstInfo {
1015 using FI = llvm::FCmpInst;
1016 using II = llvm::ICmpInst;
1019 return {
"cmp.lt", FI::FCMP_OLT, II::ICMP_SLT, II::ICMP_ULT};
1021 return {
"cmp.gt", FI::FCMP_OGT, II::ICMP_SGT, II::ICMP_UGT};
1023 return {
"cmp.eq", FI::FCMP_OEQ, II::ICMP_EQ, II::ICMP_EQ};
1025 llvm_unreachable(
"Unrecognised CompareKind enum");
1029 return Builder.CreateFCmp(InstInfo.FCmp, LHS, RHS,
1030 llvm::Twine(InstInfo.Name) + NameSuffix);
1034 return Builder.CreateICmp(Inst, LHS, RHS,
1035 llvm::Twine(InstInfo.Name) + NameSuffix);
1038 llvm_unreachable(
"unsupported aggregate binary expression should have "
1039 "already been handled");
1043 using llvm::BasicBlock;
1044 using llvm::PHINode;
1051 "cannot copy non-trivially copyable aggregate");
1063 auto EmitOperand = [&](
Expr *E) -> std::pair<Value *, Value *> {
1072 auto LHSValues = EmitOperand(E->
getLHS()),
1073 RHSValues = EmitOperand(E->
getRHS());
1076 Value *Cmp =
EmitCompare(Builder, CGF, E, LHSValues.first, RHSValues.first,
1077 K, IsComplex ?
".r" :
"");
1082 RHSValues.second, K,
".i");
1083 return Builder.CreateAnd(Cmp, CmpImag,
"and.eq");
1086 return Builder.getInt(VInfo->getIntValue());
1094 Builder.CreateSelect(EmitCmp(
CK_Less), EmitCmpRes(CmpInfo.
getLess()),
1096 Select = Builder.CreateSelect(EmitCmp(
CK_Equal),
1098 SelectOne,
"sel.eq");
1100 Value *SelectEq = Builder.CreateSelect(
1105 SelectEq,
"sel.gt");
1106 Select = Builder.CreateSelect(
1107 EmitCmp(
CK_Less), EmitCmpRes(CmpInfo.
getLess()), SelectGT,
"sel.lt");
1122void AggExprEmitter::VisitBinaryOperator(
const BinaryOperator *E) {
1124 VisitPointerToDataMemberBinaryOperator(E);
1129void AggExprEmitter::VisitPointerToDataMemberBinaryOperator(
1132 EmitFinalDestCopy(E->
getType(), LV);
1142 if (
const DeclRefExpr *DRE = dyn_cast<DeclRefExpr>(E)) {
1143 const VarDecl *var = dyn_cast<VarDecl>(DRE->getDecl());
1144 return (var && var->
hasAttr<BlocksAttr>());
1153 if (op->isAssignmentOp() || op->isPtrMemOp())
1157 if (op->getOpcode() == BO_Comma)
1165 = dyn_cast<AbstractConditionalOperator>(E)) {
1171 = dyn_cast<OpaqueValueExpr>(E)) {
1172 if (
const Expr *src = op->getSourceExpr())
1179 }
else if (
const CastExpr *
cast = dyn_cast<CastExpr>(E)) {
1180 if (
cast->getCastKind() == CK_LValueToRValue)
1186 }
else if (
const UnaryOperator *uop = dyn_cast<UnaryOperator>(E)) {
1190 }
else if (
const MemberExpr *mem = dyn_cast<MemberExpr>(E)) {
1206 &&
"Invalid assignment");
1261 EmitFinalDestCopy(E->
getType(), LHS);
1269void AggExprEmitter::
1276 CodeGenFunction::OpaqueValueMapping binding(CGF, E);
1278 CodeGenFunction::ConditionalEvaluation eval(CGF);
1284 bool destructNonTrivialCStruct =
1285 !isExternallyDestructed &&
1287 isExternallyDestructed |= destructNonTrivialCStruct;
1299 assert(CGF.
HaveInsertPoint() &&
"expression evaluation ended with no IP!");
1300 CGF.
Builder.CreateBr(ContBlock);
1315 if (destructNonTrivialCStruct)
1324void AggExprEmitter::VisitChooseExpr(
const ChooseExpr *CE) {
1328void AggExprEmitter::VisitVAArgExpr(
VAArgExpr *VE) {
1353 if (!wasExternallyDestructed)
1363void AggExprEmitter::VisitCXXInheritedCtorInitExpr(
1372AggExprEmitter::VisitLambdaExpr(
LambdaExpr *E) {
1379 llvm::Instruction *CleanupDominator =
nullptr;
1384 i != e; ++i, ++CurField) {
1387 if (CurField->hasCapturedVLAType()) {
1392 EmitInitializationToLValue(*i, LV);
1396 CurField->getType().isDestructedType()) {
1399 if (!CleanupDominator)
1402 llvm::Constant::getNullValue(CGF.
Int8PtrTy),
1414 for (
unsigned i = Cleanups.size(); i != 0; --i)
1418 if (CleanupDominator)
1419 CleanupDominator->eraseFromParent();
1423 CodeGenFunction::RunCleanupsScope cleanups(CGF);
1446 case CK_UserDefinedConversion:
1447 case CK_ConstructorConversion:
1453 case CK_BooleanToSignedIntegral:
1454 case CK_FloatingCast:
1455 case CK_FloatingComplexCast:
1456 case CK_FloatingComplexToBoolean:
1457 case CK_FloatingComplexToIntegralComplex:
1458 case CK_FloatingComplexToReal:
1459 case CK_FloatingRealToComplex:
1460 case CK_FloatingToBoolean:
1461 case CK_FloatingToIntegral:
1462 case CK_IntegralCast:
1463 case CK_IntegralComplexCast:
1464 case CK_IntegralComplexToBoolean:
1465 case CK_IntegralComplexToFloatingComplex:
1466 case CK_IntegralComplexToReal:
1467 case CK_IntegralRealToComplex:
1468 case CK_IntegralToBoolean:
1469 case CK_IntegralToFloating:
1471 case CK_IntegralToPointer:
1472 case CK_PointerToIntegral:
1474 case CK_VectorSplat:
1476 case CK_NonAtomicToAtomic:
1477 case CK_AtomicToNonAtomic:
1478 case CK_HLSLVectorTruncation:
1481 case CK_BaseToDerivedMemberPointer:
1482 case CK_DerivedToBaseMemberPointer:
1483 case CK_MemberPointerToBoolean:
1484 case CK_NullToMemberPointer:
1485 case CK_ReinterpretMemberPointer:
1489 case CK_AnyPointerToBlockPointerCast:
1490 case CK_BlockPointerToObjCPointerCast:
1491 case CK_CPointerToObjCPointerCast:
1492 case CK_ObjCObjectLValueCast:
1493 case CK_IntToOCLSampler:
1494 case CK_ZeroToOCLOpaqueType:
1498 case CK_FixedPointCast:
1499 case CK_FixedPointToBoolean:
1500 case CK_FixedPointToFloating:
1501 case CK_FixedPointToIntegral:
1502 case CK_FloatingToFixedPoint:
1503 case CK_IntegralToFixedPoint:
1507 case CK_AddressSpaceConversion:
1508 case CK_BaseToDerived:
1509 case CK_DerivedToBase:
1511 case CK_NullToPointer:
1512 case CK_PointerToBoolean:
1517 case CK_ARCConsumeObject:
1518 case CK_ARCExtendBlockObject:
1519 case CK_ARCProduceObject:
1520 case CK_ARCReclaimReturnedObject:
1521 case CK_CopyAndAutoreleaseBlockObject:
1522 case CK_ArrayToPointerDecay:
1523 case CK_FunctionToPointerDecay:
1524 case CK_BuiltinFnToFnPtr:
1526 case CK_LValueBitCast:
1527 case CK_LValueToRValue:
1528 case CK_LValueToRValueBitCast:
1529 case CK_UncheckedDerivedToBase:
1530 case CK_HLSLArrayRValue:
1533 llvm_unreachable(
"Unhandled clang::CastKind enum");
1541 while (
auto *CE = dyn_cast<CastExpr>(E)) {
1549 return IL->getValue() == 0;
1552 return FL->getValue().isPosZero();
1554 if ((isa<ImplicitValueInitExpr>(E) || isa<CXXScalarValueInitExpr>(E)) &&
1558 if (
const CastExpr *ICE = dyn_cast<CastExpr>(E))
1559 return ICE->getCastKind() == CK_NullToPointer &&
1564 return CL->getValue() == 0;
1572AggExprEmitter::EmitInitializationToLValue(
Expr *E,
LValue LV) {
1579 }
else if (isa<ImplicitValueInitExpr>(E) || isa<CXXScalarValueInitExpr>(E)) {
1580 return EmitNullInitializationToLValue(LV);
1581 }
else if (isa<NoInitExpr>(E)) {
1584 }
else if (
type->isReferenceType()) {
1608 llvm_unreachable(
"bad evaluation kind");
1611void AggExprEmitter::EmitNullInitializationToLValue(
LValue lv) {
1644void AggExprEmitter::VisitInitListExpr(
InitListExpr *E) {
1651 VisitCXXParenListOrInitListExpr(
1655void AggExprEmitter::VisitCXXParenListOrInitListExpr(
1664 if (llvm::Constant *
C =
1665 CGF.
CGM.EmitConstantExpr(ExprToVisit, ExprToVisit->
getType(), &CGF)) {
1666 llvm::GlobalVariable* GV =
1667 new llvm::GlobalVariable(CGF.
CGM.
getModule(),
C->getType(),
true,
1668 llvm::GlobalValue::InternalLinkage,
C,
"");
1669 EmitFinalDestCopy(ExprToVisit->
getType(),
1683 InitExprs, ArrayFiller);
1689 assert(InitExprs.size() == 0 &&
1690 "you can only use an empty initializer with VLAs");
1696 "Only support structs/unions here!");
1702 unsigned NumInitElements = InitExprs.size();
1708 llvm::Instruction *cleanupDominator =
nullptr;
1710 cleanups.push_back(cleanup);
1711 if (!cleanupDominator)
1717 unsigned curInitIndex = 0;
1720 if (
auto *CXXRD = dyn_cast<CXXRecordDecl>(record)) {
1721 assert(NumInitElements >= CXXRD->getNumBases() &&
1722 "missing initializer for base class");
1723 for (
auto &
Base : CXXRD->bases()) {
1724 assert(!
Base.isVirtual() &&
"should not see vbases here");
1725 auto *BaseRD =
Base.getType()->getAsCXXRecordDecl();
1735 CGF.
EmitAggExpr(InitExprs[curInitIndex++], AggSlot);
1738 Base.getType().isDestructedType()) {
1746 CodeGenFunction::FieldConstructionScope FCS(CGF, Dest.
getAddress());
1751 if (!InitializedFieldInUnion) {
1757 for (
const auto *Field : record->
fields())
1759 (
Field->isUnnamedBitField() ||
Field->isAnonymousStructOrUnion()) &&
1760 "Only unnamed bitfields or ananymous class allowed");
1769 if (NumInitElements) {
1771 EmitInitializationToLValue(InitExprs[0], FieldLoc);
1774 EmitNullInitializationToLValue(FieldLoc);
1782 for (
const auto *field : record->
fields()) {
1784 if (field->getType()->isIncompleteArrayType())
1788 if (field->isUnnamedBitField())
1794 if (curInitIndex == NumInitElements && Dest.
isZeroed() &&
1803 if (curInitIndex < NumInitElements) {
1805 EmitInitializationToLValue(InitExprs[curInitIndex++], LV);
1808 EmitNullInitializationToLValue(LV);
1814 bool pushedCleanup =
false;
1816 = field->getType().isDestructedType()) {
1822 pushedCleanup =
true;
1828 if (!pushedCleanup && LV.
isSimple())
1829 if (llvm::GetElementPtrInst *GEP =
1831 if (GEP->use_empty())
1832 GEP->eraseFromParent();
1837 assert((cleanupDominator || cleanups.empty()) &&
1838 "Missing cleanupDominator before deactivating cleanup blocks");
1839 for (
unsigned i = cleanups.size(); i != 0; --i)
1843 if (cleanupDominator)
1844 cleanupDominator->eraseFromParent();
1848 llvm::Value *outerBegin) {
1850 CodeGenFunction::OpaqueValueMapping binding(CGF, E->
getCommonExpr());
1859 llvm::Value *zero = llvm::ConstantInt::get(CGF.
SizeTy, 0);
1860 llvm::Value *indices[] = {zero, zero};
1861 llvm::Value *begin = Builder.CreateInBoundsGEP(destPtr.
getElementType(),
1863 indices,
"arrayinit.begin");
1878 llvm::BasicBlock *entryBB = Builder.GetInsertBlock();
1883 llvm::PHINode *index =
1884 Builder.CreatePHI(zero->getType(), 2,
"arrayinit.index");
1885 index->addIncoming(zero, entryBB);
1886 llvm::Value *element =
1887 Builder.CreateInBoundsGEP(llvmElementType, begin, index);
1893 if (outerBegin->getType() != element->getType())
1894 outerBegin = Builder.CreateBitCast(outerBegin, element->getType());
1907 CodeGenFunction::RunCleanupsScope CleanupsScope(CGF);
1908 CodeGenFunction::ArrayInitLoopExprScope
Scope(CGF, index);
1910 Address(element, llvmElementType, elementAlign), elementType);
1918 AggExprEmitter(CGF, elementSlot,
false)
1919 .VisitArrayInitLoopExpr(InnerLoop, outerBegin);
1921 EmitInitializationToLValue(E->
getSubExpr(), elementLV);
1925 llvm::Value *nextIndex = Builder.CreateNUWAdd(
1926 index, llvm::ConstantInt::get(CGF.
SizeTy, 1),
"arrayinit.next");
1927 index->addIncoming(nextIndex, Builder.GetInsertBlock());
1930 llvm::Value *done = Builder.CreateICmpEQ(
1931 nextIndex, llvm::ConstantInt::get(CGF.
SizeTy, numElements),
1934 Builder.CreateCondBr(done, endBB, bodyBB);
1947 EmitInitializationToLValue(E->
getBase(), DestLV);
1959 if (
auto *MTE = dyn_cast<MaterializeTemporaryExpr>(E))
1960 E = MTE->getSubExpr();
1970 ILE = dyn_cast<InitListExpr>(ILE->
getInit(0));
1978 if (!RT->isUnionType()) {
1982 unsigned ILEElement = 0;
1983 if (
auto *CXXRD = dyn_cast<CXXRecordDecl>(SD))
1984 while (ILEElement != CXXRD->getNumBases())
1987 for (
const auto *Field : SD->
fields()) {
1990 if (Field->getType()->isIncompleteArrayType() ||
1993 if (Field->isUnnamedBitField())
1999 if (Field->getType()->isReferenceType())
2006 return NumNonZeroBytes;
2012 for (
unsigned i = 0, e = ILE->
getNumInits(); i != e; ++i)
2014 return NumNonZeroBytes;
2031 const CXXRecordDecl *RD = cast<CXXRecordDecl>(RT->getDecl());
2044 if (NumNonZeroBytes*4 > Size)
2048 llvm::Constant *SizeVal = CGF.
Builder.getInt64(Size.getQuantity());
2066 "Invalid aggregate expression to emit");
2068 "slot has bits but no address");
2073 AggExprEmitter(*
this, Slot, Slot.
isIgnored()).Visit(
const_cast<Expr*
>(E));
2119 getContext().getASTRecordLayout(BaseRD).getSize() <=
2138 assert((
Record->hasTrivialCopyConstructor() ||
2139 Record->hasTrivialCopyAssignment() ||
2140 Record->hasTrivialMoveConstructor() ||
2141 Record->hasTrivialMoveAssignment() ||
2142 Record->hasAttr<TrivialABIAttr>() ||
Record->isUnion()) &&
2143 "Trying to aggregate-copy a type without a trivial copy/move "
2144 "constructor or assignment operator");
2153 if (
getTargetHooks().emitCUDADeviceBuiltinSurfaceDeviceCopy(*
this, Dest,
2157 if (
getTargetHooks().emitCUDADeviceBuiltinTextureDeviceCopy(*
this, Dest,
2183 llvm::Value *SizeVal =
nullptr;
2186 if (
auto *VAT = dyn_cast_or_null<VariableArrayType>(
2192 SizeVal =
Builder.CreateNUWMul(
2222 if (
Record->hasObjectMember()) {
2244 Inst->setMetadata(llvm::LLVMContext::MD_tbaa_struct, TBAAStructTag);
Defines the clang::ASTContext interface.
static CharUnits GetNumNonZeroBytesInInit(const Expr *E, CodeGenFunction &CGF)
GetNumNonZeroBytesInInit - Get an approximate count of the number of non-zero bytes that will be stor...
static Expr * findPeephole(Expr *op, CastKind kind, const ASTContext &ctx)
Attempt to look through various unimportant expressions to find a cast of the given kind.
static bool isBlockVarRef(const Expr *E)
Is the value of the given expression possibly a reference to or into a __block variable?
static bool isTrivialFiller(Expr *E)
Determine if E is a trivial array filler, that is, one that is equivalent to zero-initialization.
static bool isSimpleZero(const Expr *E, CodeGenFunction &CGF)
isSimpleZero - If emitting this value will obviously just cause a store of zero to memory,...
static llvm::Value * EmitCompare(CGBuilderTy &Builder, CodeGenFunction &CGF, const BinaryOperator *E, llvm::Value *LHS, llvm::Value *RHS, CompareKind Kind, const char *NameSuffix="")
static bool castPreservesZero(const CastExpr *CE)
Determine whether the given cast kind is known to always convert values with all zero bits in their v...
static void CheckAggExprForMemSetUse(AggValueSlot &Slot, const Expr *E, CodeGenFunction &CGF)
CheckAggExprForMemSetUse - If the initializer is large and has a lot of zeros in it,...
Defines the C++ Decl subclasses, other than those for templates (found in DeclTemplate....
Defines the C++ template declaration subclasses.
llvm::MachO::Record Record
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
const ConstantArrayType * getAsConstantArrayType(QualType T) const
CharUnits getTypeAlignInChars(QualType T) const
Return the ABI-specified alignment of a (complete) type T, in characters.
const ASTRecordLayout & getASTRecordLayout(const RecordDecl *D) const
Get or compute information about the layout of the specified record (struct/union/class) D,...
bool hasSameType(QualType T1, QualType T2) const
Determine whether the given types T1 and T2 are equivalent.
QualType getBaseElementType(const ArrayType *VAT) const
Return the innermost element type of an array type.
ComparisonCategories CompCategories
Types and expressions required to build C++2a three-way comparisons using operator<=>,...
CanQualType getSizeType() const
Return the unique type for "size_t" (C99 7.17), defined in <stddef.h>.
TypeInfoChars getTypeInfoDataSizeInChars(QualType T) const
TypeInfoChars getTypeInfoInChars(const Type *T) const
bool hasSameUnqualifiedType(QualType T1, QualType T2) const
Determine whether the given types are equivalent after cvr-qualifiers have been removed.
const ArrayType * getAsArrayType(QualType T) const
Type Query functions.
CharUnits getTypeSizeInChars(QualType T) const
Return the size of the specified (complete) type T, in characters.
CharUnits toCharUnitsFromBits(int64_t BitSize) const
Convert a size in bits to a size in characters.
unsigned getTargetAddressSpace(LangAS AS) const
ASTRecordLayout - This class contains layout information for one RecordDecl, which is a struct/union/...
uint64_t getFieldOffset(unsigned FieldNo) const
getFieldOffset - Get the offset of the given field index, in bits.
CharUnits getBaseClassOffset(const CXXRecordDecl *Base) const
getBaseClassOffset - Get the offset, in chars, for the given base class.
CharUnits getNonVirtualSize() const
getNonVirtualSize - Get the non-virtual size (in chars) of an object, which is the size of the object...
AbstractConditionalOperator - An abstract base class for ConditionalOperator and BinaryConditionalOpe...
Expr * getCond() const
getCond - Return the expression representing the condition for the ?: operator.
Expr * getTrueExpr() const
getTrueExpr - Return the subexpression representing the value of the expression if the condition eval...
Expr * getFalseExpr() const
getFalseExpr - Return the subexpression representing the value of the expression if the condition eva...
Represents a loop initializing the elements of an array.
llvm::APInt getArraySize() const
OpaqueValueExpr * getCommonExpr() const
Get the common subexpression shared by all initializations (the source array).
Expr * getSubExpr() const
Get the initializer to use for each array element.
ArraySubscriptExpr - [C99 6.5.2.1] Array Subscripting.
Represents an array type, per C99 6.7.5.2 - Array Declarators.
QualType getElementType() const
AtomicExpr - Variadic atomic builtins: __atomic_exchange, __atomic_fetch_*, __atomic_load,...
QualType getValueType() const
Gets the type contained by this atomic type, i.e.
A builtin binary operation expression such as "x + y" or "x <= y".
Represents binding an expression to a temporary.
CXXTemporary * getTemporary()
const Expr * getSubExpr() const
Represents a call to a C++ constructor.
A default argument (C++ [dcl.fct.default]).
A use of a default initializer in a constructor or in aggregate initialization.
Expr * getExpr()
Get the initialization expression that will be used.
Represents a call to an inherited base class constructor from an inheriting constructor.
bool constructsVBase() const
Determine whether this constructor is actually constructing a base class (rather than a complete obje...
CXXConstructorDecl * getConstructor() const
Get the constructor that this expression will call.
bool inheritedFromVBase() const
Determine whether the inherited constructor is inherited from a virtual base of the object we constru...
Represents a list-initialization with parenthesis.
ArrayRef< Expr * > getInitExprs()
FieldDecl * getInitializedFieldInUnion()
Represents a C++ struct/union/class.
bool isTriviallyCopyable() const
Determine whether this class is considered trivially copyable per (C++11 [class]p6).
bool hasUserDeclaredConstructor() const
Determine whether this class has any user-declared constructors.
A rewritten comparison expression that was originally written using operator syntax.
Expr * getSemanticForm()
Get an equivalent semantic form for this expression.
An expression "T()" which creates a value-initialized rvalue of type T, which is a non-class type.
Implicit construction of a std::initializer_list<T> object from an array temporary within list-initia...
A C++ throw-expression (C++ [except.throw]).
A C++ typeid expression (C++ [expr.typeid]), which gets the type_info that corresponds to the supplie...
CallExpr - Represents a function call (C99 6.5.2.2, C++ [expr.call]).
QualType getCallReturnType(const ASTContext &Ctx) const
getCallReturnType - Get the return type of the call expr.
CastExpr - Base class for type casts, including both implicit casts (ImplicitCastExpr) and explicit c...
CastKind getCastKind() const
CharUnits - This is an opaque type for sizes expressed in character units.
llvm::Align getAsAlign() const
getAsAlign - Returns Quantity as a valid llvm::Align, Beware llvm::Align assumes power of two 8-bit b...
QuantityType getQuantity() const
getQuantity - Get the raw integer representation of this quantity.
static CharUnits One()
One - Construct a CharUnits quantity of one.
CharUnits alignmentOfArrayElement(CharUnits elementSize) const
Given that this is the alignment of the first element of an array, return the minimum alignment of an...
static CharUnits fromQuantity(QuantityType Quantity)
fromQuantity - Construct a CharUnits quantity from a raw integer type.
static CharUnits Zero()
Zero - Construct a CharUnits quantity of zero.
ChooseExpr - GNU builtin-in function __builtin_choose_expr.
Expr * getChosenSubExpr() const
getChosenSubExpr - Return the subexpression chosen according to the condition.
Represents a 'co_await' expression.
Like RawAddress, an abstract representation of an aligned address, but the pointer contained in this ...
llvm::Value * emitRawPointer(CodeGenFunction &CGF) const
Return the pointer contained in this class after authenticating it and adding offset to it if necessa...
CharUnits getAlignment() const
llvm::Type * getElementType() const
Return the type of the values stored in this address.
Address withElementType(llvm::Type *ElemTy) const
Return address with different element type, but same pointer and alignment.
llvm::PointerType * getType() const
Return the type of the pointer value.
void setVolatile(bool flag)
static AggValueSlot ignored()
ignored - Returns an aggregate value slot indicating that the aggregate value is being ignored.
Address getAddress() const
CharUnits getPreferredSize(ASTContext &Ctx, QualType Type) const
Get the preferred size to use when storing a value to this slot.
static AggValueSlot forLValue(const LValue &LV, CodeGenFunction &CGF, IsDestructed_t isDestructed, NeedsGCBarriers_t needsGC, IsAliased_t isAliased, Overlap_t mayOverlap, IsZeroed_t isZeroed=IsNotZeroed, IsSanitizerChecked_t isChecked=IsNotSanitizerChecked)
NeedsGCBarriers_t requiresGCollection() const
void setExternallyDestructed(bool destructed=true)
void setZeroed(bool V=true)
IsZeroed_t isZeroed() const
Qualifiers getQualifiers() const
IsAliased_t isPotentiallyAliased() const
static AggValueSlot forAddr(Address addr, Qualifiers quals, IsDestructed_t isDestructed, NeedsGCBarriers_t needsGC, IsAliased_t isAliased, Overlap_t mayOverlap, IsZeroed_t isZeroed=IsNotZeroed, IsSanitizerChecked_t isChecked=IsNotSanitizerChecked)
forAddr - Make a slot for an aggregate value.
IsDestructed_t isExternallyDestructed() const
Overlap_t mayOverlap() const
llvm::Value * emitRawPointer(CodeGenFunction &CGF) const
A scoped helper to set the current debug location to the specified location or preferred location of ...
llvm::CallInst * CreateMemSet(Address Dest, llvm::Value *Value, llvm::Value *Size, bool IsVolatile=false)
Address CreateStructGEP(Address Addr, unsigned Index, const llvm::Twine &Name="")
llvm::CallInst * CreateMemCpy(Address Dest, Address Src, llvm::Value *Size, bool IsVolatile=false)
llvm::LoadInst * CreateAlignedLoad(llvm::Type *Ty, llvm::Value *Addr, CharUnits Align, const llvm::Twine &Name="")
virtual llvm::Value * EmitMemberPointerComparison(CodeGenFunction &CGF, llvm::Value *L, llvm::Value *R, const MemberPointerType *MPT, bool Inequality)
Emit a comparison between two member pointers. Returns an i1.
virtual void EmitGCMemmoveCollectable(CodeGen::CodeGenFunction &CGF, Address DestPtr, Address SrcPtr, llvm::Value *Size)=0
CodeGenFunction - This class organizes the per-function state that is used while generating LLVM code...
void EmitNullInitialization(Address DestPtr, QualType Ty)
EmitNullInitialization - Generate code to set a value of the given type to null, If the type contains...
llvm::Value * EmitLifetimeStart(llvm::TypeSize Size, llvm::Value *Addr)
void DeactivateCleanupBlock(EHScopeStack::stable_iterator Cleanup, llvm::Instruction *DominatingIP)
DeactivateCleanupBlock - Deactivates the given cleanup block.
static TypeEvaluationKind getEvaluationKind(QualType T)
getEvaluationKind - Return the TypeEvaluationKind of QualType T.
void EmitBranchOnBoolExpr(const Expr *Cond, llvm::BasicBlock *TrueBlock, llvm::BasicBlock *FalseBlock, uint64_t TrueCount, Stmt::Likelihood LH=Stmt::LH_None, const Expr *ConditionalOp=nullptr)
EmitBranchOnBoolExpr - Emit a branch on a boolean condition (e.g.
LValue getOrCreateOpaqueLValueMapping(const OpaqueValueExpr *e)
Given an opaque value expression, return its LValue mapping if it exists, otherwise create one.
LValue EmitAggExprToLValue(const Expr *E)
EmitAggExprToLValue - Emit the computation of the specified expression of aggregate type into a tempo...
void EmitLifetimeEnd(llvm::Value *Size, llvm::Value *Addr)
void EmitStoreThroughLValue(RValue Src, LValue Dst, bool isInit=false)
EmitStoreThroughLValue - Store the specified rvalue into the specified lvalue, where both are guarant...
void pushLifetimeExtendedDestroy(CleanupKind kind, Address addr, QualType type, Destroyer *destroyer, bool useEHCleanupForArray)
static bool hasScalarEvaluationKind(QualType T)
void pushIrregularPartialArrayCleanup(llvm::Value *arrayBegin, Address arrayEndPointer, QualType elementType, CharUnits elementAlignment, Destroyer *destroyer)
llvm::Value * emitArrayLength(const ArrayType *arrayType, QualType &baseType, Address &addr)
emitArrayLength - Compute the length of an array, even if it's a VLA, and drill down to the base elem...
AggValueSlot::Overlap_t getOverlapForBaseInit(const CXXRecordDecl *RD, const CXXRecordDecl *BaseRD, bool IsVirtual)
Determine whether a base class initialization may overlap some other object.
LValue EmitLValue(const Expr *E, KnownNonNull_t IsKnownNonNull=NotKnownNonNull)
EmitLValue - Emit code to compute a designator that specifies the location of the expression.
RValue EmitAtomicLoad(LValue LV, SourceLocation SL, AggValueSlot Slot=AggValueSlot::ignored())
bool hasVolatileMember(QualType T)
hasVolatileMember - returns true if aggregate type has a volatile member.
void callCStructCopyAssignmentOperator(LValue Dst, LValue Src)
void callCStructMoveConstructor(LValue Dst, LValue Src)
void callCStructCopyConstructor(LValue Dst, LValue Src)
llvm::BasicBlock * createBasicBlock(const Twine &name="", llvm::Function *parent=nullptr, llvm::BasicBlock *before=nullptr)
createBasicBlock - Create an LLVM basic block.
const LangOptions & getLangOpts() const
LValue EmitLValueForFieldInitialization(LValue Base, const FieldDecl *Field)
EmitLValueForFieldInitialization - Like EmitLValueForField, except that if the Field is a reference,...
void EmitBlock(llvm::BasicBlock *BB, bool IsFinished=false)
EmitBlock - Emit the given block.
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 EmitInheritedCXXConstructorCall(const CXXConstructorDecl *D, bool ForVirtualBase, Address This, bool InheritedFromVBase, const CXXInheritedCtorInitExpr *E)
Emit a call to a constructor inherited from a base class, passing the current constructor's arguments...
RValue EmitObjCMessageExpr(const ObjCMessageExpr *E, ReturnValueSlot Return=ReturnValueSlot())
void EmitIgnoredExpr(const Expr *E)
EmitIgnoredExpr - Emit an expression in a context which ignores the result.
llvm::Type * ConvertTypeForMem(QualType T)
void EmitScalarInit(const Expr *init, const ValueDecl *D, LValue lvalue, bool capturedByInit)
LValue EmitCheckedLValue(const Expr *E, TypeCheckKind TCK)
Same as EmitLValue but additionally we generate checking code to guard against undefined behavior.
RawAddress CreateMemTemp(QualType T, const Twine &Name="tmp", RawAddress *Alloca=nullptr)
CreateMemTemp - Create a temporary memory object of the given type, with appropriate alignmen and cas...
Destroyer * getDestroyer(QualType::DestructionKind destructionKind)
void EmitStoreThroughBitfieldLValue(RValue Src, LValue Dst, llvm::Value **Result=nullptr)
EmitStoreThroughBitfieldLValue - Store Src into Dst with same constraints as EmitStoreThroughLValue.
const TargetInfo & getTarget() const
llvm::Value * getTypeSize(QualType Ty)
Returns calculated size of the specified type.
void EmitComplexExprIntoLValue(const Expr *E, LValue dest, bool isInit)
EmitComplexExprIntoLValue - Emit the given expression of complex type and place its result into the s...
void pushFullExprCleanup(CleanupKind kind, As... A)
pushFullExprCleanup - Push a cleanup to be run at the end of the current full-expression.
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.
AggValueSlot CreateAggTemp(QualType T, const Twine &Name="tmp", RawAddress *Alloca=nullptr)
CreateAggTemp - Create a temporary memory object for the given aggregate type.
RValue EmitCoyieldExpr(const CoyieldExpr &E, AggValueSlot aggSlot=AggValueSlot::ignored(), bool ignoreResult=false)
bool HaveInsertPoint() const
HaveInsertPoint - True if an insertion point is defined.
void ErrorUnsupported(const Stmt *S, const char *Type)
ErrorUnsupported - Print out an error that codegen doesn't support the specified stmt yet.
AggValueSlot::Overlap_t getOverlapForFieldInit(const FieldDecl *FD)
Determine whether a field initialization may overlap some other object.
void EmitAggregateCopy(LValue Dest, LValue Src, QualType EltTy, AggValueSlot::Overlap_t MayOverlap, bool isVolatile=false)
EmitAggregateCopy - Emit an aggregate copy.
const TargetCodeGenInfo & getTargetHooks() const
RValue EmitReferenceBindingToExpr(const Expr *E)
Emits a reference binding to the passed in expression.
void EmitAggExpr(const Expr *E, AggValueSlot AS)
EmitAggExpr - Emit the computation of the specified expression of aggregate type.
Address EmitCompoundStmt(const CompoundStmt &S, bool GetLast=false, AggValueSlot AVS=AggValueSlot::ignored())
void EmitCXXTemporary(const CXXTemporary *Temporary, QualType TempType, Address Ptr)
void EmitAggregateStore(llvm::Value *Val, Address Dest, bool DestIsVolatile)
Build all the stores needed to initialize an aggregate at Dest with the value Val.
RValue EmitPseudoObjectRValue(const PseudoObjectExpr *e, AggValueSlot slot=AggValueSlot::ignored())
ASTContext & getContext() const
void EmitCXXThrowExpr(const CXXThrowExpr *E, bool KeepInsertionPoint=true)
void pushDestroy(QualType::DestructionKind dtorKind, Address addr, QualType type)
Address GetAddressOfDirectBaseInCompleteClass(Address Value, const CXXRecordDecl *Derived, const CXXRecordDecl *Base, bool BaseIsVirtual)
GetAddressOfBaseOfCompleteClass - Convert the given pointer to a complete class to the given direct b...
void callCStructMoveAssignmentOperator(LValue Dst, LValue Src)
bool needsEHCleanup(QualType::DestructionKind kind)
Determines whether an EH cleanup is required to destroy a type with the given destruction kind.
CleanupKind getCleanupKind(QualType::DestructionKind kind)
void EmitCXXConstructExpr(const CXXConstructExpr *E, AggValueSlot Dest)
llvm::Type * ConvertType(QualType T)
Address EmitVAArg(VAArgExpr *VE, Address &VAListAddr)
Generate code to get an argument from the passed in pointer and update it accordingly.
CodeGenTypes & getTypes() const
RValue EmitCoawaitExpr(const CoawaitExpr &E, AggValueSlot aggSlot=AggValueSlot::ignored(), bool ignoreResult=false)
llvm::Value * EmitDynamicCast(Address V, const CXXDynamicCastExpr *DCE)
uint64_t getProfileCount(const Stmt *S)
Get the profiler's count for the given statement.
LValue EmitPseudoObjectLValue(const PseudoObjectExpr *e)
static bool hasAggregateEvaluationKind(QualType T)
LValue MakeAddrLValue(Address Addr, QualType T, AlignmentSource Source=AlignmentSource::Type)
void EmitLambdaVLACapture(const VariableArrayType *VAT, LValue LV)
void EmitAtomicStore(RValue rvalue, LValue lvalue, bool isInit)
RValue EmitCallExpr(const CallExpr *E, ReturnValueSlot ReturnValue=ReturnValueSlot())
llvm::Value * EmitScalarExpr(const Expr *E, bool IgnoreResultAssign=false)
EmitScalarExpr - Emit the computation of the specified expression of LLVM scalar type,...
bool LValueIsSuitableForInlineAtomic(LValue Src)
void incrementProfileCounter(const Stmt *S, llvm::Value *StepV=nullptr)
Increment the profiler's counter for the given statement by StepV.
void pushRegularPartialArrayCleanup(llvm::Value *arrayBegin, llvm::Value *arrayEnd, QualType elementType, CharUnits elementAlignment, Destroyer *destroyer)
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...
RValue EmitAtomicExpr(AtomicExpr *E)
LValue EmitPointerToDataMemberBinaryExpr(const BinaryOperator *E)
This class organizes the cross-function state that is used while generating LLVM code.
void EmitExplicitCastExprType(const ExplicitCastExpr *E, CodeGenFunction *CGF=nullptr)
Emit type info if type of an expression is a variably modified type.
llvm::MDNode * getTBAAStructInfo(QualType QTy)
llvm::Module & getModule() const
bool isPaddedAtomicType(QualType type)
void ErrorUnsupported(const Stmt *S, const char *Type)
Print out an error that codegen doesn't support the specified stmt yet.
TBAAAccessInfo mergeTBAAInfoForMemoryTransfer(TBAAAccessInfo DestInfo, TBAAAccessInfo SrcInfo)
mergeTBAAInfoForMemoryTransfer - Get merged TBAA information for the purposes of memory transfer call...
const LangOptions & getLangOpts() const
const llvm::DataLayout & getDataLayout() const
CGCXXABI & getCXXABI() const
void DecorateInstructionWithTBAA(llvm::Instruction *Inst, TBAAAccessInfo TBAAInfo)
DecorateInstructionWithTBAA - Decorate the instruction with a TBAA tag.
ASTContext & getContext() const
const CodeGenOptions & getCodeGenOpts() const
CGObjCRuntime & getObjCRuntime()
Return a reference to the configured Objective-C runtime.
llvm::Constant * EmitNullConstant(QualType T)
Return the result of value-initializing the given type, i.e.
bool isPointerZeroInitializable(QualType T)
Check if the pointer type can be zero-initialized (in the C++ sense) with an LLVM zeroinitializer.
bool isZeroInitializable(QualType T)
IsZeroInitializable - Return whether a type can be zero-initialized (in the C++ sense) with an LLVM z...
A saved depth on the scope stack.
stable_iterator stable_begin() const
Create a stable reference to the top of the EH stack.
LValue - This represents an lvalue references.
Address getAddress(CodeGenFunction &CGF) const
llvm::Value * emitRawPointer(CodeGenFunction &CGF) const
TBAAAccessInfo getTBAAInfo() const
void setNonGC(bool Value)
RValue - This trivial value class is used to represent the result of an expression that is evaluated.
llvm::Value * getAggregatePointer(QualType PointeeType, CodeGenFunction &CGF) const
static RValue get(llvm::Value *V)
static RValue getAggregate(Address addr, bool isVolatile=false)
Convert an Address to an RValue.
Address getAggregateAddress() const
getAggregateAddr() - Return the Value* of the address of the aggregate.
llvm::Value * getScalarVal() const
getScalarVal() - Return the Value* of this scalar value.
std::pair< llvm::Value *, llvm::Value * > getComplexVal() const
getComplexVal - Return the real/imag components of this complex value.
An abstract representation of an aligned address.
llvm::Value * getPointer() const
static RawAddress invalid()
ReturnValueSlot - Contains the address where the return value of a function can be stored,...
const ComparisonCategoryInfo & getInfoForType(QualType Ty) const
Return the comparison category information as specified by getCategoryForType(Ty).
bool isPartial() const
True iff the comparison is not totally ordered.
const ValueInfo * getLess() const
const ValueInfo * getUnordered() const
const CXXRecordDecl * Record
The declaration for the comparison category type from the standard library.
const ValueInfo * getGreater() const
const ValueInfo * getEqualOrEquiv() const
Complex values, per C99 6.2.5p11.
CompoundLiteralExpr - [C99 6.5.2.5].
const Expr * getInitializer() const
Represents the canonical version of C arrays with a specified constant size.
ConstantExpr - An expression that occurs in a constant context and optionally the result of evaluatin...
Represents a 'co_yield' expression.
specific_decl_iterator - Iterates over a subrange of declarations stored in a DeclContext,...
A reference to a declared variable, function, enum, etc.
InitListExpr * getUpdater() const
Represents an expression – generally a full-expression – that introduces cleanups to be run at the en...
This represents one expression.
Expr * IgnoreParenNoopCasts(const ASTContext &Ctx) LLVM_READONLY
Skip past any parentheses and casts which do not change the value (including ptr->int casts of the sa...
Expr * IgnoreParens() LLVM_READONLY
Skip past any parentheses which might surround this expression until reaching a fixed point.
bool HasSideEffects(const ASTContext &Ctx, bool IncludePossibleEffects=true) const
HasSideEffects - This routine returns true for all those expressions which have any effect other than...
SourceLocation getExprLoc() const LLVM_READONLY
getExprLoc - Return the preferred location for the arrow when diagnosing a problem with a generic exp...
Represents a member of a struct/union/class.
unsigned getFieldIndex() const
Returns the index of this field within its record, as appropriate for passing to ASTRecordLayout::get...
const RecordDecl * getParent() const
Returns the parent of this field declaration, which is the struct in which this field is defined.
const Expr * getSubExpr() const
Represents a C11 generic selection.
Represents an implicitly-generated value initialization of an object of a given type.
Describes an C or C++ initializer list.
bool isTransparent() const
Is this a transparent initializer list (that is, an InitListExpr that is purely syntactic,...
FieldDecl * getInitializedFieldInUnion()
If this initializes a union, specifies which field in the union to initialize.
unsigned getNumInits() const
bool hadArrayRangeDesignator() const
Expr * getArrayFiller()
If this initializer list initializes an array with more elements than there are initializers in the l...
const Expr * getInit(unsigned Init) const
ArrayRef< Expr * > inits()
A C++ lambda expression, which produces a function object (of unspecified type) that can be invoked l...
capture_init_iterator capture_init_end()
Retrieve the iterator pointing one past the last initialization argument for this lambda expression.
Expr *const * const_capture_init_iterator
Const iterator that walks over the capture initialization arguments.
capture_init_iterator capture_init_begin()
Retrieve the first initialization argument for this lambda expression (which initializes the first ca...
CXXRecordDecl * getLambdaClass() const
Retrieve the class that corresponds to the lambda.
Represents a prvalue temporary that is written into memory so that a reference can bind to it.
Expr * getSubExpr() const
Retrieve the temporary-generating subexpression whose value will be materialized into a glvalue.
MemberExpr - [C99 6.5.2.3] Structure and Union Members.
A pointer to member type per C++ 8.3.3 - Pointers to members.
Represents a place-holder for an object not to be initialized by anything.
ObjCIvarRefExpr - A reference to an ObjC instance variable.
An expression that sends a message to the given Objective-C object or class.
OpaqueValueExpr - An expression referring to an opaque object of a fixed type and value class.
Expr * getSourceExpr() const
The source expression of an opaque value expression is the expression which originally generated the ...
Expr * getSelectedExpr() const
ParenExpr - This represents a parethesized expression, e.g.
const Expr * getSubExpr() const
[C99 6.4.2.2] - A predefined identifier such as func.
PseudoObjectExpr - An expression which accesses a pseudo-object l-value.
A (possibly-)qualified type.
bool isVolatileQualified() const
Determine whether this type is volatile-qualified.
bool isTriviallyCopyableType(const ASTContext &Context) const
Return true if this is a trivially copyable type (C++0x [basic.types]p9)
LangAS getAddressSpace() const
Return the address space of this type.
DestructionKind isDestructedType() const
Returns a nonzero value if objects of this type require non-trivial work to clean up after.
bool isPODType(const ASTContext &Context) const
Determine whether this is a Plain Old Data (POD) type (C++ 3.9p10).
@ PCK_Struct
The type is a struct containing a field whose type is neither PCK_Trivial nor PCK_VolatileTrivial.
The collection of all-type qualifiers we support.
Represents a struct/union/class.
bool hasObjectMember() const
field_range fields() const
field_iterator field_begin() const
A helper class that allows the use of isa/cast/dyncast to detect TagType objects of structs/unions/cl...
RecordDecl * getDecl() const
Scope - A scope is a transient data structure that is used while parsing the program.
StmtExpr - This is the GNU Statement Expression extension: ({int X=4; X;}).
CompoundStmt * getSubStmt()
RetTy Visit(PTR(Stmt) S, ParamTys... P)
StmtVisitor - This class implements a simple visitor for Stmt subclasses.
Stmt - This represents one statement.
StringLiteral - This represents a string literal expression, e.g.
Represents a reference to a non-type template parameter that has been substituted with a template arg...
Expr * getReplacement() const
uint64_t getPointerWidth(LangAS AddrSpace) const
Return the width of pointers on this target, for the specified address space.
bool isConstantArrayType() const
bool isPointerType() const
const T * castAs() const
Member-template castAs<specific type>.
bool isReferenceType() const
bool isVariableArrayType() const
bool isCUDADeviceBuiltinSurfaceType() const
Check if the type is the CUDA device builtin surface type.
bool isIntegralOrEnumerationType() const
Determine whether this type is an integral or enumeration type.
bool isAnyComplexType() const
bool hasSignedIntegerRepresentation() const
Determine whether this type has an signed integer representation of some sort, e.g....
bool isMemberPointerType() const
bool isAtomicType() const
bool isCUDADeviceBuiltinTextureType() const
Check if the type is the CUDA device builtin texture type.
bool hasFloatingRepresentation() const
Determine whether this type has a floating-point representation of some sort, e.g....
bool isRealFloatingType() const
Floating point categories.
const T * getAs() const
Member-template getAs<specific type>'.
bool isNullPtrType() const
bool isRecordType() const
UnaryOperator - This represents the unary-expression's (except sizeof and alignof),...
Expr * getSubExpr() const
Represents a call to the builtin function __builtin_va_arg.
Represents a variable declaration or definition.
@ EHCleanup
Denotes a cleanup that should run when a scope is exited using exceptional control flow (a throw stat...
const internal::VariadicAllOfMatcher< Type > type
Matches Types in the clang AST.
const AstTypeMatcher< AtomicType > atomicType
Matches atomic types.
bool Zero(InterpState &S, CodePtr OpPC)
bool GE(InterpState &S, CodePtr OpPC)
The JSON file list parser is used to communicate input to InstallAPI.
LangAS
Defines the address space values used by the address space qualifier of QualType.
CastKind
CastKind - The kind of operation required for a conversion.
ExprValueKind
The categorization of expression values, currently following the C++11 scheme.
const FunctionProtoType * T
U cast(CodeGen::Address addr)
Diagnostic wrappers for TextAPI types for error reporting.
cl::opt< bool > EnableSingleByteCoverage
llvm::IntegerType * Int8Ty
i8, i16, i32, and i64
llvm::IntegerType * SizeTy
llvm::PointerType * Int8PtrTy
llvm::IntegerType * PtrDiffTy
CharUnits getPointerAlign() const