85 for (
const auto *nd : indirectField->
chain()) {
100 "Must have member initializer!");
101 assert(memberInit->
getInit() &&
"Must have initializer!");
133 unsigned srcArgIndex =
145 lhs.isVolatileQualified());
149 "Arrays of non-record types shouldn't need EH cleanup");
166 const CXXRecordDecl *baseClass;
168 CallBaseDtor(
const CXXRecordDecl *base,
bool baseIsVirtual)
169 : baseClass(base), baseIsVirtual(baseIsVirtual) {}
171 void emit(CIRGenFunction &cgf, Flags flags)
override {
172 const CXXRecordDecl *derivedClass =
175 const CXXDestructorDecl *d = baseClass->getDestructor();
179 assert(cgf.
currSrcLoc &&
"expected source location");
184 false, addr, thisTy);
192 const CXXDestructorDecl *dtor;
196 CallDelegatingCtorDtor(
const CXXDestructorDecl *dtor, Address addr,
198 : dtor(dtor), addr(addr),
type(
type) {}
200 void emit(CIRGenFunction &cgf, Flags flags)
override {
201 QualType thisTy = dtor->getFunctionObjectParameterType();
209struct DynamicThisUseChecker
210 : ConstEvaluatedExprVisitor<DynamicThisUseChecker> {
211 using super = ConstEvaluatedExprVisitor<DynamicThisUseChecker>;
213 bool usesThis =
false;
215 DynamicThisUseChecker(
const ASTContext &
c) : super(
c) {}
222 void VisitCXXThisExpr(
const CXXThisExpr *e) { usesThis =
true; }
227 DynamicThisUseChecker checker(
c);
229 return checker.usesThis;
251 return builder.createBaseClassAddr(loc, thisAddr,
convertType(base),
259 assert(
curFuncDecl &&
"loading 'this' without a func declaration?");
280 loc, thisPtr, classDecl, baseClassDecl, isBaseVirtual);
288 if (
cgm.getLangOpts().Exceptions && !baseClassDecl->hasTrivialDestructor())
312 bool constructVBases = ctorType !=
Ctor_Base &&
315 if (constructVBases &&
316 !
cgm.getTarget().getCXXABI().hasConstructorVariants()) {
318 "emitCtorPrologue: virtual base without variants");
323 auto allInits = cd->
inits();
326 auto virtualBaseEnd = std::find_if(
328 return !(Init->isBaseInitializer() && Init->isBaseVirtual());
331 auto nonVirtualBaseEnd = std::find_if(virtualBaseEnd, allInits.end(),
333 return !Init->isBaseInitializer();
337 auto virtualBaseInits = llvm::make_range(allInits.begin(), virtualBaseEnd);
338 auto nonVirtualBaseInits =
339 llvm::make_range(virtualBaseEnd, nonVirtualBaseEnd);
340 auto memberInits = llvm::make_range(nonVirtualBaseEnd, allInits.end());
345 if (
cgm.getCodeGenOpts().StrictVTablePointers &&
346 cgm.getCodeGenOpts().OptimizationLevel > 0 &&
351 "emitCtorPrologue: strict vtable pointers for vbase");
358 if (!constructVBases)
360 emitInitializer(virtualBaseInit);
367 assert(!nonVirtualBaseInit->isBaseVirtual());
368 emitInitializer(nonVirtualBaseInit);
383 assert(!member->isBaseInitializer());
384 assert(member->isAnyMemberInitializer() &&
385 "Delegating initializer on non-delegating constructor");
392 CharUnits nonVirtualOffset, mlir::Value virtualOffset,
394 mlir::Type baseValueTy = {},
bool assumeNotNull =
true) {
396 assert(!nonVirtualOffset.
isZero() || virtualOffset !=
nullptr);
399 mlir::Value baseOffset;
400 if (!nonVirtualOffset.
isZero()) {
404 "applyNonVirtualAndVirtualOffset: virtual and non-virtual offset");
407 assert(baseValueTy &&
"expected base type");
410 loc, addr, baseValueTy, nonVirtualOffset.
getQuantity(),
414 baseOffset = virtualOffset;
423 mlir::Value adjusted = cir::PtrStrideOp::create(
424 cgf.
getBuilder(), loc, charPtrType, charPtr, baseOffset);
431 assert(nearestVBase &&
"virtual offset without vbase?");
439 return Address(ptr, alignment);
445 mlir::Value vtableAddressPoint =
446 cgm.getCXXABI().getVTableAddressPointInStructor(
449 if (!vtableAddressPoint)
453 mlir::Value virtualOffset{};
456 mlir::Type baseValueTy;
457 if (
cgm.getCXXABI().isVirtualOffsetNeededForVTableField(*
this, vptr)) {
460 virtualOffset =
cgm.getCXXABI().getVirtualBaseClassOffset(
472 if (!nonVirtualOffset.
isZero() || virtualOffset) {
474 loc, *
this, classAddr, nonVirtualOffset, virtualOffset,
484 cir::VTableGetVPtrOp::create(builder, loc, classAddr.
getPointer());
486 builder.createStore(loc, vtableAddressPoint, vtableField);
498 if (
cgm.getCXXABI().doStructorsInitializeVPtrs(rd))
503 cgm.getCXXABI().initializeHiddenVirtualInheritanceMembers(*
this, rd);
513 false, vtableClass, vbases,
521 bool baseIsNonVirtualPrimaryBase,
527 if (!baseIsNonVirtualPrimaryBase) {
529 VPtr vptr = {base, nearestVBase, offsetFromNearestVBase, vtableClass};
530 vptrs.push_back(vptr);
535 for (
const auto &nextBase : rd->
bases()) {
536 const auto *baseDecl =
538 ->getDefinitionOrSelf();
541 if (!baseDecl->isDynamicClass())
546 bool baseDeclIsNonVirtualPrimaryBase;
549 if (nextBase.isVirtual()) {
551 if (!vbases.insert(baseDecl).second)
557 nextBaseDecl = baseDecl;
560 baseDeclIsNonVirtualPrimaryBase =
false;
564 nextBaseDecl = nearestVBase;
566 baseOffsetFromNearestVBase =
568 baseDeclIsNonVirtualPrimaryBase = layout.
getPrimaryBase() == baseDecl;
572 baseOffsetFromNearestVBase,
573 baseDeclIsNonVirtualPrimaryBase, vtableClass, vbases,
579 assert(
curFuncDecl &&
"loading 'this' without a func declaration?");
627 const Expr *e,
Address base, mlir::Value memberPtr,
631 cir::GetRuntimeMemberOp op = builder.createGetIndirectMember(
636 CharUnits memberAlign =
cgm.getNaturalTypeAlignment(memberType, baseInfo);
637 memberAlign =
cgm.getDynamicOffsetAlignment(
652 return std::min(actualBaseAlign, expectedTargetAlign);
676 if (actualBaseAlign >= expectedBaseAlign)
677 return expectedTargetAlign;
682 return std::min(actualBaseAlign, expectedTargetAlign);
714 bool zeroInitialize) {
718 newPointerIsChecked, zeroInitialize);
742 while (
auto maybeArrayTy = mlir::dyn_cast<cir::ArrayType>(elementType))
743 elementType = maybeArrayTy.getElementType();
744 cir::PointerType ptrToElmType = builder.getPointerTo(elementType);
746 bool useDynamicArrayCtor =
true;
747 uint64_t constElementCount = 0;
748 if (
auto constantOp = numElements.getDefiningOp<cir::ConstantOp>()) {
750 if (constElementCount == 0)
752 if (constantOp.use_empty())
754 useDynamicArrayCtor =
false;
772 mlir::Value dynamicElPtr;
773 if (useDynamicArrayCtor)
775 builder.createPtrBitcast(arrayBase.
getPointer(), elementType);
787 bool needsPartialArrayCleanup =
790 auto emitCtorBody = [&](mlir::OpBuilder &
b, mlir::Location l) {
791 mlir::BlockArgument arg =
792 b.getInsertionBlock()->addArgument(ptrToElmType, l);
804 cir::YieldOp::create(
b, l);
807 llvm::function_ref<void(mlir::OpBuilder &, mlir::Location)>
808 emitPartialDtorBody =
nullptr;
809 auto partialDtorBuilder = [&](mlir::OpBuilder &
b, mlir::Location l) {
810 mlir::BlockArgument arg =
811 b.getInsertionBlock()->addArgument(ptrToElmType, l);
815 false, curAddr,
type);
816 cir::YieldOp::create(
b, l);
818 if (needsPartialArrayCleanup)
819 emitPartialDtorBody = partialDtorBuilder;
821 if (useDynamicArrayCtor) {
822 cir::ArrayCtor::create(builder, loc, dynamicElPtr, numElements,
823 emitCtorBody, emitPartialDtorBody);
825 cir::ArrayType arrayTy =
826 cir::ArrayType::get(elementType, constElementCount);
827 mlir::Value arrayOp =
828 builder.createPtrBitcast(arrayBase.
getPointer(), arrayTy);
829 cir::ArrayCtor::create(builder, loc, arrayOp, emitCtorBody,
830 emitPartialDtorBody);
840 FunctionArgList::const_iterator i = args.begin(), e = args.end();
841 assert(i != e &&
"no parameters to constructor");
850 if (
cgm.getCXXABI().needsVTTParameter(
curGD)) {
851 cgm.errorNYI(loc,
"emitDelegateCXXConstructorCall: VTT parameter");
856 for (; i != e; ++i) {
865 true, thisAddr, delegateArgs, loc);
870 assert(assignOp->isCopyAssignmentOperator() ||
871 assignOp->isMoveAssignmentOperator());
872 const Stmt *rootS = assignOp->getBody();
874 "Body of an implicit assignment operator should be compound stmt.");
888 for (
Stmt *
s : rootCS->body())
890 cgm.errorNYI(
s->getSourceRange(),
891 std::string(
"emitImplicitAssignmentOperatorBody: ") +
892 s->getStmtClassName());
899 cgm.getTypes().arrangeCXXMethodDeclaration(callOperator);
900 cir::FuncOp calleePtr =
cgm.getAddrOfFunction(
901 GlobalDecl(callOperator),
cgm.getTypes().getFunctionType(calleeFnInfo));
919 if (!resultType->isVoidType() && returnSlot.
isNull()) {
920 if (
getLangOpts().ObjCAutoRefCount && resultType->isObjCRetainableType())
922 "emitForwardingCallToLambda: ObjCAutoRefCount");
926 "emitForwardingCallToLambda: return slot is not null");
954 void *InsertPos =
nullptr;
957 assert(correspondingCallOpSpecialization);
977 const auto *record =
type->castAsCXXRecordDecl();
996struct CallDtorDelete final : EHScopeStack::Cleanup {
999 void emit(CIRGenFunction &cgf, Flags flags)
override {
1001 const CXXRecordDecl *classDecl = dtor->
getParent();
1003 loadThisForDtorDelete(cgf, dtor),
1009 const FieldDecl *field;
1014 : field(field), destroyer(destroyer) {}
1016 void emit(CIRGenFunction &cgf, Flags flags)
override {
1023 assert(lv.isSimple());
1026 cgf.
emitDestroy(lv.getAddress(), field->getType(), destroyer);
1040 "Should not emit dtor epilogue for non-exported trivial dtor!");
1046 "operator delete missing - EnterDtorCleanups");
1052 "deleting destructor with destroying operator delete");
1073 auto *baseClassDecl = base.getType()->castAsCXXRecordDecl();
1075 if (baseClassDecl->hasTrivialDestructor()) {
1095 if (base.isVirtual())
1098 CXXRecordDecl *baseClassDecl = base.getType()->getAsCXXRecordDecl();
1117 const RecordType *rt =
type->getAsUnionType();
1118 if (rt && rt->getDecl()->isAnonymousStructOrUnion())
1123 ehStack.pushCleanup<DestroyField>(cleanupKind, field,
1147 ehStack.pushCleanup<CallDelegatingCtorDtor>(
1154 bool forVirtualBase,
bool delegating,
1156 cgm.getCXXABI().emitDestructorCall(*
this, dd,
type, forVirtualBase,
1157 delegating, thisAddr, thisTy);
1162 if (!
cgm.getCXXABI().needsVTTParameter(gd))
1168 uint64_t subVTTIndex;
1173 }
else if (rd == base) {
1176 assert(!
cgm.getCXXABI().needsVTTParameter(
curGD) &&
1177 "doing no-op VTT offset in base dtor/ctor?");
1178 assert(!forVirtualBase &&
"Can't have same class as virtual base!");
1187 assert(subVTTIndex != 0 &&
"Sub-VTT index must be greater than zero!");
1191 if (
cgm.getCXXABI().needsVTTParameter(
curGD)) {
1194 return builder.createVTTAddrPoint(loc, vtt.getType(), vtt, subVTTIndex);
1197 cir::GlobalOp vtt =
cgm.getVTables().getAddrOfVTT(rd);
1198 return builder.createVTTAddrPoint(
1199 loc, builder.getPointerTo(
cgm.voidPtrTy),
1200 mlir::FlatSymbolRefAttr::get(vtt.getSymNameAttr()), subVTTIndex);
1206 llvm::iterator_range<CastExpr::path_const_iterator> path,
1207 bool nullCheckValue) {
1208 assert(!path.empty() &&
"Base path should not be empty!");
1211 mlir::Type derivedValueTy =
convertType(derivedTy);
1213 cgm.computeNonVirtualBaseClassOffset(derived, path);
1218 return builder.createDerivedClassAddr(loc, baseAddr, derivedValueTy,
1225 llvm::iterator_range<CastExpr::path_const_iterator> path,
1227 assert(!path.empty() &&
"Base path should not be empty!");
1232 if ((*path.begin())->isVirtual()) {
1233 vBase = (*start)->getType()->castAsCXXRecordDecl();
1240 CharUnits nonVirtualOffset =
cgm.computeNonVirtualBaseClassOffset(
1241 vBase ? vBase : derived, {start, path.end()});
1246 if (vBase && derived->
hasAttr<FinalAttr>()) {
1249 nonVirtualOffset += vBaseOffset;
1254 mlir::Type baseValueTy =
convertType((path.end()[-1])->getType());
1259 if (nonVirtualOffset.
isZero() && !vBase) {
1261 return builder.createBaseClassAddr(
getLoc(loc), value, baseValueTy, 0,
1268 mlir::Value virtualOffset =
nullptr;
1270 virtualOffset =
cgm.getCXXABI().getVirtualBaseClassOffset(
1271 getLoc(loc), *
this, value, derived, vBase);
1276 getLoc(loc), *
this, value, nonVirtualOffset, virtualOffset, derived,
1277 vBase, baseValueTy,
not nullCheckValue);
1288 if (!
cgm.getCodeGenOpts().WholeProgramVTables)
1291 if (
cgm.getCodeGenOpts().VirtualFunctionElimination)
1302 cir::VTableGetVPtrOp::create(builder, loc, thisAddr.
getPointer());
1305 auto vtable = builder.createLoad(loc, vtablePtrAddr);
1308 if (
cgm.getCodeGenOpts().OptimizationLevel > 0 &&
1309 cgm.getCodeGenOpts().StrictVTablePointers) {
1318 bool forVirtualBase,
1332 assert(e->
getNumArgs() == 1 &&
"unexpected argcount for trivial ctor");
1349 !inherited ||
cgm.getTypes().inheritingCtorHasParams(inherited,
type))
1374 "canEmitDelegateCallArgs: args-destroyed-L-to-R in callee");
1389 if (inheritedFromVBase &&
1390 cgm.getTarget().getCXXABI().hasConstructorVariants()) {
1392 "inheritedFromVBase with ctor variants");
1397 "wrong number of parameters for inherited constructor call");
1399 ctorArgs[0] = thisArg;
1401 ctorArgs.push_back(thisArg);
1403 assert(outerCtor->getNumParams() == d->
getNumParams());
1404 assert(!outerCtor->isVariadic() &&
"should have been inlined");
1406 for (
const ParmVarDecl *param : outerCtor->parameters()) {
1408 outerCtor->getParamDecl(param->getFunctionScopeIndex())->getType(),
1412 if (param->hasAttr<PassObjectSizeAttr>())
1415 "emitInheritedCXXConstructorCall: pass object size attr argument");
1425 bool forVirtualBase,
bool delegating,
CallArgList &args) {
1428 InlinedInheritingConstructorScope scope(*
this, gd);
1441 cgm.getCXXABI().addImplicitConstructorArgs(*
this, d, ctorType, forVirtualBase,
1445 assert(args.size() >= params.size() &&
"too few arguments for call");
1446 for (
auto [idx, arg, parm] :
1447 llvm::zip_longest(llvm::index_range{0, args.size()}, args, params)) {
1449 mlir::Location parmLoc =
getLoc((*parm)->getSourceRange());
1450 RValue argVal = arg->getRValue(*
this, parmLoc);
1455 (*parm)->getType());
1467 "emitInlinedInheritingCXXConstructorCall: non-void return");
1469 cgm.getCXXABI().emitInstanceFunctionProlog(loc, *
this);
1489 bool passPrototypeArgs =
true;
1494 if (passPrototypeArgs &&
1504 cgm.getCXXABI().addImplicitConstructorArgs(*
this, d,
type, forVirtualBase,
1512 cir::CIRCallOpInterface
c;
static void emit(Program &P, llvm::SmallVectorImpl< std::byte > &Code, const T &Val, bool &Success)
Helper to write bytecode and bail out if 32-bit offsets become invalid.
static bool baseInitializerUsesThis(ASTContext &c, const Expr *init)
static Address applyNonVirtualAndVirtualOffset(mlir::Location loc, CIRGenFunction &cgf, Address addr, CharUnits nonVirtualOffset, mlir::Value virtualOffset, const CXXRecordDecl *derivedClass, const CXXRecordDecl *nearestVBase, mlir::Type baseValueTy={}, bool assumeNotNull=true)
static void emitMemberInitializer(CIRGenFunction &cgf, const CXXRecordDecl *classDecl, CXXCtorInitializer *memberInit, const CXXConstructorDecl *constructor, FunctionArgList &args)
static bool isInitializerOfDynamicClass(const CXXCtorInitializer *baseInit)
static bool canEmitDelegateCallArgs(CIRGenModule &cgm, ASTContext &ctx, const CXXConstructorDecl *d, CXXCtorType type)
static void emitLValueForAnyFieldInitialization(CIRGenFunction &cgf, CXXCtorInitializer *memberInit, LValue &lhs)
Defines the clang::Expr interface and subclasses for C++ expressions.
C Language Family Type Representation.
__device__ __2f16 float __ockl_bool s
__device__ __2f16 float c
mlir::Value createBitcast(mlir::Value src, mlir::Type newTy)
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
const ConstantArrayType * getAsConstantArrayType(QualType T) const
const ASTRecordLayout & getASTRecordLayout(const RecordDecl *D) const
Get or compute information about the layout of the specified record (struct/union/class) D,...
QualType getPointerType(QualType T) const
Return the uniqued reference to the type for a pointer to the specified type.
QualType getBaseElementType(const ArrayType *VAT) const
Return the innermost element type of an array type.
const TargetInfo & getTargetInfo() const
CanQualType getCanonicalTagType(const TagDecl *TD) const
ASTRecordLayout - This class contains layout information for one RecordDecl, which is a struct/union/...
CharUnits getSize() const
getSize - Get the record size in characters.
CharUnits getNonVirtualAlignment() const
getNonVirtualAlignment - Get the non-virtual alignment (in chars) of an object, which is the alignmen...
CharUnits getBaseClassOffset(const CXXRecordDecl *Base) const
getBaseClassOffset - Get the offset, in chars, for the given base class.
CharUnits getVBaseClassOffset(const CXXRecordDecl *VBase) const
getVBaseClassOffset - Get the offset, in chars, for the given base class.
const CXXRecordDecl * getPrimaryBase() const
getPrimaryBase - Get the primary base for this record.
Represents an array type, per C99 6.7.5.2 - Array Declarators.
const CXXRecordDecl * getBase() const
getBase - Returns the base class declaration.
CharUnits getBaseOffset() const
getBaseOffset - Returns the base class offset.
mlir::Value getPointer() const
mlir::Type getElementType() const
Address withElementType(CIRGenBuilderTy &builder, mlir::Type ElemTy) const
Return address with different element type, a bitcast pointer, and the same alignment.
clang::CharUnits getAlignment() const
Overlap_t mayOverlap() const
static AggValueSlot forAddr(Address addr, clang::Qualifiers quals, IsDestructed_t isDestructed, IsAliased_t isAliased, Overlap_t mayOverlap, IsZeroed_t isZeroed=IsNotZeroed)
static AggValueSlot forLValue(const LValue &LV, IsDestructed_t isDestructed, IsAliased_t isAliased, Overlap_t mayOverlap, IsZeroed_t isZeroed=IsNotZeroed)
Address getAddress() const
Address createBaseClassAddr(mlir::Location loc, Address addr, mlir::Type destType, unsigned offset, bool assumeNotNull)
cir::LoadOp createLoad(mlir::Location loc, Address addr, bool isVolatile=false)
virtual size_t getSrcArgforCopyCtor(const CXXConstructorDecl *, FunctionArgList &args) const =0
static CIRGenCallee forDirect(mlir::Operation *funcPtr, const CIRGenCalleeInfo &abstractInfo=CIRGenCalleeInfo())
A scope within which we are constructing the fields of an object which might use a CXXDefaultInitExpr...
Enters a new scope for capturing cleanups, all of which will be executed once the scope is exited.
static bool isConstructorDelegationValid(const clang::CXXConstructorDecl *ctor)
Checks whether the given constructor is a valid subject for the complete-to-base constructor delegati...
void emitLambdaDelegatingInvokeBody(const CXXMethodDecl *md)
void emitCallArgs(CallArgList &args, PrototypeWrapper prototype, llvm::iterator_range< clang::CallExpr::const_arg_iterator > argRange, AbstractCallee callee=AbstractCallee(), unsigned paramsToSkip=0)
mlir::Type convertType(clang::QualType t)
static cir::TypeEvaluationKind getEvaluationKind(clang::QualType type)
Return the cir::TypeEvaluationKind of QualType type.
clang::GlobalDecl curGD
The GlobalDecl for the current function being compiled or the global variable currently being initial...
Address emitCXXMemberDataPointerAddress(const Expr *e, Address base, mlir::Value memberPtr, const MemberPointerType *memberPtrType, LValueBaseInfo *baseInfo)
CIRGenTypes & getTypes() const
const clang::LangOptions & getLangOpts() const
mlir::Value cxxStructorImplicitParamValue
cir::AllocaOp createTempAlloca(mlir::Type ty, mlir::Location loc, const Twine &name="tmp", mlir::Value arraySize=nullptr, bool insertIntoFnEntryBlock=false)
This creates an alloca and inserts it into the entry block if ArraySize is nullptr,...
void emitForwardingCallToLambda(const CXXMethodDecl *lambdaCallOperator, CallArgList &callArgs)
mlir::Value loadCXXThis()
Load the value for 'this'.
LValue makeNaturalAlignPointeeAddrLValue(mlir::Value v, clang::QualType t)
Given a value of type T* that may not be to a complete object, construct an l-vlaue withi the natural...
void emitDeleteCall(const FunctionDecl *deleteFD, mlir::Value ptr, QualType deleteTy)
clang::CharUnits cxxThisAlignment
LValue emitLValue(const clang::Expr *e)
Emit code to compute a designator that specifies the location of the expression.
const clang::Decl * curFuncDecl
Address loadCXXThisAddress()
void emitInlinedInheritingCXXConstructorCall(SourceLocation loc, const CXXConstructorDecl *d, CXXCtorType ctorType, bool forVirtualBase, bool delegating, CallArgList &args)
Address getAddrOfLocalVar(const clang::VarDecl *vd)
Return the address of a local variable.
void emitAggregateCopy(LValue dest, LValue src, QualType eltTy, AggValueSlot::Overlap_t mayOverlap, bool isVolatile=false)
Emit an aggregate copy.
LValue makeNaturalAlignAddrLValue(mlir::Value val, QualType ty)
mlir::Value getVTTParameter(GlobalDecl gd, bool forVirtualBase, bool delegating)
Return the VTT parameter that should be passed to a base constructor/destructor with virtual bases.
mlir::Location getLoc(clang::SourceLocation srcLoc)
Helpers to convert Clang's SourceLocation to a MLIR Location.
void initializeVTablePointers(mlir::Location loc, const clang::CXXRecordDecl *rd)
void initializeVTablePointer(mlir::Location loc, const VPtr &vptr)
Address getAddressOfBaseClass(Address value, const CXXRecordDecl *derived, llvm::iterator_range< CastExpr::path_const_iterator > path, bool nullCheckValue, SourceLocation loc)
void emitDelegateCXXConstructorCall(const clang::CXXConstructorDecl *ctor, clang::CXXCtorType ctorType, const FunctionArgList &args, clang::SourceLocation loc)
void emitBaseInitializer(mlir::Location loc, const CXXRecordDecl *classDecl, CXXCtorInitializer *baseInit)
void emitExprAsInit(const clang::Expr *init, const clang::ValueDecl *d, LValue lvalue, bool capturedByInit=false)
Emit an expression as an initializer for an object (variable, field, etc.) at the given location.
mlir::Value emitArrayLength(const clang::ArrayType *arrayType, QualType &baseType, Address &addr)
Computes the length of an array in elements, as well as the base element type and a properly-typed fi...
void emitNullInitialization(mlir::Location loc, Address destPtr, QualType ty)
VPtrsVector getVTablePointers(const clang::CXXRecordDecl *vtableClass)
CleanupKind getCleanupKind(QualType::DestructionKind kind)
AggValueSlot::Overlap_t getOverlapForFieldInit(const FieldDecl *fd)
mlir::Operation * curFn
The current function or global initializer that is generated code for.
Address getAddressOfDerivedClass(mlir::Location loc, Address baseAddr, const CXXRecordDecl *derived, llvm::iterator_range< CastExpr::path_const_iterator > path, bool nullCheckValue)
CallArgList cxxInheritedCtorInitExprArgs
The values of function arguments to use when evaluating CXXInheritedCtorInitExprs within this context...
EHScopeStack ehStack
Tracks function scope overall cleanup handling.
void enterDtorCleanups(const CXXDestructorDecl *dtor, CXXDtorType type)
Enter the cleanups necessary to complete the given phase of destruction for a destructor.
void emitImplicitAssignmentOperatorBody(FunctionArgList &args)
static int64_t getZExtIntValueFromConstOp(mlir::Value val)
Get zero-extended integer from a mlir::Value that is an int constant or a constant op.
mlir::Type convertTypeForMem(QualType t)
clang::QualType buildFunctionArgList(clang::GlobalDecl gd, FunctionArgList &args)
void emitCtorPrologue(const clang::CXXConstructorDecl *ctor, clang::CXXCtorType ctorType, FunctionArgList &args)
This routine generates necessary code to initialize base classes and non-static data members belongin...
mlir::Value loadCXXVTT()
Load the VTT parameter to base constructors/destructors have virtual bases.
static Destroyer destroyCXXObject
void emitCXXConstructorCall(const clang::CXXConstructorDecl *d, clang::CXXCtorType type, bool forVirtualBase, bool delegating, AggValueSlot thisAVS, const clang::CXXConstructExpr *e)
mlir::Value getVTablePtr(mlir::Location loc, Address thisAddr, const clang::CXXRecordDecl *vtableClass)
Return the Value of the vtable pointer member pointed to by thisAddr.
llvm::SmallPtrSet< const clang::CXXRecordDecl *, 4 > VisitedVirtualBasesSetTy
void emitReturnOfRValue(mlir::Location loc, RValue rv, QualType ty)
bool shouldEmitVTableTypeCheckedLoad(const CXXRecordDecl *rd)
Returns whether we should perform a type checked load when loading a virtual function for virtual cal...
RValue emitCall(const CIRGenFunctionInfo &funcInfo, const CIRGenCallee &callee, ReturnValueSlot returnValue, const CallArgList &args, cir::CIRCallOpInterface *callOp, mlir::Location loc)
const clang::Decl * curCodeDecl
This is the inner-most code context, which includes blocks.
LValue emitLValueForFieldInitialization(LValue base, const clang::FieldDecl *field, llvm::StringRef fieldName)
Like emitLValueForField, excpet that if the Field is a reference, this will return the address of the...
mlir::Value getAsNaturalPointerTo(Address addr, QualType pointeeType)
void emitInitializerForField(clang::FieldDecl *field, LValue lhs, clang::Expr *init)
LValue emitLValueForField(LValue base, const clang::FieldDecl *field)
mlir::Value emitScalarExpr(const clang::Expr *e, bool ignoreResultAssign=false)
Emit the computation of the specified expression of scalar type.
bool needsEHCleanup(QualType::DestructionKind kind)
Determines whether an EH cleanup is required to destroy a type with the given destruction kind.
Address getAddressOfDirectBaseInCompleteClass(mlir::Location loc, Address value, const CXXRecordDecl *derived, const CXXRecordDecl *base, bool baseIsVirtual)
Convert the given pointer to a complete class to the given direct base.
CIRGenBuilderTy & getBuilder()
AggValueSlot::Overlap_t getOverlapForBaseInit(const CXXRecordDecl *rd, const CXXRecordDecl *baseRD, bool isVirtual)
Determine whether a base class initialization may overlap some other object.
void emitDestroy(Address addr, QualType type, Destroyer *destroyer)
Immediately perform the destruction of the given object.
Destroyer * getDestroyer(clang::QualType::DestructionKind kind)
void Destroyer(CIRGenFunction &cgf, Address addr, QualType ty)
void emitComplexExprIntoLValue(const Expr *e, LValue dest, bool isInit)
void pushEHDestroyIfNeeded(QualType::DestructionKind dtorKind, Address addr, QualType type)
pushEHDestroyIfNeeded - Push the standard destructor for the given type as an EH-only cleanup.
LValue makeAddrLValue(Address addr, QualType ty, AlignmentSource source=AlignmentSource::Type)
void emitCXXDestructorCall(const CXXDestructorDecl *dd, CXXDtorType type, bool forVirtualBase, bool delegating, Address thisAddr, QualType thisTy)
llvm::SmallVector< VPtr, 4 > VPtrsVector
void emitLambdaStaticInvokeBody(const CXXMethodDecl *md)
void emitCXXAggrConstructorCall(const CXXConstructorDecl *ctor, const clang::ArrayType *arrayType, Address arrayBegin, const CXXConstructExpr *e, bool newPointerIsChecked, bool zeroInitialize=false)
Emit a loop to call a particular constructor for each of several members of an array.
void emitDelegateCallArg(CallArgList &args, const clang::VarDecl *param, clang::SourceLocation loc)
We are performing a delegate call; that is, the current function is delegating to another one.
std::optional< mlir::Location > currSrcLoc
Use to track source locations across nested visitor traversals.
clang::ASTContext & getContext() const
void setAddrOfLocalVar(const clang::VarDecl *vd, Address addr)
Set the address of a local variable.
void emitInheritedCXXConstructorCall(const CXXConstructorDecl *d, bool forVirtualBase, Address thisAddr, bool inheritedFromVBase, const CXXInheritedCtorInitExpr *e)
void emitStoreThroughLValue(RValue src, LValue dst, bool isInit=false)
Store the specified rvalue into the specified lvalue, where both are guaranteed to the have the same ...
mlir::Value cxxabiThisValue
mlir::LogicalResult emitStmt(const clang::Stmt *s, bool useCurrentScope, llvm::ArrayRef< const Attr * > attrs={})
Address createMemTemp(QualType t, mlir::Location loc, const Twine &name="tmp", Address *alloca=nullptr, mlir::OpBuilder::InsertPoint ip={})
Create a temporary memory object of the given type, with appropriate alignmen and cast it to the defa...
void emitDelegatingCXXConstructorCall(const CXXConstructorDecl *ctor, const FunctionArgList &args)
void emitAggExpr(const clang::Expr *e, AggValueSlot slot)
This class organizes the cross-function state that is used while generating CIR code.
DiagnosticBuilder errorNYI(SourceLocation, llvm::StringRef)
Helpers to emit "not yet implemented" error diagnostics.
clang::ASTContext & getASTContext() const
CharUnits getDynamicOffsetAlignment(CharUnits actualBaseAlign, const CXXRecordDecl *baseDecl, CharUnits expectedTargetAlign)
TODO: Add TBAAAccessInfo.
CharUnits getMinimumClassObjectSize(const CXXRecordDecl *cd)
Returns the minimum object size for an object of the given class type (or a class derived from it).
CharUnits getVBaseAlignment(CharUnits derivedAlign, const CXXRecordDecl *derived, const CXXRecordDecl *vbase)
Returns the assumed alignment of a virtual base of a class.
CIRGenCXXABI & getCXXABI() const
bool inheritingCtorHasParams(const InheritedConstructor &inherited, CXXCtorType type)
Determine if a C++ inheriting constructor should have parameters matching those of its inherited cons...
void add(RValue rvalue, clang::QualType type)
Information for lazily generating a cleanup.
Type for representing both the decl and type of parameters to a function.
Address getAddress() const
clang::QualType getType() const
This trivial value class is used to represent the result of an expression that is evaluated.
static RValue get(mlir::Value v)
Contains the address where the return value of a function can be stored, and whether the address is v...
Represents a base class of a C++ class.
Represents a call to a C++ constructor.
Expr * getArg(unsigned Arg)
Return the specified argument.
CXXConstructorDecl * getConstructor() const
Get the constructor that this expression will (ultimately) call.
unsigned getNumArgs() const
Return the number of arguments to the constructor call.
Represents a C++ constructor within a class.
init_iterator init_begin()
Retrieve an iterator to the first initializer.
bool isDelegatingConstructor() const
Determine whether this constructor is a delegating constructor.
bool isCopyOrMoveConstructor(unsigned &TypeQuals) const
Determine whether this is a copy or move constructor.
InheritedConstructor getInheritedConstructor() const
Get the constructor that this inheriting constructor is based on.
Represents a C++ base or member initializer.
Expr * getInit() const
Get the initializer.
SourceLocation getSourceLocation() const
Determine the source location of the initializer.
bool isAnyMemberInitializer() const
bool isBaseInitializer() const
Determine whether this initializer is initializing a base class.
bool isIndirectMemberInitializer() const
const Type * getBaseClass() const
If this is a base class initializer, returns the type of the base class.
FieldDecl * getAnyMember() const
IndirectFieldDecl * getIndirectMember() const
bool isBaseVirtual() const
Returns whether the base is virtual or not.
Represents a C++ destructor within a class.
const FunctionDecl * getOperatorDelete() const
Expr * getOperatorDeleteThisArg() const
Represents a call to an inherited base class constructor from an inheriting constructor.
SourceLocation getLocation() const LLVM_READONLY
Represents a static or instance method of a struct/union/class.
const CXXRecordDecl * getParent() const
Return the parent of this method declaration, which is the class in which this method is defined.
QualType getThisType() const
Return the type of the this pointer.
QualType getFunctionObjectParameterType() const
bool isMemcpyEquivalentSpecialMember(const ASTContext &Ctx) const
Returns whether this is a copy/move constructor or assignment operator that can be implemented as a m...
Represents a C++ struct/union/class.
bool isEffectivelyFinal() const
Determine whether it's impossible for a class to be derived from this class.
bool isGenericLambda() const
Determine whether this class describes a generic lambda function object (i.e.
bool hasTrivialDestructor() const
Determine whether this class has a trivial destructor (C++ [class.dtor]p3)
base_class_range vbases()
bool isAbstract() const
Determine whether this class has a pure virtual function.
bool isDynamicClass() const
bool hasDefinition() const
CXXDestructorDecl * getDestructor() const
Returns the destructor decl for this class.
CXXMethodDecl * getLambdaCallOperator() const
Retrieve the lambda call operator of the closure type if this is a closure type.
unsigned getNumVBases() const
Retrieves the number of virtual base classes of this class.
const CXXBaseSpecifier *const * path_const_iterator
CharUnits - This is an opaque type for sizes expressed in character units.
CharUnits alignmentAtOffset(CharUnits offset) const
Given that this is a non-zero alignment value, what is the alignment at the given offset?
bool isZero() const
isZero - Test whether the quantity equals zero.
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 Zero()
Zero - Construct a CharUnits quantity of zero.
Represents the canonical version of C arrays with a specified constant size.
SourceLocation getBeginLoc() const LLVM_READONLY
This represents one expression.
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.
Represents a function declaration or definition.
bool isFunctionTemplateSpecialization() const
Determine whether this function is a function template specialization.
FunctionTemplateDecl * getDescribedFunctionTemplate() const
Retrieves the function template that is described by this function declaration.
bool isDestroyingOperatorDelete() const
Determine whether this is a destroying operator delete.
ArrayRef< ParmVarDecl * > parameters() const
bool isTrivial() const
Whether this function is "trivial" in some specialized C++ senses.
bool isVariadic() const
Whether this function is variadic.
const TemplateArgumentList * getTemplateSpecializationArgs() const
Retrieve the template arguments used to produce this function template specialization from the primar...
bool isDefaulted() const
Whether this function is defaulted.
SourceRange getSourceRange() const override LLVM_READONLY
Source range that this declaration covers.
unsigned getNumParams() const
Return the number of parameters this function must have based on its FunctionType.
Represents a prototype with parameter type info, e.g.
bool isVariadic() const
Whether this function prototype is variadic.
Declaration of a template function.
FunctionDecl * findSpecialization(ArrayRef< TemplateArgument > Args, void *&InsertPos)
Return the specialization with the provided arguments if it exists, otherwise return the insertion po...
QualType getReturnType() const
GlobalDecl - represents a global declaration.
CXXCtorType getCtorType() const
const Decl * getDecl() const
Represents a field injected from an anonymous union/struct into the parent scope.
ArrayRef< NamedDecl * > chain() const
A pointer to member type per C++ 8.3.3 - Pointers to members.
CXXRecordDecl * getMostRecentCXXRecordDecl() const
Note: this can trigger extra deserialization when external AST sources are used.
QualType getPointeeType() const
StringRef getName() const
Get the name of identifier for this declaration as a StringRef.
Represents a parameter to a function.
A (possibly-)qualified type.
DestructionKind isDestructedType() const
Returns a nonzero value if objects of this type require non-trivial work to clean up after.
The collection of all-type qualifiers we support.
field_range fields() const
Encodes a location in the source.
Stmt - This represents one statement.
SourceRange getSourceRange() const LLVM_READONLY
SourceLocation tokens are not useful in isolation - they are low level value objects created/interpre...
bool isCompleteDefinition() const
Return true if this decl has its body fully specified.
bool areArgsDestroyedLeftToRightInCallee() const
Are arguments to a call destroyed left to right in the callee?
TargetCXXABI getCXXABI() const
Get the C++ ABI currently in use.
A template argument list.
ArrayRef< TemplateArgument > asArray() const
Produce this as an array ref.
SourceLocation getBeginLoc() const LLVM_READONLY
The base class of the type hierarchy.
CXXRecordDecl * castAsCXXRecordDecl() const
const T * castAs() const
Member-template castAs<specific type>.
QualType getPointeeType() const
If this is a pointer, ObjC object pointer, or block pointer, this returns the respective pointee.
bool isRecordType() const
Represents a variable declaration or definition.
@ Type
The l-value was considered opaque, so the alignment was determined from a type.
@ 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< ArrayType > arrayType
@ Address
A pointer to a ValueDecl.
The JSON file list parser is used to communicate input to InstallAPI.
CanQual< Type > CanQualType
Represents a canonical, potentially-qualified type.
CXXCtorType
C++ constructor types.
@ Ctor_Base
Base object ctor.
@ Ctor_Complete
Complete object ctor.
bool isa(CodeGen::Address addr)
CXXDtorType
C++ destructor types.
@ Dtor_Base
Base object dtor.
@ Dtor_Complete
Complete object dtor.
@ Dtor_Deleting
Deleting dtor.
U cast(CodeGen::Address addr)
static bool addressSpace()
static bool useEHCleanupForArray()
static bool aggValueSlotGC()
static bool hiddenVisibility()
static bool runCleanupsScope()
static bool opCallArgEvaluationOrder()
static bool createInvariantGroup()
static bool isTrivialCtorOrDtor()
static bool assignMemcpyizer()
static bool ctorMemcpyizer()
static bool generateDebugInfo()
static bool incrementProfileCounter()
Similar to AddedStructorArgs, but only notes the number of additional arguments.
const clang::CXXRecordDecl * vtableClass
clang::CharUnits offsetFromNearestVBase
const clang::CXXRecordDecl * nearestVBase
clang::BaseSubobject base
cir::PointerType uInt8PtrTy