21 #include "llvm/IR/Constants.h"
22 #include "llvm/IR/Function.h"
23 #include "llvm/IR/GlobalVariable.h"
24 #include "llvm/IR/Intrinsics.h"
25 using namespace clang;
26 using namespace CodeGen;
33 class AggExprEmitter :
public StmtVisitor<AggExprEmitter> {
44 bool shouldUseDestForReturnSlot()
const {
45 return !(Dest.requiresGCollection() || Dest.isPotentiallyAliased());
49 if (!shouldUseDestForReturnSlot())
57 if (!Dest.isIgnored())
return Dest;
58 return CGF.CreateAggTemp(T,
"agg.tmp.ensured");
61 if (!Dest.isIgnored())
return;
62 Dest = CGF.CreateAggTemp(T,
"agg.tmp.ensured");
68 IsResultUnused(IsResultUnused) { }
77 void EmitAggLoadOfLValue(
const Expr *
E);
85 void EmitMoveFromReturnSlot(
const Expr *
E,
RValue Src);
87 void EmitArrayInit(
Address DestPtr, llvm::ArrayType *AType,
91 if (CGF.getLangOpts().getGC() && TypeRequiresGCollection(T))
96 bool TypeRequiresGCollection(
QualType T);
102 void Visit(
Expr *
E) {
107 void VisitStmt(
Stmt *
S) {
108 CGF.ErrorUnsupported(S,
"aggregate expression");
129 = CGF.tryEmitAsConstant(E)) {
130 EmitFinalDestCopy(E->
getType(), result.getReferenceLValue(CGF, E));
135 EmitAggLoadOfLValue(E);
138 void VisitMemberExpr(
MemberExpr *ME) { EmitAggLoadOfLValue(ME); }
139 void VisitUnaryDeref(
UnaryOperator *E) { EmitAggLoadOfLValue(E); }
140 void VisitStringLiteral(
StringLiteral *E) { EmitAggLoadOfLValue(E); }
143 EmitAggLoadOfLValue(E);
146 EmitAggLoadOfLValue(E);
151 void VisitCallExpr(
const CallExpr *E);
152 void VisitStmtExpr(
const StmtExpr *E);
154 void VisitPointerToDataMemberBinaryOperator(
const BinaryOperator *BO);
160 EmitAggLoadOfLValue(E);
182 void VisitCXXTypeidExpr(
CXXTypeidExpr *E) { EmitAggLoadOfLValue(E); }
188 LValue LV = CGF.EmitPseudoObjectLValue(E);
189 return EmitFinalDestCopy(E->
getType(), LV);
192 CGF.EmitPseudoObjectRValue(E, EnsureSlot(E->
getType()));
200 void VisitCXXThrowExpr(
const CXXThrowExpr *E) { CGF.EmitCXXThrowExpr(E); }
202 RValue Res = CGF.EmitAtomicExpr(E);
203 EmitFinalDestCopy(E->
getType(), Res);
215 void AggExprEmitter::EmitAggLoadOfLValue(
const Expr *E) {
216 LValue LV = CGF.EmitLValue(E);
220 CGF.EmitAtomicLoad(LV, E->
getExprLoc(), Dest);
224 EmitFinalDestCopy(E->
getType(), LV);
228 bool AggExprEmitter::TypeRequiresGCollection(
QualType T) {
231 if (!RecordTy)
return false;
235 if (isa<CXXRecordDecl>(Record) &&
236 (cast<CXXRecordDecl>(Record)->hasNonTrivialCopyConstructor() ||
237 !cast<CXXRecordDecl>(Record)->hasTrivialDestructor()))
254 void AggExprEmitter::EmitMoveFromReturnSlot(
const Expr *E,
RValue src) {
255 if (shouldUseDestForReturnSlot()) {
264 EmitFinalDestCopy(E->
getType(), src);
269 assert(src.
isAggregate() &&
"value must be aggregate value!");
271 EmitFinalDestCopy(type, srcLV);
275 void AggExprEmitter::EmitFinalDestCopy(
QualType type,
const LValue &src) {
280 if (Dest.isIgnored())
286 EmitCopy(type, Dest, srcAgg);
296 CharUnits sz = CGF.getContext().getTypeSizeInChars(type);
298 CGF.CGM.getObjCRuntime().EmitGCMemmoveCollectable(CGF,
320 assert(Array.
isSimple() &&
"initializer_list array not a simple lvalue");
325 assert(ArrayType &&
"std::initializer_list constructed from non-array");
331 CGF.ErrorUnsupported(E,
"weird std::initializer_list");
336 if (!Field->getType()->isPointerType() ||
337 !Ctx.
hasSameType(Field->getType()->getPointeeType(),
339 CGF.ErrorUnsupported(E,
"weird std::initializer_list");
345 LValue Start = CGF.EmitLValueForFieldInitialization(DestLV, *Field);
346 llvm::Value *Zero = llvm::ConstantInt::get(CGF.PtrDiffTy, 0);
349 Builder.CreateInBoundsGEP(ArrayPtr.getPointer(), IdxStart,
"arraystart");
350 CGF.EmitStoreThroughLValue(
RValue::get(ArrayStart), Start);
354 CGF.ErrorUnsupported(E,
"weird std::initializer_list");
359 LValue EndOrLength = CGF.EmitLValueForFieldInitialization(DestLV, *Field);
360 if (Field->getType()->isPointerType() &&
361 Ctx.
hasSameType(Field->getType()->getPointeeType(),
366 Builder.CreateInBoundsGEP(ArrayPtr.getPointer(), IdxEnd,
"arrayend");
367 CGF.EmitStoreThroughLValue(
RValue::get(ArrayEnd), EndOrLength);
370 CGF.EmitStoreThroughLValue(
RValue::get(Size), EndOrLength);
372 CGF.ErrorUnsupported(E,
"weird std::initializer_list");
383 if (isa<ImplicitValueInitExpr>(E))
386 if (
auto *ILE = dyn_cast<InitListExpr>(E)) {
387 if (ILE->getNumInits())
392 if (
auto *Cons = dyn_cast_or_null<CXXConstructExpr>(E))
393 return Cons->getConstructor()->isDefaultConstructor() &&
394 Cons->getConstructor()->isTrivial();
401 void AggExprEmitter::EmitArrayInit(
Address DestPtr, llvm::ArrayType *AType,
405 uint64_t NumArrayElements = AType->getNumElements();
406 assert(NumInitElements <= NumArrayElements);
410 llvm::Value *zero = llvm::ConstantInt::get(CGF.SizeTy, 0);
415 CharUnits elementSize = CGF.getContext().getTypeSizeInChars(elementType);
425 llvm::Instruction *cleanupDominator =
nullptr;
426 if (CGF.needsEHCleanup(dtorKind)) {
431 endOfInit = CGF.CreateTempAlloca(begin->getType(), CGF.getPointerAlign(),
432 "arrayinit.endOfInit");
433 cleanupDominator =
Builder.CreateStore(begin, endOfInit);
434 CGF.pushIrregularPartialArrayCleanup(begin, endOfInit, elementType,
436 CGF.getDestroyer(dtorKind));
437 cleanup = CGF.EHStack.stable_begin();
444 llvm::Value *one = llvm::ConstantInt::get(CGF.SizeTy, 1);
454 for (uint64_t i = 0; i != NumInitElements; ++i) {
457 element =
Builder.CreateInBoundsGEP(element, one,
"arrayinit.element");
466 CGF.MakeAddrLValue(
Address(element, elementAlign), elementType);
467 EmitInitializationToLValue(E->
getInit(i), elementLV);
477 if (NumInitElements != NumArrayElements &&
478 !(Dest.
isZeroed() && hasTrivialFiller &&
479 CGF.getTypes().isZeroInitializable(elementType))) {
485 if (NumInitElements) {
486 element =
Builder.CreateInBoundsGEP(element, one,
"arrayinit.start");
492 llvm::ConstantInt::get(CGF.SizeTy, NumArrayElements),
495 llvm::BasicBlock *entryBB =
Builder.GetInsertBlock();
496 llvm::BasicBlock *bodyBB = CGF.createBasicBlock(
"arrayinit.body");
499 CGF.EmitBlock(bodyBB);
500 llvm::PHINode *currentElement =
501 Builder.CreatePHI(element->getType(), 2,
"arrayinit.cur");
502 currentElement->addIncoming(element, entryBB);
506 CGF.MakeAddrLValue(
Address(currentElement, elementAlign), elementType);
508 EmitInitializationToLValue(filler, elementLV);
510 EmitNullInitializationToLValue(elementLV);
514 Builder.CreateInBoundsGEP(currentElement, one,
"arrayinit.next");
517 if (endOfInit.
isValid())
Builder.CreateStore(nextElement, endOfInit);
522 llvm::BasicBlock *endBB = CGF.createBasicBlock(
"arrayinit.end");
523 Builder.CreateCondBr(done, endBB, bodyBB);
524 currentElement->addIncoming(nextElement,
Builder.GetInsertBlock());
526 CGF.EmitBlock(endBB);
530 if (dtorKind) CGF.DeactivateCleanupBlock(cleanup, cleanupDominator);
542 EmitFinalDestCopy(e->
getType(), CGF.getOpaqueLValueMapping(e));
551 EmitAggLoadOfLValue(E);
564 if (
CastExpr *castE = dyn_cast<CastExpr>(op)) {
565 if (castE->getCastKind() ==
kind)
566 return castE->getSubExpr();
567 if (castE->getCastKind() ==
CK_NoOp)
574 void AggExprEmitter::VisitCastExpr(
CastExpr *E) {
575 if (
const auto *ECE = dyn_cast<ExplicitCastExpr>(E))
576 CGF.CGM.EmitExplicitCastExprType(ECE, &CGF);
580 assert(isa<CXXDynamicCastExpr>(E) &&
"CK_Dynamic without a dynamic_cast?");
585 CGF.EmitDynamicCast(LV.
getAddress(), cast<CXXDynamicCastExpr>(
E));
587 CGF.CGM.ErrorUnsupported(E,
"non-simple lvalue dynamic_cast");
590 CGF.CGM.ErrorUnsupported(E,
"lvalue dynamic_cast with a destination");
607 CGF.MakeAddrLValue(CastPtr, Ty));
614 llvm_unreachable(
"cannot perform hierarchy conversion in EmitAggExpr: "
615 "should have been unpacked before we got here");
625 if (isToAtomic) std::swap(atomicType, valueType);
628 assert(CGF.getContext().hasSameUnqualifiedType(valueType,
633 if (Dest.
isIgnored() || !CGF.CGM.isPaddedAtomicType(atomicType)) {
642 assert(CGF.getContext().hasSameUnqualifiedType(op->getType(),
644 "peephole significantly changed types?");
652 if (!valueDest.
isIgnored() && CGF.CGM.isPaddedAtomicType(atomicType)) {
656 CGF.EmitNullInitialization(Dest.
getAddress(), atomicType);
660 CGF.Builder.CreateStructGEP(valueDest.
getAddress(), 0,
677 CGF.CreateAggTemp(atomicType,
"atomic-to-nonatomic.temp");
683 return EmitFinalDestCopy(valueType, rvalue);
701 "Implicit cast types must be compatible");
706 llvm_unreachable(
"should not be emitting lvalue bitcast as rvalue");
752 llvm_unreachable(
"cast kind invalid for aggregate types");
756 void AggExprEmitter::VisitCallExpr(
const CallExpr *E) {
758 EmitAggLoadOfLValue(E);
762 RValue RV = CGF.EmitCallExpr(E, getReturnValueSlot());
763 EmitMoveFromReturnSlot(E, RV);
767 RValue RV = CGF.EmitObjCMessageExpr(E, getReturnValueSlot());
768 EmitMoveFromReturnSlot(E, RV);
772 CGF.EmitIgnoredExpr(E->
getLHS());
776 void AggExprEmitter::VisitStmtExpr(
const StmtExpr *E) {
778 CGF.EmitCompoundStmt(*E->
getSubStmt(),
true, Dest);
781 void AggExprEmitter::VisitBinaryOperator(
const BinaryOperator *E) {
783 VisitPointerToDataMemberBinaryOperator(E);
785 CGF.ErrorUnsupported(E,
"aggregate binary expression");
788 void AggExprEmitter::VisitPointerToDataMemberBinaryOperator(
790 LValue LV = CGF.EmitPointerToDataMemberBinaryExpr(E);
791 EmitFinalDestCopy(E->
getType(), LV);
801 if (
const DeclRefExpr *DRE = dyn_cast<DeclRefExpr>(E)) {
803 return (var && var->
hasAttr<BlocksAttr>());
812 if (op->isAssignmentOp() || op->isPtrMemOp())
824 = dyn_cast<AbstractConditionalOperator>(E)) {
830 = dyn_cast<OpaqueValueExpr>(E)) {
831 if (
const Expr *src = op->getSourceExpr())
838 }
else if (
const CastExpr *
cast = dyn_cast<CastExpr>(E)) {
845 }
else if (
const UnaryOperator *uop = dyn_cast<UnaryOperator>(E)) {
849 }
else if (
const MemberExpr *mem = dyn_cast<MemberExpr>(E)) {
863 assert(CGF.getContext().hasSameUnqualifiedType(E->
getLHS()->
getType(),
865 &&
"Invalid assignment");
881 if (LHS.getType()->isAtomicType() ||
882 CGF.LValueIsSuitableForInlineAtomic(LHS)) {
883 CGF.EmitAtomicStore(Dest.
asRValue(), LHS,
false);
900 CGF.LValueIsSuitableForInlineAtomic(LHS)) {
903 CGF.EmitAtomicStore(Dest.
asRValue(), LHS,
false);
917 CGF.EmitAggExpr(E->
getRHS(), LHSSlot);
920 EmitFinalDestCopy(E->
getType(), LHS);
923 void AggExprEmitter::
925 llvm::BasicBlock *LHSBlock = CGF.createBasicBlock(
"cond.true");
926 llvm::BasicBlock *RHSBlock = CGF.createBasicBlock(
"cond.false");
927 llvm::BasicBlock *ContBlock = CGF.createBasicBlock(
"cond.end");
933 CGF.EmitBranchOnBoolExpr(E->
getCond(), LHSBlock, RHSBlock,
934 CGF.getProfileCount(E));
940 CGF.EmitBlock(LHSBlock);
941 CGF.incrementProfileCounter(E);
945 assert(CGF.HaveInsertPoint() &&
"expression evaluation ended with no IP!");
946 CGF.Builder.CreateBr(ContBlock);
955 CGF.EmitBlock(RHSBlock);
959 CGF.EmitBlock(ContBlock);
962 void AggExprEmitter::VisitChooseExpr(
const ChooseExpr *CE) {
966 void AggExprEmitter::VisitVAArgExpr(
VAArgExpr *VE) {
968 Address ArgPtr = CGF.EmitVAArg(VE, ArgValue);
973 CGF.ConvertType(VE->
getType()));
979 EmitFinalDestCopy(VE->
getType(), CGF.MakeAddrLValue(ArgPtr, VE->
getType()));
994 if (!wasExternallyDestructed)
1001 CGF.EmitCXXConstructExpr(E, Slot);
1005 AggExprEmitter::VisitLambdaExpr(
LambdaExpr *E) {
1007 CGF.EmitLambdaExpr(E, Slot);
1011 CGF.enterFullExpression(E);
1019 EmitNullInitializationToLValue(CGF.MakeAddrLValue(Slot.
getAddress(), T));
1025 EmitNullInitializationToLValue(CGF.MakeAddrLValue(Slot.
getAddress(), T));
1036 return IL->getValue() == 0;
1039 return FL->getValue().isPosZero();
1041 if ((isa<ImplicitValueInitExpr>(E) || isa<CXXScalarValueInitExpr>(E)) &&
1045 if (
const CastExpr *ICE = dyn_cast<CastExpr>(E))
1049 return CL->getValue() == 0;
1057 AggExprEmitter::EmitInitializationToLValue(
Expr *E,
LValue LV) {
1064 }
else if (isa<ImplicitValueInitExpr>(E) || isa<CXXScalarValueInitExpr>(
E)) {
1065 return EmitNullInitializationToLValue(LV);
1066 }
else if (isa<NoInitExpr>(E)) {
1070 RValue RV = CGF.EmitReferenceBindingToExpr(E);
1071 return CGF.EmitStoreThroughLValue(RV, LV);
1074 switch (CGF.getEvaluationKind(type)) {
1076 CGF.EmitComplexExprIntoLValue(E, LV,
true);
1087 CGF.EmitScalarInit(E,
nullptr, LV,
false);
1089 CGF.EmitStoreThroughLValue(
RValue::get(CGF.EmitScalarExpr(E)), LV);
1093 llvm_unreachable(
"bad evaluation kind");
1096 void AggExprEmitter::EmitNullInitializationToLValue(
LValue lv) {
1101 if (Dest.
isZeroed() && CGF.getTypes().isZeroInitializable(type))
1104 if (CGF.hasScalarEvaluationKind(type)) {
1106 llvm::Value *null = CGF.CGM.EmitNullConstant(type);
1110 CGF.EmitStoreThroughBitfieldLValue(
RValue::get(null), lv);
1113 CGF.EmitStoreOfScalar(null, lv,
true);
1123 void AggExprEmitter::VisitInitListExpr(
InitListExpr *E) {
1130 if (llvm::Constant*
C = CGF.CGM.EmitConstantExpr(E, E->
getType(), &CGF)) {
1131 llvm::GlobalVariable* GV =
1132 new llvm::GlobalVariable(CGF.CGM.getModule(),
C->getType(),
true,
1134 EmitFinalDestCopy(E->
getType(), CGF.MakeAddrLValue(GV, E->
getType()));
1139 CGF.ErrorUnsupported(E,
"GNU array range designator extension");
1154 EmitArrayInit(Dest.
getAddress(), AType, elementType,
E);
1162 CGF.getContext().hasSameUnqualifiedType(E->
getInit(0)->
getType(),
1164 "unexpected list initialization for atomic object");
1189 for (
const auto *Field : record->
fields())
1190 assert(Field->isUnnamedBitfield() &&
"Only unnamed bitfields allowed");
1198 LValue FieldLoc = CGF.EmitLValueForFieldInitialization(DestLV, Field);
1199 if (NumInitElements) {
1201 EmitInitializationToLValue(E->
getInit(0), FieldLoc);
1204 EmitNullInitializationToLValue(FieldLoc);
1213 llvm::Instruction *cleanupDominator =
nullptr;
1217 unsigned curInitIndex = 0;
1218 for (
const auto *field : record->
fields()) {
1220 if (field->getType()->isIncompleteArrayType())
1224 if (field->isUnnamedBitfield())
1230 if (curInitIndex == NumInitElements && Dest.
isZeroed() &&
1231 CGF.getTypes().isZeroInitializable(E->
getType()))
1235 LValue LV = CGF.EmitLValueForFieldInitialization(DestLV, field);
1239 if (curInitIndex < NumInitElements) {
1241 EmitInitializationToLValue(E->
getInit(curInitIndex++), LV);
1244 EmitNullInitializationToLValue(LV);
1250 bool pushedCleanup =
false;
1252 = field->getType().isDestructedType()) {
1254 if (CGF.needsEHCleanup(dtorKind)) {
1255 if (!cleanupDominator)
1256 cleanupDominator = CGF.Builder.CreateAlignedLoad(
1258 llvm::Constant::getNullValue(CGF.Int8PtrTy),
1262 CGF.getDestroyer(dtorKind),
false);
1263 cleanups.push_back(CGF.EHStack.stable_begin());
1264 pushedCleanup =
true;
1270 if (!pushedCleanup && LV.
isSimple())
1271 if (llvm::GetElementPtrInst *GEP =
1272 dyn_cast<llvm::GetElementPtrInst>(LV.
getPointer()))
1273 if (GEP->use_empty())
1274 GEP->eraseFromParent();
1279 for (
unsigned i = cleanups.size(); i != 0; --i)
1280 CGF.DeactivateCleanupBlock(cleanups[i-1], cleanupDominator);
1283 if (cleanupDominator)
1284 cleanupDominator->eraseFromParent();
1291 EmitInitializationToLValue(E->
getBase(), DestLV);
1318 if (!RT->isUnionType()) {
1322 unsigned ILEElement = 0;
1323 for (
const auto *Field : SD->
fields()) {
1342 return NumNonZeroBytes;
1348 for (
unsigned i = 0, e = ILE->
getNumInits(); i != e; ++i)
1350 return NumNonZeroBytes;
1367 const CXXRecordDecl *RD = cast<CXXRecordDecl>(RT->getDecl());
1380 if (NumNonZeroBytes*4 > Size)
1403 "Invalid aggregate expression to emit");
1405 "slot has bits but no address");
1410 AggExprEmitter(*
this, Slot, Slot.
isIgnored()).Visit(const_cast<Expr*>(E));
1426 bool isAssignment) {
1437 "Trying to aggregate-copy a type without a trivial copy/move "
1438 "constructor or assignment operator");
1460 std::pair<CharUnits, CharUnits>
TypeInfo;
1467 if (TypeInfo.first.isZero()) {
1469 if (
auto *VAT = dyn_cast_or_null<VariableArrayType>(
1474 std::pair<CharUnits, CharUnits> LastElementTypeInfo;
1477 assert(!TypeInfo.first.isZero());
1478 SizeVal =
Builder.CreateNUWMul(
1480 llvm::ConstantInt::get(
SizeTy, TypeInfo.first.getQuantity()));
1481 if (!isAssignment) {
1482 SizeVal =
Builder.CreateNUWSub(
1484 llvm::ConstantInt::get(
SizeTy, TypeInfo.first.getQuantity()));
1485 SizeVal =
Builder.CreateNUWAdd(
1486 SizeVal, llvm::ConstantInt::get(
1487 SizeTy, LastElementTypeInfo.first.getQuantity()));
1492 SizeVal = llvm::ConstantInt::get(
SizeTy, TypeInfo.first.getQuantity());
1538 Inst->setMetadata(llvm::LLVMContext::MD_tbaa_struct, TBAAStructTag);
ReturnValueSlot - Contains the address where the return value of a function can be stored...
Defines the clang::ASTContext interface.
unsigned getNumInits() const
CastKind getCastKind() const
CK_LValueToRValue - A conversion which causes the extraction of an r-value from the operand gl-value...
A (possibly-)qualified type.
llvm::Value * getPointer() const
DestructionKind isDestructedType() const
Returns a nonzero value if objects of this type require non-trivial work to clean up after...
CompoundStmt * getSubStmt()
static AggValueSlot forLValue(const LValue &LV, IsDestructed_t isDestructed, NeedsGCBarriers_t needsGC, IsAliased_t isAliased, IsZeroed_t isZeroed=IsNotZeroed)
const TargetInfo & getTarget() const
CanQualType getSizeType() const
Return the unique type for "size_t" (C99 7.17), defined in <stddef.h>.
Expr * GetTemporaryExpr() const
Retrieve the temporary-generating subexpression whose value will be materialized into a glvalue...
QuantityType getQuantity() const
getQuantity - Get the raw integer representation of this quantity.
bool isRecordType() const
virtual void EmitGCMemmoveCollectable(CodeGen::CodeGenFunction &CGF, Address DestPtr, Address SrcPtr, llvm::Value *Size)=0
CK_ToUnion - The GCC cast-to-union extension.
llvm::MDNode * getTBAAStructInfo(QualType QTy)
Address getAddress() const
Defines the C++ template declaration subclasses.
ParenExpr - This represents a parethesized expression, e.g.
CK_BaseToDerivedMemberPointer - Member pointer in base class to member pointer in derived class...
Represents an array type, per C99 6.7.5.2 - Array Declarators.
const Expr * getResultExpr() const
The generic selection's result expression.
Represents a call to a C++ constructor.
CK_FloatingToIntegral - Floating point to integral.
void setZeroed(bool V=true)
const LangOptions & getLangOpts() const
[ARC] Consumes a retainable object pointer that has just been produced, e.g.
llvm::IntegerType * Int8Ty
i8, i16, i32, and i64
bool HasSideEffects(const ASTContext &Ctx, bool IncludePossibleEffects=true) const
HasSideEffects - This routine returns true for all those expressions which have any effect other than...
Represents a prvalue temporary that is written into memory so that a reference can bind to it...
const llvm::APInt & getSize() const
CK_IntegralToFloating - Integral to floating point.
bool hadArrayRangeDesignator() const
static bool isBlockVarRef(const Expr *E)
Is the value of the given expression possibly a reference to or into a __block variable?
static Expr * findPeephole(Expr *op, CastKind kind)
Attempt to look through various unimportant expressions to find a cast of the given kind...
VarDecl - An instance of this class is created to represent a variable declaration or definition...
CK_IntegralCast - A cast between integral types (other than to boolean).
llvm::Type * getElementType() const
Return the type of the values stored in this address.
CompoundLiteralExpr - [C99 6.5.2.5].
static bool isSimpleZero(const Expr *E, CodeGenFunction &CGF)
isSimpleZero - If emitting this value will obviously just cause a store of zero to memory...
field_iterator field_begin() const
CK_Dynamic - A C++ dynamic_cast.
Implicit construction of a std::initializer_list<T> object from an array temporary within list-initia...
CK_Dependent - A conversion which cannot yet be analyzed because either the expression or target type...
IsZeroed_t isZeroed() const
A C++ throw-expression (C++ [except.throw]).
Represents an expression – generally a full-expression – that introduces cleanups to be run at the en...
bool hasTrivialCopyConstructor() const
Determine whether this class has a trivial copy constructor (C++ [class.copy]p6, C++11 [class...
static CharUnits GetNumNonZeroBytesInInit(const Expr *E, CodeGenFunction &CGF)
GetNumNonZeroBytesInInit - Get an approximate count of the number of non-zero bytes that will be stor...
RecordDecl - Represents a struct/union/class.
An object to manage conditionally-evaluated expressions.
bool isEmpty() const
Determine whether this is an empty class in the sense of (C++11 [meta.unary.prop]).
CodeGenFunction - This class organizes the per-function state that is used while generating LLVM code...
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
Converts between different integral complex types.
bool isReferenceType() const
FieldDecl - An instance of this class is created by Sema::ActOnField to represent a member of a struc...
llvm::IntegerType * SizeTy
Represents a place-holder for an object not to be initialized by anything.
An RAII object to set (and then clear) a mapping for an OpaqueValueExpr.
Converting between two Objective-C object types, which can occur when performing reference binding to...
Denotes a cleanup that should run when a scope is exited using exceptional control flow (a throw stat...
bool hasSameType(QualType T1, QualType T2) const
Determine whether the given types T1 and T2 are equivalent.
CK_FloatingCast - Casting between floating types of different size.
[ARC] Causes a value of block type to be copied to the heap, if it is not already there...
CK_VectorSplat - A conversion from an arithmetic type to a vector of that element type...
static CharUnits Zero()
Zero - Construct a CharUnits quantity of zero.
CK_NullToPointer - Null pointer constant to pointer, ObjC pointer, or block pointer.
static bool isTrivialFiller(Expr *E)
Determine if E is a trivial array filler, that is, one that is equivalent to zero-initialization.
CK_PointerToIntegral - Pointer to integral.
CK_IntegralToPointer - Integral to pointer.
void setNonGC(bool Value)
Converts a floating point complex to bool by comparing against 0+0i.
Describes an C or C++ initializer list.
A C++ typeid expression (C++ [expr.typeid]), which gets the type_info that corresponds to the supplie...
CK_IntegralToBoolean - Integral to boolean.
Expr * getChosenSubExpr() const
getChosenSubExpr - Return the subexpression chosen according to the condition.
Expr * getTrueExpr() const
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.
field_range fields() const
A builtin binary operation expression such as "x + y" or "x <= y".
RecordDecl * getDecl() const
llvm::CallInst * CreateMemCpy(Address Dest, Address Src, llvm::Value *Size, bool IsVolatile=false)
Scope - A scope is a transient data structure that is used while parsing the program.
CastExpr - Base class for type casts, including both implicit casts (ImplicitCastExpr) and explicit c...
Represents binding an expression to a temporary.
CXXTemporary * getTemporary()
A C++ lambda expression, which produces a function object (of unspecified type) that can be invoked l...
CharUnits getTypeSizeInChars(QualType T) const
Return the size of the specified (complete) type T, in characters.
std::pair< CharUnits, CharUnits > getTypeInfoInChars(const Type *T) const
A default argument (C++ [dcl.fct.default]).
bool isUnnamedBitfield() const
Determines whether this is an unnamed bitfield.
Checking the operand of a load. Must be suitably sized and aligned.
field_iterator field_end() const
CK_AnyPointerToBlockPointerCast - Casting any non-block pointer to a block pointer.
LValue MakeAddrLValue(Address Addr, QualType T, AlignmentSource AlignSource=AlignmentSource::Type)
QualType getValueType() const
Gets the type contained by this atomic type, i.e.
static CharUnits One()
One - Construct a CharUnits quantity of one.
Causes a block literal to by copied to the heap and then autoreleased.
CastKind
CastKind - The kind of operation required for a conversion.
RValue - This trivial value class is used to represent the result of an expression that is evaluated...
const Expr * getExpr() const
Get the initialization expression that will be used.
Represents a call to the builtin function __builtin_va_arg.
CK_FunctionToPointerDecay - Function to pointer decay.
Converts between different floating point complex types.
std::pair< CharUnits, CharUnits > getTypeInfoDataSizeInChars(QualType T) const
CGObjCRuntime & getObjCRuntime()
Return a reference to the configured Objective-C runtime.
An expression "T()" which creates a value-initialized rvalue of type T, which is a non-class type...
llvm::Value * getPointer() const
Expr - This represents one expression.
CK_PointerToBoolean - Pointer to boolean conversion.
Converts an integral complex to an integral real of the source's element type by discarding the imagi...
CK_BitCast - A conversion which causes a bit pattern of one type to be reinterpreted as a bit pattern...
bool isAnyComplexType() const
Enters a new scope for capturing cleanups, all of which will be executed once the scope is exited...
bool isAtomicType() const
static CharUnits fromQuantity(QuantityType Quantity)
fromQuantity - Construct a CharUnits quantity from a raw integer type.
CharUnits toCharUnitsFromBits(int64_t BitSize) const
Convert a size in bits to a size in characters.
An RAII object to record that we're evaluating a statement expression.
Expr * getSubExpr() const
CK_ConstructorConversion - Conversion by constructor.
An expression that sends a message to the given Objective-C object or class.
llvm::CallInst * CreateMemSet(Address Dest, llvm::Value *Value, llvm::Value *Size, bool IsVolatile=false)
Converts from an integral complex to a floating complex.
UnaryOperator - This represents the unary-expression's (except sizeof and alignof), the postinc/postdec operators from postfix-expression, and various extensions.
Represents a reference to a non-type template parameter that has been substituted with a template arg...
The scope of a CXXDefaultInitExpr.
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.
CK_ArrayToPointerDecay - Array to pointer decay.
InitListExpr * getUpdater() const
CK_CPointerToObjCPointerCast - Casting a C pointer kind to an Objective-C pointer.
OpaqueValueExpr - An expression referring to an opaque object of a fixed type and value class...
PseudoObjectExpr - An expression which accesses a pseudo-object l-value.
CK_UserDefinedConversion - Conversion using a user defined type conversion function.
ASTContext & getContext() const
A saved depth on the scope stack.
LValue EmitAggExprToLValue(const Expr *E)
EmitAggExprToLValue - Emit the computation of the specified expression of aggregate type into a tempo...
CK_NullToMemberPointer - Null pointer constant to member pointer.
A scoped helper to set the current debug location to the specified location or preferred location of ...
StmtVisitor - This class implements a simple visitor for Stmt subclasses.
CK_ReinterpretMemberPointer - Reinterpret a member pointer as a different kind of member pointer...
CK_DerivedToBase - A conversion from a C++ class pointer to a base class pointer. ...
const ConstantArrayType * getAsConstantArrayType(QualType T) const
AtomicExpr - Variadic atomic builtins: __atomic_exchange, __atomic_fetch_*, __atomic_load, __atomic_store, and __atomic_compare_exchange_*, for the similarly-named C++11 instructions, and __c11 variants for <stdatomic.h>.
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 void CheckAggExprForMemSetUse(AggValueSlot &Slot, const Expr *E, CodeGenFunction &CGF)
CheckAggExprForMemSetUse - If the initializer is large and has a lot of zeros in it, emit a memset and avoid storing the individual zeros.
Converts from an integral real to an integral complex whose element type matches the source...
const LangOptions & getLangOpts() const
const T * castAs() const
Member-template castAs<specific type>.
bool hasObjectMember() const
StmtExpr - This is the GNU Statement Expression extension: ({int X=4; X;}).
bool isVolatileQualified() const
Determine whether this type is volatile-qualified.
Expr * getArrayFiller()
If this initializer list initializes an array with more elements than there are initializers in the l...
SourceLocation getExprLoc() const LLVM_READONLY
getExprLoc - Return the preferred location for the arrow when diagnosing a problem with a generic exp...
bool hasTrivialCopyAssignment() const
Determine whether this class has a trivial copy assignment operator (C++ [class.copy]p11, C++11 [class.copy]p25)
void setExternallyDestructed(bool destructed=true)
Represents a C11 generic selection.
QualType getCallReturnType(const ASTContext &Ctx) const
getCallReturnType - Get the return type of the call expr.
Converts a floating point complex to floating point real of the source's element type.
Expr * getReplacement() const
CharUnits getAlignment() const
Return the alignment of this pointer.
static const Type * getElementType(const Expr *BaseExpr)
void setVolatile(bool flag)
llvm::Value * getAggregatePointer() const
const Expr * getExpr() const
[C99 6.4.2.2] - A predefined identifier such as func.
Converts an integral complex to bool by comparing against 0+0i.
Address CreateMemTemp(QualType T, const Twine &Name="tmp")
CreateMemTemp - Create a temporary memory object of the given type, with appropriate alignment...
const internal::VariadicAllOfMatcher< Type > type
Matches Types in the clang AST.
static AggValueSlot ignored()
ignored - Returns an aggregate value slot indicating that the aggregate value is being ignored...
A scope within which we are constructing the fields of an object which might use a CXXDefaultInitExpr...
CK_BaseToDerived - A conversion from a C++ class pointer/reference to a derived class pointer/referen...
U cast(CodeGen::Address addr)
IsAliased_t isPotentiallyAliased() const
bool hasTrivialMoveConstructor() const
Determine whether this class has a trivial move constructor (C++11 [class.copy]p12) ...
Checking the destination of a store. Must be suitably sized and aligned.
CK_BlockPointerToObjCPointerCast - Casting a block pointer to an ObjC pointer.
detail::InMemoryDirectory::const_iterator E
void EmitAggregateCopy(Address DestPtr, Address SrcPtr, QualType EltTy, bool isVolatile=false, bool isAssignment=false)
EmitAggregateCopy - Emit an aggregate copy.
IsDestructed_t isExternallyDestructed() const
A conversion of a floating point real to a floating point complex of the original type...
CK_MemberPointerToBoolean - Member pointer to boolean.
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. ...
[ARC] Reclaim a retainable object pointer object that may have been produced and autoreleased as part...
static bool hasAggregateEvaluationKind(QualType T)
bool hasTrivialMoveAssignment() const
Determine whether this class has a trivial move assignment operator (C++11 [class.copy]p25)
llvm::PointerType * getType() const
Return the type of the pointer value.
A helper class that allows the use of isa/cast/dyncast to detect TagType objects of structs/unions/cl...
const T * getAs() const
Member-template getAs<specific type>'.
Expr * getFalseExpr() const
ArraySubscriptExpr - [C99 6.5.2.1] Array Subscripting.
AbstractConditionalOperator - An abstract base class for ConditionalOperator and BinaryConditionalOpe...
NeedsGCBarriers_t requiresGCollection() const
[ARC] Produces a retainable object pointer so that it may be consumed, e.g.
CK_LValueBitCast - A conversion which reinterprets the address of an l-value as an l-value of a diffe...
Converts from T to _Atomic(T).
Address getAddress() const
Converts from a floating complex to an integral complex.
Internal linkage, which indicates that the entity can be referred to from within the translation unit...
const Expr * getInitializer() const
CK_UncheckedDerivedToBase - A conversion from a C++ class pointer/reference to a base class that can ...
ObjCIvarRefExpr - A reference to an ObjC instance variable.
uint64_t getPointerWidth(unsigned AddrSpace) const
Return the width of pointers on this target, for the specified address space.
A use of a default initializer in a constructor or in aggregate initialization.
bool isPODType(ASTContext &Context) const
Determine whether this is a Plain Old Data (POD) type (C++ 3.9p10).
Defines the C++ Decl subclasses, other than those for templates (found in DeclTemplate.h) and friends (in DeclFriend.h).
MemberExpr - [C99 6.5.2.3] Structure and Union Members.
const Expr * getSubExpr() const
Represents a C++ struct/union/class.
BoundNodesTreeBuilder *const Builder
ChooseExpr - GNU builtin-in function __builtin_choose_expr.
unsigned kind
All of the diagnostics that can be emitted by the frontend.
Address getAggregateAddress() const
getAggregateAddr() - Return the Value* of the address of the aggregate.
Converts from _Atomic(T) to T.
StringLiteral - This represents a string literal expression, e.g.
CallExpr - Represents a function call (C99 6.5.2.2, C++ [expr.call]).
bool isIncompleteArrayType() const
bool isStringLiteralInit() const
CK_NoOp - A conversion which does not affect the type other than (possibly) adding qualifiers...
A reference to a declared variable, function, enum, etc.
static RValue get(llvm::Value *V)
CK_DerivedToBaseMemberPointer - Member pointer in derived class to member pointer in base class...
QualType getElementType() const
const Expr * getInit(unsigned Init) const
const Expr * getSubExpr() const
FieldDecl * getInitializedFieldInUnion()
If this initializes a union, specifies which field in the union to initialize.
static RValue getAggregate(Address addr, bool isVolatile=false)
CodeGenTypes & getTypes() const
LValue - This represents an lvalue references.
Qualifiers getQualifiers() const
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...
CK_ToVoid - Cast to void, discarding the computed value.
Represents the canonical version of C arrays with a specified constant size.
QualType getBaseElementType(const ArrayType *VAT) const
Return the innermost element type of an array type.
bool isZeroInitializable(QualType T)
IsZeroInitializable - Return whether a type can be zero-initialized (in the C++ sense) with an LLVM z...
Represents an implicitly-generated value initialization of an object of a given type.
bool hasUserDeclaredConstructor() const
Determine whether this class has any user-declared constructors.
Expr * IgnoreParens() LLVM_READONLY
IgnoreParens - Ignore parentheses.
CK_FloatingToBoolean - Floating point to boolean.