clang: lib/CIR/CodeGen/CIRGenExprCXX.cpp Source File (original) (raw)

1

2

3

4

5

6

7

8

9

10

11

12

16

21

22using namespace clang;

24

25namespace {

26struct MemberCallInfo {

27 RequiredArgs reqArgs;

28

29 unsigned prefixSize;

30};

31}

32

35 mlir::Value implicitParam, QualType implicitParamTy, const CallExpr *ce,

40 "Trying to emit a member or operator call expr on a static method!");

41

42

46

47

48 if (implicitParam) {

49 args.add(RValue::get(implicitParam), implicitParamTy);

50 }

51

55 unsigned prefixSize = args.size() - 1;

56

57

58 if (rtlArgs) {

59

60

61

63 } else if (ce) {

64

68 } else {

69 assert(

70 fpt->getNumParams() == 0 &&

71 "No CallExpr specified for function with non-zero number of arguments");

72 }

73

74

75 return {required, prefixSize};

76}

77

81 const Expr *base) {

83

84

85 bool canUseVirtualCall = md->isVirtual() && !hasQualifier;

86 const CXXMethodDecl *devirtualizedMethod = nullptr;

88

89

90

91

92

93

94

95

96

97

98

101 if (auto *oce = dyn_cast(ce)) {

102 if (oce->isAssignmentOp()) {

103 rtlArgs = &rtlArgStorage;

106 0);

107 }

108 }

109

111 if (isArrow) {

116 } else {

118 }

119

122 "emitCXXMemberOrOperatorMemberCallExpr: constructor call");

124 }

125

129

130

132 devirtualizedMethod ? devirtualizedMethod : md;

134 if (const auto *dtor = dyn_cast(calleeDecl))

135 fInfo = &cgm.getTypes().arrangeCXXStructorDeclaration(

137 else

138 fInfo = &cgm.getTypes().arrangeCXXMethodDeclaration(calleeDecl);

139

140 cir::FuncType ty = cgm.getTypes().getFunctionType(*fInfo);

141

144

145

146

147

148

149

150

151 bool useVirtualCall = canUseVirtualCall && !devirtualizedMethod;

152

153 if (const auto *dtor = dyn_cast(calleeDecl)) {

155 "Destructor shouldn't have explicit parameters");

156 assert(returnValue.isNull() && "Destructor shouldn't have return value");

157 if (useVirtualCall) {

158 cgm.getCXXABI().emitVirtualDestructorCall(*this, dtor, Dtor_Complete,

161 } else {

165 if (!devirtualizedMethod) {

167 cgm.getAddrOfCXXStructor(globalDecl, fInfo, ty), globalDecl);

168 } else {

169 cgm.errorNYI(ce->getSourceRange(), "devirtualized destructor call");

171 }

172

175

176

178 nullptr,

179 QualType(), ce);

180 }

182 }

183

185 if (useVirtualCall) {

187 } else {

191 "emitCXXMemberOrOperatorMemberCallExpr: AppleKext");

193 }

194

197 }

198

201 cgm.getCXXABI().adjustThisArgumentForVirtualFunctionCall(

202 *this, calleeDecl, thisPtr.getAddress(), useVirtualCall);

204 }

205

208 nullptr, QualType(), ce, rtlArgs);

209}

210

216 "Trying to emit a member call expr on a static method!");

218 e, md, returnValue, false, std::nullopt,

219 false, e->getArg(0));

220}

221

229 *this, md, thisPtr, implicitParam, implicitParamTy, ce, args, rtlArgs);

230 auto &fnInfo = cgm.getTypes().arrangeCXXMethodCall(

231 args, fpt, callInfo.reqArgs, callInfo.prefixSize);

232 assert((ce || currSrcLoc) && "expected source location");

236}

237

242 return;

243

246

247

248

249

252

253

254

256

257

258

259

260

261

262

267 "emitNullBaseClassInitialization: base constant is not null");

268 } else {

269

270

271

272

273

274

275

276 assert(stores.size() == 1 && "Expected only one store");

278 "Expected store to begin at offset zero");

282 destPtr);

283 }

284}

285

288 assert(!dest.isIgnored() && "Must have a destination!");

290

291

292

293

294

301 break;

306 break;

307 }

308 }

309

310

312 return;

313

314

316

317

318

319

320

323 assert(

326 return;

327 }

328

332 } else {

333

335 bool forVirtualBase = false;

336 bool delegating = false;

337

341 break;

343

345 delegating = true;

346 break;

348 forVirtualBase = true;

349 [[fallthrough]];

352 break;

353 }

354

356 }

357}

358

371

373 unsigned minElements,

374 mlir::Value &numElements,

375 mlir::Value &sizeWithoutCookie) {

378

383 return sizeWithoutCookie;

384 }

385

386

388

389

390

391

392

393

394

395

396

397

398

399

400 llvm::APInt arraySizeMultiplier(sizeWidth, 1);

403 type = cat->getElementType();

404 arraySizeMultiplier *= cat->getSize();

405 }

406

408 llvm::APInt typeSizeMultiplier(sizeWidth, typeSize.getQuantity());

409 typeSizeMultiplier *= arraySizeMultiplier;

410

411

412 llvm::APInt cookieSize(sizeWidth,

414

415

416 mlir::Value size;

417

418

419

420

422 mlir::Attribute constNumElements =

425 if (constNumElements) {

426

427 const llvm::APInt &count =

428 mlir::castcir::IntAttr(constNumElements).getValue();

429

430 [[maybe_unused]] unsigned numElementsWidth = count.getBitWidth();

431 bool hasAnyOverflow = false;

432

433

434

435

436

437 assert(!count.isNegative() && "Expected non-negative array size");

438 assert(numElementsWidth == sizeWidth &&

439 "Expected a size_t array size constant");

440

441

442 llvm::APInt adjustedCount = count.zextOrTrunc(sizeWidth);

443

444

445

446

447

448

449 numElements =

451

452

453 bool overflow;

454 llvm::APInt allocationSize =

455 adjustedCount.umul_ov(typeSizeMultiplier, overflow);

456

457

458 assert(!overflow && "Overflow in array allocation size");

459

460

461 if (cookieSize != 0) {

462

463

465 loc, allocationSize.zextOrTrunc(sizeWidth));

466

467 allocationSize = allocationSize.uadd_ov(cookieSize, overflow);

468 hasAnyOverflow |= overflow;

469 }

470

471

472 if (hasAnyOverflow) {

473 size =

475 } else {

477 }

478 } else {

479

481 "emitCXXNewAllocSize: variable array size");

482 }

483

484 if (cookieSize == 0)

485 sizeWithoutCookie = size;

486 else

487 assert(sizeWithoutCookie && "didn't set sizeWithoutCookie?");

488

489 return size;

490}

491

495

500 return;

503 true);

504 return;

512 return;

513 }

514 }

515 llvm_unreachable("bad evaluation kind");

516}

517

520 Address beginPtr, mlir::Value numElements,

521 mlir::Value allocSizeWithoutCookie) {

522

523

525 return;

526

527 unsigned initListElements = 0;

528

530 const InitListExpr *ile = dyn_cast(init);

531 if (ile) {

532 cgm.errorNYI(ile->getSourceRange(), "emitNewArrayInitializer: init list");

533 return;

534 }

535

536

537

538 auto constOp = mlir::dyn_castcir::ConstantOp(numElements.getDefiningOp());

539 if (constOp) {

540 auto constIntAttr = mlir::dyn_castcir::IntAttr(constOp.getValue());

541

542 if (constIntAttr && constIntAttr.getUInt() <= initListElements)

543 return;

544 }

545

546 assert(init && "have trailing elements to initialize but no initializer");

547

548

549

550 if (const CXXConstructExpr *cce = dyn_cast(init)) {

553

554

555 if (!cce->requiresZeroInitialization())

556 return;

557

558 cgm.errorNYI(cce->getSourceRange(),

559 "emitNewArrayInitializer: trivial ctor zero-init");

560 return;

561 }

562

563 cgm.errorNYI(cce->getSourceRange(),

564 "emitNewArrayInitializer: ctor initializer");

565 return;

566 }

567

569 "emitNewArrayInitializer: unsupported initializer");

570 return;

571}

572

574 QualType elementType, mlir::Type elementTy,

575 Address newPtr, mlir::Value numElements,

576 mlir::Value allocSizeWithoutCookie) {

580 allocSizeWithoutCookie);

584 }

585}

586

589 QualType thisTy, mlir::Value implicitParam, QualType implicitParamTy,

592

593 assert(!thisTy.isNull());

595 "Pointer/Object mixup");

596

598

601 implicitParamTy, ce, args, nullptr);

602 assert((ce || dtor.getDecl()) && "expected source location provider");

604 return emitCall(cgm.getTypes().arrangeCXXStructorDeclaration(dtor), callee,

608}

609

612 QualType destroyedType = expr->getDestroyedType();

615 cgm.errorNYI(expr->getExprLoc(),

616 "emitCXXPseudoDestructorExpr: Objective-C lifetime is NYI");

617 } else {

618

619

620

621

622

624 }

625

627}

628

629

630

635 cir::CIRCallOpInterface callOrTryCall;

642

643

644

645

646

647

649 return rv;

650}

651

657

659 assert(op == OO_New || op == OO_Delete);

661

664 for (const auto *decl : lookupResult) {

665 if (const auto *funcDecl = dyn_cast(decl)) {

667 if (sanOpts.has(SanitizerKind::AllocToken)) {

668

670 cgm.errorNYI("Alloc token sanitizer not yet supported!");

671 }

672

673

675 }

676 }

677 }

678

679 llvm_unreachable("predeclared global operator new/delete is missing");

680}

681

682namespace {

683

685 mlir::Value ptr;

688

689 CallObjectDelete(mlir::Value ptr, const FunctionDecl *operatorDelete,

691 : ptr(ptr), operatorDelete(operatorDelete), elementType(elementType) {}

692

694 cgf.emitDeleteCall(operatorDelete, ptr, elementType);

695 }

696};

697}

698

699

702

703

704

705

706

708

711

712

713

716 if (rd->hasDefinition() && !rd->hasTrivialDestructor()) {

717 dtor = rd->getDestructor();

718

722 dtor);

723 return;

724 }

725 }

726 }

727

728

729

730

731 cgf.ehStack.pushCleanup(

733

734 if (dtor) {

736 false,

737 false, ptr, elementType);

741 }

742

743

744

745

747

749}

750

754

755

756

757

758

759

760

761

762

763

764

767

768

769

772 "emitCXXDeleteExpr: destroying operator delete");

773 return;

774 }

775

776

779

781 cgm.getASTContext().getTargetInfo().emitVectorDeletingDtors(

782 cgm.getASTContext().getLangOpts())) {

784 "emitCXXDeleteExpr: emitVectorDeletingDtors");

785 }

786

789 cgm.errorNYI(e->getSourceRange(), "emitCXXDeleteExpr: array delete");

790 return;

791 } else {

793 }

794}

795

797

799

800

802

803

804 unsigned minElements = 0;

805

806 mlir::Value numElements = nullptr;

807 mlir::Value allocSizeWithoutCookie = nullptr;

809 *this, e, minElements, numElements, allocSizeWithoutCookie);

811

812

815 if (allocator->isReservedGlobalPlacementOperator()) {

816

817

820

823

824

825

826

828 allocation = allocation.withAlignment(allocAlign);

829

830

831

835 "emitCXXNewExpr: reserved placement new with delete");

836 }

837 } else {

840 unsigned paramsToSkip = 0;

841

842

845 ++paramsToSkip;

846

847 if (allocSize != allocSizeWithoutCookie) {

849 allocAlign = std::max(allocAlign, cookieAlign);

850 }

851

852

854 cgm.errorNYI(e->getSourceRange(), "emitCXXNewExpr: pass alignment");

855 }

856

857

861 emitNewDeleteCall(*this, allocator, allocatorType, allocatorArgs);

862

863

865

866

867

868

869

870 CharUnits allocationAlign = allocAlign;

872 allocator->isReplaceableGlobalAllocationFunction()) {

873 const TargetInfo &target = cgm.getASTContext().getTargetInfo();

874 unsigned allocatorAlign = llvm::bit_floor(std::min<uint64_t>(

876 allocationAlign = std::max(

877 allocationAlign, getContext().toCharUnitsFromBits(allocatorAlign));

878 }

879

880 mlir::Value allocPtr = rv.getValue();

882 allocPtr, mlir::castcir::PointerType(allocPtr.getType()).getPointee(),

883 allocationAlign);

884 }

885

886

887

888

889

893 if (nullCheck)

895

896

897

900 cgm.errorNYI(e->getSourceRange(), "emitCXXNewExpr: operator delete");

901

902 if (allocSize != allocSizeWithoutCookie) {

904 allocation = cgm.getCXXABI().initializeArrayCookie(

905 *this, allocation, numElements, e, allocType);

906 }

907

908 mlir::Type elementTy;

910

911

913 } else {

915 }

917 allocation, elementTy);

918

919

920

921

922

923 if (cgm.getCodeGenOpts().StrictVTablePointers &&

924 allocator->isReservedGlobalPlacementOperator())

925 cgm.errorNYI(e->getSourceRange(), "emitCXXNewExpr: strict vtable pointers");

926

928

929 emitNewInitializer(*this, e, allocType, elementTy, result, numElements,

930 allocSizeWithoutCookie);

932}

933

935 mlir::Value ptr, QualType deleteTy) {

937

940

942 auto paramTypeIt = deleteFTy->param_type_begin();

943

944

947 "emitDeleteCall: type aware delete");

948

949

950 QualType argTy = *paramTypeIt++;

951 mlir::Value deletePtr =

952 builder.createBitcast(ptr.getLoc(), ptr, convertType(argTy));

953 deleteArgs.add(RValue::get(deletePtr), argTy);

954

955

958 "emitDeleteCall: destroying delete");

959

960

961 if (params.Size) {

962 QualType sizeType = *paramTypeIt++;

964 assert(mlir::isacir::IntType(convertType(sizeType)) &&

965 "expected cir::IntType");

966 cir::ConstantOp size = builder.getConstInt(

968

969 deleteArgs.add(RValue::get(size), sizeType);

970 }

971

972

975 "emitDeleteCall: aligned allocation");

976

977 assert(paramTypeIt == deleteFTy->param_type_end() &&

978 "unknown parameter to usual delete function");

979

980

982}

983

985 mlir::Location loc, QualType destTy) {

986 mlir::Type destCIRTy = cgf.convertType(destTy);

987 assert(mlir::isacir::PointerType(destCIRTy) &&

988 "result of dynamic_cast should be a ptr");

989

991 mlir::Region *currentRegion = cgf.getBuilder().getBlock()->getParent();

992

993

995

996

997

998 cgf.getBuilder().createBlock(currentRegion, currentRegion->end());

999 }

1000

1002}

1003

1007

1008 cgm.emitExplicitCastExprType(dce, this);

1011

1012

1013

1014

1017

1020 if (isDynCastToVoid) {

1022

1026 } else {

1027 srcRecordTy = srcTy;

1029 }

1030

1031 assert(srcRecordTy->isRecordType() && "source type must be a record type!");

1033

1036

1037 auto destCirTy = mlir::castcir::PointerType(convertType(destTy));

1038 return cgm.getCXXABI().emitDynamicCast(*this, loc, srcRecordTy, destRecordTy,

1039 destCirTy, isRefCast, thisAddr);

1040}

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 void emitNewInitializer(CIRGenFunction &cgf, const CXXNewExpr *e, QualType elementType, mlir::Type elementTy, Address newPtr, mlir::Value numElements, mlir::Value allocSizeWithoutCookie)

Definition CIRGenExprCXX.cpp:573

static void emitObjectDelete(CIRGenFunction &cgf, const CXXDeleteExpr *de, Address ptr, QualType elementType)

Emit the code for deleting a single object.

Definition CIRGenExprCXX.cpp:700

static void emitNullBaseClassInitialization(CIRGenFunction &cgf, Address destPtr, const CXXRecordDecl *base)

Definition CIRGenExprCXX.cpp:238

static mlir::Value emitCXXNewAllocSize(CIRGenFunction &cgf, const CXXNewExpr *e, unsigned minElements, mlir::Value &numElements, mlir::Value &sizeWithoutCookie)

Definition CIRGenExprCXX.cpp:372

static void storeAnyExprIntoOneUnit(CIRGenFunction &cgf, const Expr *init, QualType allocType, Address newPtr, AggValueSlot::Overlap_t mayOverlap)

Definition CIRGenExprCXX.cpp:492

static CharUnits calculateCookiePadding(CIRGenFunction &cgf, const CXXNewExpr *e)

Definition CIRGenExprCXX.cpp:359

static mlir::Value emitDynamicCastToNull(CIRGenFunction &cgf, mlir::Location loc, QualType destTy)

Definition CIRGenExprCXX.cpp:984

static MemberCallInfo commonBuildCXXMemberOrOperatorCall(CIRGenFunction &cgf, const CXXMethodDecl *md, mlir::Value thisPtr, mlir::Value implicitParam, QualType implicitParamTy, const CallExpr *ce, CallArgList &args, CallArgList *rtlArgs)

Definition CIRGenExprCXX.cpp:33

static RValue emitNewDeleteCall(CIRGenFunction &cgf, const FunctionDecl *calleeDecl, const FunctionProtoType *calleeType, const CallArgList &args)

Emit a call to an operator new or operator delete function, as implicitly created by new-expressions ...

Definition CIRGenExprCXX.cpp:631

Defines the C++ Decl subclasses, other than those for templates (found in DeclTemplate....

Defines the clang::Expr interface and subclasses for C++ expressions.

Defines an enumeration for C++ overloaded operators.

static QualType getPointeeType(const MemRegion *R)

cir::ConstantOp getConstant(mlir::Location loc, mlir::TypedAttr attr)

cir::ConstantOp getNullPtr(mlir::Type ty, mlir::Location loc)

llvm::TypeSize getTypeSizeInBits(mlir::Type ty) const

Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...

TranslationUnitDecl * getTranslationUnitDecl() const

const ConstantArrayType * getAsConstantArrayType(QualType T) const

CharUnits getTypeAlignInChars(QualType T) const

Return the ABI-specified alignment of a (complete) type T, in characters.

DeclarationNameTable DeclarationNames

const ASTRecordLayout & getASTRecordLayout(const RecordDecl *D) const

Get or compute information about the layout of the specified record (struct/union/class) D,...

QualType getBaseElementType(const ArrayType *VAT) const

Return the innermost element type of an array type.

CharUnits getTypeSizeInChars(QualType T) const

Return the size of the specified (complete) type T, in characters.

static bool hasSameType(QualType T1, QualType T2)

Determine whether the given types T1 and T2 are equivalent.

QualType getSizeType() const

Return the unique type for "size_t" (C99 7.17), defined in <stddef.h>.

ASTRecordLayout - This class contains layout information for one RecordDecl, which is a struct/union/...

CharUnits getNonVirtualSize() const

getNonVirtualSize - Get the non-virtual size (in chars) of an object, which is the size of the object...

Represents an array type, per C99 6.7.5.2 - Array Declarators.

mlir::Value getPointer() const

Address withElementType(CIRGenBuilderTy &builder, mlir::Type ElemTy) const

Return address with different element type, a bitcast pointer, and the same alignment.

Address withAlignment(clang::CharUnits newAlignment) const

Return address with different alignment, but same pointer and element type.

IsZeroed_t isZeroed() const

static AggValueSlot forAddr(Address addr, clang::Qualifiers quals, IsDestructed_t isDestructed, IsAliased_t isAliased, Overlap_t mayOverlap, IsZeroed_t isZeroed=IsNotZeroed)

Address getAddress() const

bool isNullValue(mlir::Attribute attr) const

cir::StoreOp createStore(mlir::Location loc, mlir::Value val, Address dst, bool isVolatile=false, mlir::IntegerAttr align={}, cir::SyncScopeKindAttr scope={}, cir::MemOrderAttr order={})

cir::ConstantOp getConstInt(mlir::Location loc, llvm::APSInt intVal)

virtual void emitVirtualObjectDelete(CIRGenFunction &cgf, const CXXDeleteExpr *de, Address ptr, QualType elementType, const CXXDestructorDecl *dtor)=0

virtual const clang::CXXRecordDecl * getThisArgumentTypeForMethod(const clang::CXXMethodDecl *md)

Get the type of the implicit "this" parameter used by a method.

virtual void emitBadCastCall(CIRGenFunction &cgf, mlir::Location loc)=0

virtual CharUnits getArrayCookieSize(const CXXNewExpr *e)

Returns the extra size required in order to store the array cookie for the given new-expression.

static CIRGenCallee forDirect(mlir::Operation *funcPtr, const CIRGenCalleeInfo &abstractInfo=CIRGenCalleeInfo())

static CIRGenCallee forVirtual(const clang::CallExpr *ce, clang::GlobalDecl md, Address addr, cir::FuncType fTy)

An abstract representation of regular/ObjC call/message targets.

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...

CIRGenTypes & getTypes() const

Address emitPointerWithAlignment(const clang::Expr *expr, LValueBaseInfo *baseInfo=nullptr)

Given an expression with a pointer type, emit the value and compute our best estimate of the alignmen...

const clang::LangOptions & getLangOpts() const

void emitDeleteCall(const FunctionDecl *deleteFD, mlir::Value ptr, QualType deleteTy)

Definition CIRGenExprCXX.cpp:934

LValue emitLValue(const clang::Expr *e)

Emit code to compute a designator that specifies the location of the expression.

mlir::Location getLoc(clang::SourceLocation srcLoc)

Helpers to convert Clang's SourceLocation to a MLIR Location.

RValue emitCXXMemberOrOperatorCall(const clang::CXXMethodDecl *md, const CIRGenCallee &callee, ReturnValueSlot returnValue, mlir::Value thisPtr, mlir::Value implicitParam, clang::QualType implicitParamTy, const clang::CallExpr *ce, CallArgList *rtlArgs)

Definition CIRGenExprCXX.cpp:222

void emitNullInitialization(mlir::Location loc, Address destPtr, QualType ty)

EHScopeStack ehStack

Tracks function scope overall cleanup handling.

void emitNewArrayInitializer(const CXXNewExpr *e, QualType elementType, mlir::Type elementTy, Address beginPtr, mlir::Value numElements, mlir::Value allocSizeWithoutCookie)

Definition CIRGenExprCXX.cpp:518

clang::SanitizerSet sanOpts

Sanitizers enabled for this function.

mlir::Type convertTypeForMem(QualType t)

void emitCXXConstructExpr(const clang::CXXConstructExpr *e, AggValueSlot dest)

Definition CIRGenExprCXX.cpp:286

mlir::Value emitCXXNewExpr(const CXXNewExpr *e)

Definition CIRGenExprCXX.cpp:796

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)

void emitScalarInit(const clang::Expr *init, mlir::Location loc, LValue lvalue, bool capturedByInit=false)

RValue emitCall(const CIRGenFunctionInfo &funcInfo, const CIRGenCallee &callee, ReturnValueSlot returnValue, const CallArgList &args, cir::CIRCallOpInterface *callOp, mlir::Location loc)

CIRGenBuilderTy & getBuilder()

void emitComplexExprIntoLValue(const Expr *e, LValue dest, bool isInit)

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)

RValue emitNewOrDeleteBuiltinCall(const FunctionProtoType *type, const CallExpr *callExpr, OverloadedOperatorKind op)

Definition CIRGenExprCXX.cpp:652

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.

std::optional< mlir::Location > currSrcLoc

Use to track source locations across nested visitor traversals.

clang::ASTContext & getContext() const

RValue emitCXXMemberOrOperatorMemberCallExpr(const clang::CallExpr *ce, const clang::CXXMethodDecl *md, ReturnValueSlot returnValue, bool hasQualifier, clang::NestedNameSpecifier qualifier, bool isArrow, const clang::Expr *base)

Definition CIRGenExprCXX.cpp:78

void emitCXXDeleteExpr(const CXXDeleteExpr *e)

Definition CIRGenExprCXX.cpp:751

RValue emitCXXOperatorMemberCallExpr(const CXXOperatorCallExpr *e, const CXXMethodDecl *md, ReturnValueSlot returnValue)

Definition CIRGenExprCXX.cpp:212

void emitIgnoredExpr(const clang::Expr *e)

Emit code to compute the specified expression, ignoring the result.

mlir::Value emitDynamicCast(Address thisAddr, const CXXDynamicCastExpr *dce)

Definition CIRGenExprCXX.cpp:1004

void emitAggExpr(const clang::Expr *e, AggValueSlot slot)

void popCleanupBlock()

Pops a cleanup block.

RValue emitCXXPseudoDestructorExpr(const CXXPseudoDestructorExpr *expr)

Definition CIRGenExprCXX.cpp:610

DiagnosticBuilder errorNYI(SourceLocation, llvm::StringRef)

Helpers to emit "not yet implemented" error diagnostics.

mlir::TypedAttr emitNullConstantForBase(const CXXRecordDecl *record)

Return a null constant appropriate for zero-initializing a base class with the given type.

cir::FuncOp getAddrOfFunction(clang::GlobalDecl gd, mlir::Type funcType=nullptr, bool forVTable=false, bool dontDefer=false, ForDefinition_t isForDefinition=NotForDefinition)

Return the address of the given function.

const cir::CIRDataLayout getDataLayout() const

CIRGenCXXABI & getCXXABI() const

const CIRGenFunctionInfo & arrangeFreeFunctionCall(const CallArgList &args, const FunctionType *fnType)

clang::CanQualType deriveThisType(const clang::CXXRecordDecl *rd, const clang::CXXMethodDecl *md)

Derives the 'this' type for CIRGen purposes, i.e.

void addFrom(const CallArgList &other)

Add all the arguments from another CallArgList to this one.

void add(RValue rvalue, clang::QualType type)

mlir::Attribute emitAbstract(const Expr *e, QualType destType)

Emit the result of the given expression as an abstract constant, asserting that it succeeded.

Information for lazily generating a cleanup.

AlignmentSource getAlignmentSource() const

Address getAddress() const

mlir::Value getPointer() const

void setAddress(Address address)

This trivial value class is used to represent the result of an expression that is evaluated.

static RValue get(mlir::Value v)

mlir::Value getValue() const

Return the value of this scalar value.

A class for recording the number of arguments that a function signature requires.

static RequiredArgs getFromProtoWithExtraSlots(const clang::FunctionProtoType *prototype, unsigned additional)

Compute the arguments required by the given formal prototype, given that there may be some additional...

Contains the address where the return value of a function can be stored, and whether the address is v...

Represents a call to a C++ constructor.

bool isElidable() const

Whether this construction is elidable.

Expr * getArg(unsigned Arg)

Return the specified argument.

bool requiresZeroInitialization() const

Whether this construction first requires zero-initialization before the initializer is called.

CXXConstructorDecl * getConstructor() const

Get the constructor that this expression will (ultimately) call.

CXXConstructionKind getConstructionKind() const

Determine whether this constructor is actually constructing a base class (rather than a complete obje...

Represents a C++ constructor within a class.

bool isDefaultConstructor() const

Whether this constructor is a default constructor (C++ [class.ctor]p5), which can be used to default-...

Represents a delete expression for memory deallocation and destructor calls, e.g.

FunctionDecl * getOperatorDelete() const

QualType getDestroyedType() const

Retrieve the type being destroyed.

Represents a C++ destructor within a class.

A C++ dynamic_cast expression (C++ [expr.dynamic.cast]).

bool isAlwaysNull() const

isAlwaysNull - Return whether the result of the dynamic_cast is proven to always be null.

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.

Represents a new-expression for memory allocation and constructor calls, e.g: "new CXXNewExpr(foo)".

llvm::iterator_range< arg_iterator > placement_arguments()

QualType getAllocatedType() const

std::optional< Expr * > getArraySize()

This might return std::nullopt even if isArray() returns true, since there might not be an array size...

bool hasInitializer() const

Whether this new-expression has any initializer at all.

bool shouldNullCheckAllocation() const

True if the allocation result needs to be null-checked.

bool passAlignment() const

Indicates whether the required alignment should be implicitly passed to the allocation function.

FunctionDecl * getOperatorDelete() const

unsigned getNumPlacementArgs() const

SourceRange getSourceRange() const

FunctionDecl * getOperatorNew() const

Expr * getInitializer()

The initializer of this new-expression.

A call to an overloaded operator written using operator syntax.

Represents a C++ pseudo-destructor (C++ [expr.pseudo]).

Represents a C++ struct/union/class.

bool isEmpty() const

Determine whether this is an empty class in the sense of (C++11 [meta.unary.prop]).

CallExpr - Represents a function call (C99 6.5.2.2, C++ [expr.call]).

Expr * getArg(unsigned Arg)

getArg - Return the specified argument.

FunctionDecl * getDirectCallee()

If the callee is a FunctionDecl, return it. Otherwise return null.

CharUnits - This is an opaque type for sizes expressed in character units.

QuantityType getQuantity() const

getQuantity - Get the raw integer representation of this quantity.

static CharUnits Zero()

Zero - Construct a CharUnits quantity of zero.

Represents the canonical version of C arrays with a specified constant size.

The results of name lookup within a DeclContext.

lookup_result lookup(DeclarationName Name) const

lookup - Find the declarations (if any) with the given Name in this context.

virtual SourceRange getSourceRange() const LLVM_READONLY

Source range that this declaration covers.

The name of a declaration.

QualType getTypeAsWritten() const

getTypeAsWritten - Returns the type that this expression is casting to, as written in the source code...

This represents one expression.

bool isTemporaryObject(ASTContext &Ctx, const CXXRecordDecl *TempTy) const

Determine whether the result of this expression is a temporary object of the given class type.

SourceLocation getExprLoc() const LLVM_READONLY

getExprLoc - Return the preferred location for the arrow when diagnosing a problem with a generic exp...

Represents a function declaration or definition.

bool isDestroyingOperatorDelete() const

Determine whether this is a destroying operator delete.

bool isTrivial() const

Whether this function is "trivial" in some specialized C++ senses.

UsualDeleteParams getUsualDeleteParams() const

bool isReservedGlobalPlacementOperator() const

Determines whether this operator new or delete is one of the reserved global placement operators: voi...

bool isDefaulted() const

Whether this function is defaulted.

SourceRange getSourceRange() const override LLVM_READONLY

Source range that this declaration covers.

Represents a prototype with parameter type info, e.g.

GlobalDecl - represents a global declaration.

const Decl * getDecl() const

Describes an C or C++ initializer list.

Represents a C++ nested name specifier, such as "\::std::vector::".

PointerType - C99 6.7.5.1 - Pointer Declarators.

A (possibly-)qualified type.

bool isNull() const

Return true if this QualType doesn't point to a type yet.

Qualifiers getQualifiers() const

Retrieve the set of qualifiers applied to this type.

Qualifiers::ObjCLifetime getObjCLifetime() const

Returns lifetime attribute of this type.

bool isPODType(const ASTContext &Context) const

Determine whether this is a Plain Old Data (POD) type (C++ 3.9p10).

bool hasStrongOrWeakObjCLifetime() const

Base for LValueReferenceType and RValueReferenceType.

SourceRange getSourceRange() const LLVM_READONLY

SourceLocation tokens are not useful in isolation - they are low level value objects created/interpre...

SourceRange getSourceRange() const override LLVM_READONLY

Source range that this declaration covers.

Exposes information about the current target.

unsigned getNewAlign() const

Return the largest alignment for which a suitably-sized allocation with 'operator new(size_t)' is gua...

SourceLocation getBeginLoc() const LLVM_READONLY

CXXRecordDecl * getAsCXXRecordDecl() const

Retrieves the CXXRecordDecl that this type refers to, either because the type is a RecordType or beca...

bool isVoidPointerType() const

bool isPointerType() const

const T * castAs() const

Member-template castAs.

bool isReferenceType() const

QualType getPointeeType() const

If this is a pointer, ObjC object pointer, or block pointer, this returns the respective pointee.

const T * getAs() const

Member-template getAs'.

bool isRecordType() const

@ Decl

The l-value was an access to a declared entity or something equivalently strong, like the address of ...

const internal::VariadicDynCastAllOfMatcher< Stmt, CallExpr > callExpr

Matches call expressions.

const internal::VariadicAllOfMatcher< Type > type

Matches Types in the clang AST.

const AstTypeMatcher< ArrayType > arrayType

const internal::VariadicAllOfMatcher< Decl > decl

Matches declarations.

const internal::VariadicDynCastAllOfMatcher< Stmt, Expr > expr

Matches expressions.

The JSON file list parser is used to communicate input to InstallAPI.

OverloadedOperatorKind

Enumeration specifying the different kinds of C++ overloaded operators.

CXXCtorType

C++ constructor types.

@ Ctor_Base

Base object ctor.

@ Ctor_Complete

Complete object ctor.

bool isa(CodeGen::Address addr)

bool isAlignedAllocation(AlignedAllocationMode Mode)

@ Dtor_Complete

Complete object dtor.

bool isTypeAwareAllocation(TypeAwareAllocationMode Mode)

U cast(CodeGen::Address addr)

static bool objCLifetime()

static bool addressSpace()

static bool devirtualizeDestructor()

static bool aggValueSlotGC()

static bool devirtualizeMemberFunction()

static bool deleteArray()

static bool emitTypeCheck()

static bool opCallMustTail()

static bool exprNewNullCheck()

static bool attributeBuiltin()

static bool emitNullCheckForDeleteCalls()

static bool generateDebugInfo()

clang::CharUnits getSizeAlign() const

The parameters to pass to a usual operator delete.

TypeAwareAllocationMode TypeAwareDelete

AlignedAllocationMode Alignment