86 for (
const auto *nd : indirectField->
chain()) {
101 "Must have member initializer!");
102 assert(memberInit->
getInit() &&
"Must have initializer!");
134 unsigned srcArgIndex =
146 lhs.isVolatileQualified());
150 "Arrays of non-record types shouldn't need EH cleanup");
161 const CXXRecordDecl *baseClass;
163 CallBaseDtor(
const CXXRecordDecl *base,
bool baseIsVirtual)
164 : baseClass(base), baseIsVirtual(baseIsVirtual) {}
166 void emit(CIRGenFunction &cgf, Flags flags)
override {
167 const CXXRecordDecl *derivedClass =
170 const CXXDestructorDecl *d = baseClass->getDestructor();
174 assert(cgf.
currSrcLoc &&
"expected source location");
179 false, addr, thisTy);
187 const CXXDestructorDecl *dtor;
191 CallDelegatingCtorDtor(
const CXXDestructorDecl *dtor, Address addr,
193 : dtor(dtor), addr(addr),
type(
type) {}
195 void emit(CIRGenFunction &cgf, Flags flags)
override {
196 QualType thisTy = dtor->getFunctionObjectParameterType();
204struct DynamicThisUseChecker
205 : ConstEvaluatedExprVisitor<DynamicThisUseChecker> {
206 using super = ConstEvaluatedExprVisitor<DynamicThisUseChecker>;
208 bool usesThis =
false;
210 DynamicThisUseChecker(
const ASTContext &c) : super(c) {}
217 void VisitCXXThisExpr(
const CXXThisExpr *e) { usesThis =
true; }
222 DynamicThisUseChecker checker(c);
224 return checker.usesThis;
246 return builder.createBaseClassAddr(loc, thisAddr,
convertType(base),
254 assert(
curFuncDecl &&
"loading 'this' without a func declaration?");
275 loc, thisPtr, classDecl, baseClassDecl, isBaseVirtual);
283 if (
cgm.getLangOpts().Exceptions && !baseClassDecl->hasTrivialDestructor())
307 bool constructVBases = ctorType !=
Ctor_Base &&
310 if (constructVBases &&
311 !
cgm.getTarget().getCXXABI().hasConstructorVariants()) {
313 "emitCtorPrologue: virtual base without variants");
318 auto allInits = cd->
inits();
321 auto virtualBaseEnd = std::find_if(
323 return !(Init->isBaseInitializer() && Init->isBaseVirtual());
326 auto nonVirtualBaseEnd = std::find_if(virtualBaseEnd, allInits.end(),
328 return !Init->isBaseInitializer();
332 auto virtualBaseInits = llvm::make_range(allInits.begin(), virtualBaseEnd);
333 auto nonVirtualBaseInits =
334 llvm::make_range(virtualBaseEnd, nonVirtualBaseEnd);
335 auto memberInits = llvm::make_range(nonVirtualBaseEnd, allInits.end());
340 if (
cgm.getCodeGenOpts().StrictVTablePointers &&
341 cgm.getCodeGenOpts().OptimizationLevel > 0 &&
346 "emitCtorPrologue: strict vtable pointers for vbase");
353 if (!constructVBases)
355 emitInitializer(virtualBaseInit);
362 assert(!nonVirtualBaseInit->isBaseVirtual());
363 emitInitializer(nonVirtualBaseInit);
378 assert(!member->isBaseInitializer());
379 assert(member->isAnyMemberInitializer() &&
380 "Delegating initializer on non-delegating constructor");
387 CharUnits nonVirtualOffset, mlir::Value virtualOffset,
389 mlir::Type baseValueTy = {},
bool assumeNotNull =
true) {
391 assert(!nonVirtualOffset.
isZero() || virtualOffset !=
nullptr);
394 mlir::Value baseOffset;
395 if (!nonVirtualOffset.
isZero()) {
397 mlir::Type offsetType =
406 assert(baseValueTy &&
"expected base type");
409 loc, addr, baseValueTy, nonVirtualOffset.
getQuantity(),
413 baseOffset = virtualOffset;
422 mlir::Value adjusted = cir::PtrStrideOp::create(
423 cgf.
getBuilder(), loc, charPtrType, charPtr, baseOffset);
430 assert(nearestVBase &&
"virtual offset without vbase?");
438 return Address(ptr, alignment);
444 mlir::Value vtableAddressPoint =
445 cgm.getCXXABI().getVTableAddressPointInStructor(
448 if (!vtableAddressPoint)
452 mlir::Value virtualOffset{};
455 mlir::Type baseValueTy;
456 if (
cgm.getCXXABI().isVirtualOffsetNeededForVTableField(*
this, vptr)) {
459 virtualOffset =
cgm.getCXXABI().getVirtualBaseClassOffset(
471 if (!nonVirtualOffset.
isZero() || virtualOffset) {
473 loc, *
this, classAddr, nonVirtualOffset, virtualOffset,
483 cir::VTableGetVPtrOp::create(builder, loc, classAddr.
getPointer());
485 builder.createStore(loc, vtableAddressPoint, vtableField);
497 if (
cgm.getCXXABI().doStructorsInitializeVPtrs(rd))
502 cgm.getCXXABI().initializeHiddenVirtualInheritanceMembers(*
this, rd);
512 false, vtableClass, vbases,
520 bool baseIsNonVirtualPrimaryBase,
526 if (!baseIsNonVirtualPrimaryBase) {
528 VPtr vptr = {base, nearestVBase, offsetFromNearestVBase, vtableClass};
529 vptrs.push_back(vptr);
534 for (
const auto &nextBase : rd->
bases()) {
535 const auto *baseDecl =
537 ->getDefinitionOrSelf();
540 if (!baseDecl->isDynamicClass())
545 bool baseDeclIsNonVirtualPrimaryBase;
548 if (nextBase.isVirtual()) {
550 if (!vbases.insert(baseDecl).second)
556 nextBaseDecl = baseDecl;
559 baseDeclIsNonVirtualPrimaryBase =
false;
563 nextBaseDecl = nearestVBase;
565 baseOffsetFromNearestVBase =
567 baseDeclIsNonVirtualPrimaryBase = layout.
getPrimaryBase() == baseDecl;
571 baseOffsetFromNearestVBase,
572 baseDeclIsNonVirtualPrimaryBase, vtableClass, vbases,
578 assert(
curFuncDecl &&
"loading 'this' without a func declaration?");
626 const Expr *e,
Address base, mlir::Value memberPtr,
630 cir::GetRuntimeMemberOp op = builder.createGetIndirectMember(
635 CharUnits memberAlign =
cgm.getNaturalTypeAlignment(memberType, baseInfo);
636 memberAlign =
cgm.getDynamicOffsetAlignment(
651 return std::min(actualBaseAlign, expectedTargetAlign);
675 if (actualBaseAlign >= expectedBaseAlign)
676 return expectedTargetAlign;
681 return std::min(actualBaseAlign, expectedTargetAlign);
713 bool zeroInitialize) {
717 newPointerIsChecked, zeroInitialize,
749 while (
auto maybeArrayTy = mlir::dyn_cast<cir::ArrayType>(elementType))
750 elementType = maybeArrayTy.getElementType();
751 cir::PointerType ptrToElmType = builder.getPointerTo(elementType);
753 bool useDynamicArrayCtor =
true;
754 uint64_t constElementCount = 0;
755 if (
auto constantOp = numElements.getDefiningOp<cir::ConstantOp>()) {
757 if (constElementCount == 0)
759 if (constantOp.use_empty())
761 useDynamicArrayCtor =
false;
779 mlir::Value dynamicElPtr;
780 if (useDynamicArrayCtor)
782 builder.createPtrBitcast(arrayBase.
getPointer(), elementType);
788 bool needsPartialArrayCleanup =
getLangOpts().Exceptions &&
792 auto emitCtorBody = [&](mlir::OpBuilder &b, mlir::Location l) {
793 mlir::BlockArgument arg =
794 b.getInsertionBlock()->addArgument(ptrToElmType, l);
800 builder.createStore(l, arg, endOfInit);
821 cir::YieldOp::create(b, l);
824 llvm::function_ref<void(mlir::OpBuilder &, mlir::Location)>
825 emitPartialDtorBody =
nullptr;
826 auto partialDtorBuilder = [&](mlir::OpBuilder &b, mlir::Location l) {
827 mlir::BlockArgument arg =
828 b.getInsertionBlock()->addArgument(ptrToElmType, l);
832 false, curAddr,
type);
833 cir::YieldOp::create(b, l);
835 if (needsPartialArrayCleanup)
836 emitPartialDtorBody = partialDtorBuilder;
838 if (useDynamicArrayCtor) {
839 cir::ArrayCtor::create(builder, loc, dynamicElPtr, numElements,
840 emitCtorBody, emitPartialDtorBody);
842 cir::ArrayType arrayTy =
843 cir::ArrayType::get(elementType, constElementCount);
844 mlir::Value arrayOp =
845 builder.createPtrBitcast(arrayBase.
getPointer(), arrayTy);
846 cir::ArrayCtor::create(builder, loc, arrayOp, emitCtorBody,
847 emitPartialDtorBody);
856 FunctionArgList::const_iterator i = args.begin(), e = args.end();
857 assert(i != e &&
"no parameters to constructor");
866 if (
cgm.getCXXABI().needsVTTParameter(
curGD)) {
867 cgm.errorNYI(loc,
"emitDelegateCXXConstructorCall: VTT parameter");
872 for (; i != e; ++i) {
881 true, thisAddr, delegateArgs, loc);
886 assert(assignOp->isCopyAssignmentOperator() ||
887 assignOp->isMoveAssignmentOperator());
888 const Stmt *rootS = assignOp->getBody();
890 "Body of an implicit assignment operator should be compound stmt.");
904 for (
Stmt *s : rootCS->body())
906 cgm.errorNYI(s->getSourceRange(),
907 std::string(
"emitImplicitAssignmentOperatorBody: ") +
908 s->getStmtClassName());
915 cgm.getTypes().arrangeCXXMethodDeclaration(callOperator);
916 cir::FuncOp calleePtr =
cgm.getAddrOfFunction(
917 GlobalDecl(callOperator),
cgm.getTypes().getFunctionType(calleeFnInfo));
945 if (!resultType->isVoidType()) {
947 resultType->isObjCRetainableType())
949 "emitForwardingCallToLambda: ObjCAutoRefCount");
980 llvm::FoldingSetInsertToken InsertToken;
983 assert(correspondingCallOpSpecialization);
1003 const auto *record =
type->castAsCXXRecordDecl();
1022struct CallDtorDelete final : EHScopeStack::Cleanup {
1025 void emit(CIRGenFunction &cgf, Flags flags)
override {
1027 const CXXRecordDecl *classDecl = dtor->
getParent();
1029 loadThisForDtorDelete(cgf, dtor),
1035 const FieldDecl *field;
1040 : field(field), destroyer(destroyer) {}
1042 void emit(CIRGenFunction &cgf, Flags flags)
override {
1049 assert(lv.isSimple());
1052 cgf.
emitDestroy(lv.getAddress(), field->getType(), destroyer);
1066 "Should not emit dtor epilogue for non-exported trivial dtor!");
1072 "operator delete missing - EnterDtorCleanups");
1078 "deleting destructor with destroying operator delete");
1099 auto *baseClassDecl = base.getType()->castAsCXXRecordDecl();
1101 if (baseClassDecl->hasTrivialDestructor()) {
1121 if (base.isVirtual())
1124 CXXRecordDecl *baseClassDecl = base.getType()->getAsCXXRecordDecl();
1143 const RecordType *rt =
type->getAsUnionType();
1144 if (rt && rt->getDecl()->isAnonymousStructOrUnion())
1149 ehStack.pushCleanup<DestroyField>(cleanupKind, field,
1173 ehStack.pushCleanup<CallDelegatingCtorDtor>(
1180 bool forVirtualBase,
bool delegating,
1182 cgm.getCXXABI().emitDestructorCall(*
this, dd,
type, forVirtualBase,
1183 delegating, thisAddr, thisTy);
1188 if (!
cgm.getCXXABI().needsVTTParameter(gd))
1194 uint64_t subVTTIndex;
1199 }
else if (rd == base) {
1202 assert(!
cgm.getCXXABI().needsVTTParameter(
curGD) &&
1203 "doing no-op VTT offset in base dtor/ctor?");
1204 assert(!forVirtualBase &&
"Can't have same class as virtual base!");
1213 assert(subVTTIndex != 0 &&
"Sub-VTT index must be greater than zero!");
1217 if (
cgm.getCXXABI().needsVTTParameter(
curGD)) {
1220 return builder.createVTTAddrPoint(loc, vtt.getType(), vtt, subVTTIndex);
1223 cir::GlobalOp vtt =
cgm.getVTables().getAddrOfVTT(rd);
1224 return builder.createVTTAddrPoint(
1225 loc, builder.getPointerTo(
cgm.voidPtrTy),
1226 mlir::FlatSymbolRefAttr::get(vtt.getSymNameAttr()), subVTTIndex);
1232 llvm::iterator_range<CastExpr::path_const_iterator> path,
1233 bool nullCheckValue) {
1234 assert(!path.empty() &&
"Base path should not be empty!");
1237 mlir::Type derivedValueTy =
convertType(derivedTy);
1239 cgm.computeNonVirtualBaseClassOffset(derived, path);
1244 return builder.createDerivedClassAddr(loc, baseAddr, derivedValueTy,
1251 llvm::iterator_range<CastExpr::path_const_iterator> path,
1253 assert(!path.empty() &&
"Base path should not be empty!");
1258 if ((*path.begin())->isVirtual()) {
1259 vBase = (*start)->getType()->castAsCXXRecordDecl();
1266 CharUnits nonVirtualOffset =
cgm.computeNonVirtualBaseClassOffset(
1267 vBase ? vBase : derived, {start, path.end()});
1272 if (vBase && derived->
hasAttr<FinalAttr>()) {
1275 nonVirtualOffset += vBaseOffset;
1280 mlir::Type baseValueTy =
convertType((path.end()[-1])->getType());
1285 if (nonVirtualOffset.
isZero() && !vBase) {
1287 return builder.createBaseClassAddr(
getLoc(loc), value, baseValueTy, 0,
1294 mlir::Value virtualOffset =
nullptr;
1296 virtualOffset =
cgm.getCXXABI().getVirtualBaseClassOffset(
1297 getLoc(loc), *
this, value, derived, vBase);
1302 getLoc(loc), *
this, value, nonVirtualOffset, virtualOffset, derived,
1303 vBase, baseValueTy,
not nullCheckValue);
1314 if (!
cgm.getCodeGenOpts().WholeProgramVTables)
1317 if (
cgm.getCodeGenOpts().VirtualFunctionElimination)
1328 cir::VTableGetVPtrOp::create(builder, loc, thisAddr.
getPointer());
1331 auto vtable = builder.createLoad(loc, vtablePtrAddr);
1334 if (
cgm.getCodeGenOpts().OptimizationLevel > 0 &&
1335 cgm.getCodeGenOpts().StrictVTablePointers) {
1344 bool forVirtualBase,
1358 assert(e->
getNumArgs() == 1 &&
"unexpected argcount for trivial ctor");
1375 !inherited ||
cgm.getTypes().inheritingCtorHasParams(inherited,
type))
1400 "canEmitDelegateCallArgs: args-destroyed-L-to-R in callee");
1415 if (inheritedFromVBase &&
1416 cgm.getTarget().getCXXABI().hasConstructorVariants()) {
1418 "inheritedFromVBase with ctor variants");
1423 "wrong number of parameters for inherited constructor call");
1425 ctorArgs[0] = thisArg;
1427 ctorArgs.push_back(thisArg);
1429 assert(outerCtor->getNumParams() == d->
getNumParams());
1430 assert(!outerCtor->isVariadic() &&
"should have been inlined");
1432 for (
const ParmVarDecl *param : outerCtor->parameters()) {
1434 outerCtor->getParamDecl(param->getFunctionScopeIndex())->getType(),
1438 if (param->hasAttr<PassObjectSizeAttr>())
1441 "emitInheritedCXXConstructorCall: pass object size attr argument");
1451 bool forVirtualBase,
bool delegating,
CallArgList &args) {
1454 InlinedInheritingConstructorScope scope(*
this, gd);
1467 cgm.getCXXABI().addImplicitConstructorArgs(*
this, d, ctorType, forVirtualBase,
1471 assert(args.size() >= params.size() &&
"too few arguments for call");
1472 for (
auto [idx, arg, parm] :
1473 llvm::zip_longest(llvm::index_range{0, args.size()}, args, params)) {
1475 mlir::Location parmLoc =
getLoc((*parm)->getSourceRange());
1476 RValue argVal = arg->getRValue(*
this, parmLoc);
1481 (*parm)->getType());
1493 "emitInlinedInheritingCXXConstructorCall: non-void return");
1495 cgm.getCXXABI().emitInstanceFunctionProlog(loc, *
this);
1515 bool passPrototypeArgs =
true;
1520 if (passPrototypeArgs &&
1530 cgm.getCXXABI().addImplicitConstructorArgs(*
this, d,
type, forVirtualBase,
1538 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 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.
mlir::Value createAdd(mlir::Location loc, mlir::Value lhs, mlir::Value rhs, OverflowBehavior ob=OverflowBehavior::None)
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
cir::LoadOp createLoad(mlir::Location loc, Address addr, bool isVolatile=false, bool isNontemporal=false)
Address createBaseClassAddr(mlir::Location loc, Address addr, mlir::Type destType, unsigned offset, bool assumeNotNull)
cir::ConstantOp getConstInt(mlir::Location loc, llvm::APSInt intVal)
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
Address returnValue
The temporary alloca to hold the return value.
void emitCXXConstructorCall(const clang::CXXConstructorDecl *d, clang::CXXCtorType type, bool forVirtualBase, bool delegating, AggValueSlot thisAVS, const clang::CXXConstructExpr *e)
static bool hasAggregateEvaluationKind(clang::QualType type)
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...
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)
RValue emitCall(const CIRGenFunctionInfo &funcInfo, const CIRGenCallee &callee, ReturnValueSlot returnValue, const CallArgList &args, cir::CIRCallOpInterface *callOp, bool isMustTail, mlir::Location loc)
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.
const clang::TargetInfo & getTarget() const
const clang::LangOptions & getLangOpts() const
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, llvm::FoldingSetInsertToken &InsertToken)
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
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...
bool isInitializerOfDynamicClass(const CXXCtorInitializer *BaseInit)
const internal::VariadicAllOfMatcher< Type > type
Matches Types in the clang AST.
const AstTypeMatcher< ArrayType > arrayType
@ Address
A pointer to a ValueDecl.
Top level wrappers for InstallAPI frontend operations.
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 returnValueSlotFeatures()
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