clang 22.0.0git
CIRGenCXXExpr.cpp
Go to the documentation of this file.
1//===--- CIRGenExprCXX.cpp - Emit CIR Code for C++ expressions ------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8//
9// This contains code dealing with code generation of C++ expressions
10//
11//===----------------------------------------------------------------------===//
12
13#include "CIRGenCXXABI.h"
14#include "CIRGenFunction.h"
15
16#include "clang/AST/DeclCXX.h"
17#include "clang/AST/ExprCXX.h"
19
20using namespace clang;
21using namespace clang::CIRGen;
22
23namespace {
24struct MemberCallInfo {
25 RequiredArgs reqArgs;
26 // Number of prefix arguments for the call. Ignores the `this` pointer.
27 unsigned prefixSize;
28};
29} // namespace
30
32 CIRGenFunction &cgf, const CXXMethodDecl *md, mlir::Value thisPtr,
33 mlir::Value implicitParam, QualType implicitParamTy, const CallExpr *ce,
34 CallArgList &args, CallArgList *rtlArgs) {
35 assert(ce == nullptr || isa<CXXMemberCallExpr>(ce) ||
36 isa<CXXOperatorCallExpr>(ce));
37 assert(md->isInstance() &&
38 "Trying to emit a member or operator call expr on a static method!");
39
40 // Push the this ptr.
41 const CXXRecordDecl *rd =
43 args.add(RValue::get(thisPtr), cgf.getTypes().deriveThisType(rd, md));
44
45 // If there is an implicit parameter (e.g. VTT), emit it.
46 if (implicitParam) {
47 args.add(RValue::get(implicitParam), implicitParamTy);
48 }
49
50 const auto *fpt = md->getType()->castAs<FunctionProtoType>();
51 RequiredArgs required =
53 unsigned prefixSize = args.size() - 1;
54
55 // Add the rest of the call args
56 if (rtlArgs) {
57 // Special case: if the caller emitted the arguments right-to-left already
58 // (prior to emitting the *this argument), we're done. This happens for
59 // assignment operators.
60 args.addFrom(*rtlArgs);
61 } else if (ce) {
62 // Special case: skip first argument of CXXOperatorCall (it is "this").
63 unsigned argsToSkip = isa<CXXOperatorCallExpr>(ce) ? 1 : 0;
64 cgf.emitCallArgs(args, fpt, drop_begin(ce->arguments(), argsToSkip),
65 ce->getDirectCallee());
66 } else {
67 assert(
68 fpt->getNumParams() == 0 &&
69 "No CallExpr specified for function with non-zero number of arguments");
70 }
71
72 // return {required, prefixSize};
73 return {required, prefixSize};
74}
75
77 const CallExpr *ce, const CXXMethodDecl *md, ReturnValueSlot returnValue,
78 bool hasQualifier, NestedNameSpecifier qualifier, bool isArrow,
79 const Expr *base) {
80 assert(isa<CXXMemberCallExpr>(ce) || isa<CXXOperatorCallExpr>(ce));
81
82 // Compute the object pointer.
83 bool canUseVirtualCall = md->isVirtual() && !hasQualifier;
84 const CXXMethodDecl *devirtualizedMethod = nullptr;
86
87 // Note on trivial assignment
88 // --------------------------
89 // Classic codegen avoids generating the trivial copy/move assignment operator
90 // when it isn't necessary, choosing instead to just produce IR with an
91 // equivalent effect. We have chosen not to do that in CIR, instead emitting
92 // trivial copy/move assignment operators and allowing later transformations
93 // to optimize them away if appropriate.
94
95 // C++17 demands that we evaluate the RHS of a (possibly-compound) assignment
96 // operator before the LHS.
97 CallArgList rtlArgStorage;
98 CallArgList *rtlArgs = nullptr;
99 if (auto *oce = dyn_cast<CXXOperatorCallExpr>(ce)) {
100 if (oce->isAssignmentOp()) {
101 rtlArgs = &rtlArgStorage;
102 emitCallArgs(*rtlArgs, md->getType()->castAs<FunctionProtoType>(),
103 drop_begin(ce->arguments(), 1), ce->getDirectCallee(),
104 /*ParamsToSkip*/ 0);
105 }
106 }
107
108 LValue thisPtr;
109 if (isArrow) {
110 LValueBaseInfo baseInfo;
112 Address thisValue = emitPointerWithAlignment(base, &baseInfo);
113 thisPtr = makeAddrLValue(thisValue, base->getType(), baseInfo);
114 } else {
115 thisPtr = emitLValue(base);
116 }
117
118 if (isa<CXXConstructorDecl>(md)) {
120 "emitCXXMemberOrOperatorMemberCallExpr: constructor call");
121 return RValue::get(nullptr);
122 }
123
124 if ((md->isTrivial() || (md->isDefaulted() && md->getParent()->isUnion())) &&
125 isa<CXXDestructorDecl>(md))
126 return RValue::get(nullptr);
127
128 // Compute the function type we're calling
129 const CXXMethodDecl *calleeDecl =
130 devirtualizedMethod ? devirtualizedMethod : md;
131 const CIRGenFunctionInfo *fInfo = nullptr;
132 if (isa<CXXDestructorDecl>(calleeDecl)) {
134 "emitCXXMemberOrOperatorMemberCallExpr: destructor call");
135 return RValue::get(nullptr);
136 }
137
138 fInfo = &cgm.getTypes().arrangeCXXMethodDeclaration(calleeDecl);
139
140 cir::FuncType ty = cgm.getTypes().getFunctionType(*fInfo);
141
144
145 // C++ [class.virtual]p12:
146 // Explicit qualification with the scope operator (5.1) suppresses the
147 // virtual call mechanism.
148 //
149 // We also don't emit a virtual call if the base expression has a record type
150 // because then we know what the type is.
151 bool useVirtualCall = canUseVirtualCall && !devirtualizedMethod;
152
153 if (isa<CXXDestructorDecl>(calleeDecl)) {
155 "emitCXXMemberOrOperatorMemberCallExpr: destructor call");
156 return RValue::get(nullptr);
157 }
158
159 CIRGenCallee callee;
160 if (useVirtualCall) {
161 callee = CIRGenCallee::forVirtual(ce, md, thisPtr.getAddress(), ty);
162 } else {
164 if (getLangOpts().AppleKext) {
166 "emitCXXMemberOrOperatorMemberCallExpr: AppleKext");
167 return RValue::get(nullptr);
168 }
169
170 callee = CIRGenCallee::forDirect(cgm.getAddrOfFunction(calleeDecl, ty),
171 GlobalDecl(calleeDecl));
172 }
173
174 if (md->isVirtual()) {
175 Address newThisAddr =
177 *this, calleeDecl, thisPtr.getAddress(), useVirtualCall);
178 thisPtr.setAddress(newThisAddr);
179 }
180
182 calleeDecl, callee, returnValue, thisPtr.getPointer(),
183 /*ImplicitParam=*/nullptr, QualType(), ce, rtlArgs);
184}
185
186RValue
188 const CXXMethodDecl *md,
189 ReturnValueSlot returnValue) {
190 assert(md->isInstance() &&
191 "Trying to emit a member call expr on a static method!");
193 e, md, returnValue, /*HasQualifier=*/false, /*Qualifier=*/std::nullopt,
194 /*IsArrow=*/false, e->getArg(0));
195}
196
198 const CXXMethodDecl *md, const CIRGenCallee &callee,
199 ReturnValueSlot returnValue, mlir::Value thisPtr, mlir::Value implicitParam,
200 QualType implicitParamTy, const CallExpr *ce, CallArgList *rtlArgs) {
201 const auto *fpt = md->getType()->castAs<FunctionProtoType>();
202 CallArgList args;
203 MemberCallInfo callInfo = commonBuildCXXMemberOrOperatorCall(
204 *this, md, thisPtr, implicitParam, implicitParamTy, ce, args, rtlArgs);
205 auto &fnInfo = cgm.getTypes().arrangeCXXMethodCall(
206 args, fpt, callInfo.reqArgs, callInfo.prefixSize);
207 assert((ce || currSrcLoc) && "expected source location");
208 mlir::Location loc = ce ? getLoc(ce->getExprLoc()) : *currSrcLoc;
210 return emitCall(fnInfo, callee, returnValue, args, nullptr, loc);
211}
212
213static mlir::Value emitCXXNewAllocSize(CIRGenFunction &cgf, const CXXNewExpr *e,
214 unsigned minElements,
215 mlir::Value &numElements,
216 mlir::Value &sizeWithoutCookie) {
218 mlir::Location loc = cgf.getLoc(e->getSourceRange());
219
220 if (!e->isArray()) {
222 sizeWithoutCookie = cgf.getBuilder().getConstant(
223 loc, cir::IntAttr::get(cgf.SizeTy, typeSize.getQuantity()));
224 return sizeWithoutCookie;
225 }
226
227 cgf.cgm.errorNYI(e->getSourceRange(), "emitCXXNewAllocSize: array");
228 return {};
229}
230
231static void storeAnyExprIntoOneUnit(CIRGenFunction &cgf, const Expr *init,
232 QualType allocType, Address newPtr,
233 AggValueSlot::Overlap_t mayOverlap) {
234 // FIXME: Refactor with emitExprAsInit.
235 switch (cgf.getEvaluationKind(allocType)) {
236 case cir::TEK_Scalar:
237 cgf.emitScalarInit(init, cgf.getLoc(init->getSourceRange()),
238 cgf.makeAddrLValue(newPtr, allocType), false);
239 return;
240 case cir::TEK_Complex:
241 cgf.cgm.errorNYI(init->getSourceRange(),
242 "storeAnyExprIntoOneUnit: complex");
243 return;
244 case cir::TEK_Aggregate: {
248 newPtr, allocType.getQualifiers(), AggValueSlot::IsDestructed,
250 cgf.emitAggExpr(init, slot);
251 return;
252 }
253 }
254 llvm_unreachable("bad evaluation kind");
255}
256
258 QualType elementType, mlir::Type elementTy,
259 Address newPtr, mlir::Value numElements,
260 mlir::Value allocSizeWithoutCookie) {
262 if (e->isArray()) {
263 cgf.cgm.errorNYI(e->getSourceRange(), "emitNewInitializer: array");
264 } else if (const Expr *init = e->getInitializer()) {
265 storeAnyExprIntoOneUnit(cgf, init, e->getAllocatedType(), newPtr,
267 }
268}
269
271 GlobalDecl dtor, const CIRGenCallee &callee, mlir::Value thisVal,
272 QualType thisTy, mlir::Value implicitParam, QualType implicitParamTy,
273 const CallExpr *ce) {
274 const CXXMethodDecl *dtorDecl = cast<CXXMethodDecl>(dtor.getDecl());
275
276 assert(!thisTy.isNull());
277 assert(thisTy->getAsCXXRecordDecl() == dtorDecl->getParent() &&
278 "Pointer/Object mixup");
279
281
282 CallArgList args;
283 commonBuildCXXMemberOrOperatorCall(*this, dtorDecl, thisVal, implicitParam,
284 implicitParamTy, ce, args, nullptr);
285 assert((ce || dtor.getDecl()) && "expected source location provider");
287 return emitCall(cgm.getTypes().arrangeCXXStructorDeclaration(dtor), callee,
288 ReturnValueSlot(), args, nullptr,
289 ce ? getLoc(ce->getExprLoc())
290 : getLoc(dtor.getDecl()->getSourceRange()));
291}
292
293/// Emit a call to an operator new or operator delete function, as implicitly
294/// created by new-expressions and delete-expressions.
296 const FunctionDecl *calleeDecl,
297 const FunctionProtoType *calleeType,
298 const CallArgList &args) {
299 cir::CIRCallOpInterface callOrTryCall;
300 cir::FuncOp calleePtr = cgf.cgm.getAddrOfFunction(calleeDecl);
301 CIRGenCallee callee =
302 CIRGenCallee::forDirect(calleePtr, GlobalDecl(calleeDecl));
303 RValue rv =
304 cgf.emitCall(cgf.cgm.getTypes().arrangeFreeFunctionCall(args, calleeType),
305 callee, ReturnValueSlot(), args, &callOrTryCall);
306
307 /// C++1y [expr.new]p10:
308 /// [In a new-expression,] an implementation is allowed to omit a call
309 /// to a replaceable global allocation function.
310 ///
311 /// We model such elidable calls with the 'builtin' attribute.
313 return rv;
314}
315
317 // The element type being allocated.
319
320 // 1. Build a call to the allocation function.
321 FunctionDecl *allocator = e->getOperatorNew();
322
323 // If there is a brace-initializer, cannot allocate fewer elements than inits.
324 unsigned minElements = 0;
325 if (e->isArray() && e->hasInitializer()) {
326 cgm.errorNYI(e->getSourceRange(), "emitCXXNewExpr: array initializer");
327 }
328
329 mlir::Value numElements = nullptr;
330 mlir::Value allocSizeWithoutCookie = nullptr;
331 mlir::Value allocSize = emitCXXNewAllocSize(
332 *this, e, minElements, numElements, allocSizeWithoutCookie);
333 CharUnits allocAlign = getContext().getTypeAlignInChars(allocType);
334
335 // Emit the allocation call.
336 Address allocation = Address::invalid();
337 CallArgList allocatorArgs;
338 if (allocator->isReservedGlobalPlacementOperator()) {
340 "emitCXXNewExpr: reserved global placement operator");
341 } else {
342 const FunctionProtoType *allocatorType =
343 allocator->getType()->castAs<FunctionProtoType>();
344 unsigned paramsToSkip = 0;
345
346 // The allocation size is the first argument.
347 QualType sizeType = getContext().getSizeType();
348 allocatorArgs.add(RValue::get(allocSize), sizeType);
349 ++paramsToSkip;
350
351 if (allocSize != allocSizeWithoutCookie) {
352 CharUnits cookieAlign = getSizeAlign(); // FIXME: Ask the ABI.
353 allocAlign = std::max(allocAlign, cookieAlign);
354 }
355
356 // The allocation alignment may be passed as the second argument.
357 if (e->passAlignment()) {
358 cgm.errorNYI(e->getSourceRange(), "emitCXXNewExpr: pass alignment");
359 }
360
361 // FIXME: Why do we not pass a CalleeDecl here?
362 emitCallArgs(allocatorArgs, allocatorType, e->placement_arguments(),
363 AbstractCallee(), paramsToSkip);
364 RValue rv =
365 emitNewDeleteCall(*this, allocator, allocatorType, allocatorArgs);
366
367 // Set !heapallocsite metadata on the call to operator new.
369
370 // If this was a call to a global replaceable allocation function that does
371 // not take an alignment argument, the allocator is known to produce storage
372 // that's suitably aligned for any object that fits, up to a known
373 // threshold. Otherwise assume it's suitably aligned for the allocated type.
374 CharUnits allocationAlign = allocAlign;
375 if (!e->passAlignment() &&
377 const TargetInfo &target = cgm.getASTContext().getTargetInfo();
378 unsigned allocatorAlign = llvm::bit_floor(std::min<uint64_t>(
379 target.getNewAlign(), getContext().getTypeSize(allocType)));
380 allocationAlign = std::max(
381 allocationAlign, getContext().toCharUnitsFromBits(allocatorAlign));
382 }
383
384 mlir::Value allocPtr = rv.getValue();
385 allocation = Address(
386 allocPtr, mlir::cast<cir::PointerType>(allocPtr.getType()).getPointee(),
387 allocationAlign);
388 }
389
390 // Emit a null check on the allocation result if the allocation
391 // function is allowed to return null (because it has a non-throwing
392 // exception spec or is the reserved placement new) and we have an
393 // interesting initializer will be running sanitizers on the initialization.
394 bool nullCheck = e->shouldNullCheckAllocation() &&
395 (!allocType.isPODType(getContext()) || e->hasInitializer());
397 if (nullCheck)
398 cgm.errorNYI(e->getSourceRange(), "emitCXXNewExpr: null check");
399
400 // If there's an operator delete, enter a cleanup to call it if an
401 // exception is thrown.
402 if (e->getOperatorDelete() &&
404 cgm.errorNYI(e->getSourceRange(), "emitCXXNewExpr: operator delete");
405
406 if (allocSize != allocSizeWithoutCookie)
407 cgm.errorNYI(e->getSourceRange(), "emitCXXNewExpr: array with cookies");
408
409 mlir::Type elementTy = convertTypeForMem(allocType);
410 Address result = builder.createElementBitCast(getLoc(e->getSourceRange()),
411 allocation, elementTy);
412
413 // Passing pointer through launder.invariant.group to avoid propagation of
414 // vptrs information which may be included in previous type.
415 // To not break LTO with different optimizations levels, we do it regardless
416 // of optimization level.
417 if (cgm.getCodeGenOpts().StrictVTablePointers &&
419 cgm.errorNYI(e->getSourceRange(), "emitCXXNewExpr: strict vtable pointers");
420
422
423 emitNewInitializer(*this, e, allocType, elementTy, result, numElements,
424 allocSizeWithoutCookie);
425 return result.getPointer();
426}
static void emitNewInitializer(CIRGenFunction &cgf, const CXXNewExpr *e, QualType elementType, mlir::Type elementTy, Address newPtr, mlir::Value numElements, mlir::Value allocSizeWithoutCookie)
static mlir::Value emitCXXNewAllocSize(CIRGenFunction &cgf, const CXXNewExpr *e, unsigned minElements, mlir::Value &numElements, mlir::Value &sizeWithoutCookie)
static void storeAnyExprIntoOneUnit(CIRGenFunction &cgf, const Expr *init, QualType allocType, Address newPtr, AggValueSlot::Overlap_t mayOverlap)
static MemberCallInfo commonBuildCXXMemberOrOperatorCall(CIRGenFunction &cgf, const CXXMethodDecl *md, mlir::Value thisPtr, mlir::Value implicitParam, QualType implicitParamTy, const CallExpr *ce, CallArgList &args, CallArgList *rtlArgs)
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 ...
Defines the C++ Decl subclasses, other than those for templates (found in DeclTemplate....
Defines the clang::Expr interface and subclasses for C++ expressions.
cir::ConstantOp getConstant(mlir::Location loc, mlir::TypedAttr attr)
CharUnits getTypeAlignInChars(QualType T) const
Return the ABI-specified alignment of a (complete) type T, in characters.
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.
QualType getSizeType() const
Return the unique type for "size_t" (C99 7.17), defined in <stddef.h>.
const TargetInfo & getTargetInfo() const
Definition: ASTContext.h:859
mlir::Value getPointer() const
Definition: Address.h:81
static Address invalid()
Definition: Address.h:66
An aggregate value slot.
Definition: CIRGenValue.h:302
static AggValueSlot forAddr(Address addr, clang::Qualifiers quals, IsDestructed_t isDestructed, IsAliased_t isAliased, Overlap_t mayOverlap, IsZeroed_t isZeroed=IsNotZeroed)
Definition: CIRGenValue.h:359
Address createElementBitCast(mlir::Location loc, Address addr, mlir::Type destType)
Cast the element type of the given address to a different type, preserving information like the align...
virtual Address adjustThisArgumentForVirtualFunctionCall(CIRGenFunction &cgf, clang::GlobalDecl gd, Address thisPtr, bool virtualCall)
Perform ABI-specific "this" argument adjustment required prior to a call of a virtual function.
Definition: CIRGenCXXABI.h:77
virtual const clang::CXXRecordDecl * getThisArgumentTypeForMethod(const clang::CXXMethodDecl *md)
Get the type of the implicit "this" parameter used by a method.
Definition: CIRGenCXXABI.h:66
static CIRGenCallee forDirect(mlir::Operation *funcPtr, const CIRGenCalleeInfo &abstractInfo=CIRGenCalleeInfo())
Definition: CIRGenCall.h:90
static CIRGenCallee forVirtual(const clang::CallExpr *ce, clang::GlobalDecl md, Address addr, cir::FuncType fTy)
Definition: CIRGenCall.h:152
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)
Definition: CIRGenCall.cpp:731
static cir::TypeEvaluationKind getEvaluationKind(clang::QualType type)
Return the cir::TypeEvaluationKind of QualType type.
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...
Definition: CIRGenExpr.cpp:67
const clang::LangOptions & getLangOpts() const
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)
mlir::Type convertTypeForMem(QualType t)
mlir::Value emitCXXNewExpr(const CXXNewExpr *e)
void emitScalarInit(const clang::Expr *init, mlir::Location loc, LValue lvalue, bool capturedByInit=false)
Definition: CIRGenDecl.cpp:473
RValue emitCall(const CIRGenFunctionInfo &funcInfo, const CIRGenCallee &callee, ReturnValueSlot returnValue, const CallArgList &args, cir::CIRCallOpInterface *callOp, mlir::Location loc)
Definition: CIRGenCall.cpp:500
CIRGenBuilderTy & getBuilder()
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)
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)
RValue emitCXXOperatorMemberCallExpr(const CXXOperatorCallExpr *e, const CXXMethodDecl *md, ReturnValueSlot returnValue)
void emitAggExpr(const clang::Expr *e, AggValueSlot slot)
DiagnosticBuilder errorNYI(SourceLocation, llvm::StringRef)
Helpers to emit "not yet implemented" error diagnostics.
clang::ASTContext & getASTContext() const
Definition: CIRGenModule.h:102
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 clang::CodeGenOptions & getCodeGenOpts() const
Definition: CIRGenModule.h:104
CIRGenCXXABI & getCXXABI() const
Definition: CIRGenModule.h:109
const CIRGenFunctionInfo & arrangeCXXMethodDeclaration(const clang::CXXMethodDecl *md)
C++ methods have some special rules and also have implicit parameters.
Definition: CIRGenCall.cpp:396
const CIRGenFunctionInfo & arrangeCXXStructorDeclaration(clang::GlobalDecl gd)
Definition: CIRGenCall.cpp:179
const CIRGenFunctionInfo & arrangeFreeFunctionCall(const CallArgList &args, const FunctionType *fnType)
Definition: CIRGenCall.cpp:387
cir::FuncType getFunctionType(const CIRGenFunctionInfo &info)
Get the CIR function type for.
Definition: CIRGenCall.cpp:50
clang::CanQualType deriveThisType(const clang::CXXRecordDecl *rd, const clang::CXXMethodDecl *md)
Derives the 'this' type for CIRGen purposes, i.e.
Definition: CIRGenCall.cpp:224
const CIRGenFunctionInfo & arrangeCXXMethodCall(const CallArgList &args, const clang::FunctionProtoType *type, RequiredArgs required, unsigned numPrefixArgs)
Arrange a call to a C++ method, passing the given arguments.
Definition: CIRGenCall.cpp:367
void addFrom(const CallArgList &other)
Add all the arguments from another CallArgList to this one.
Definition: CIRGenCall.h:240
void add(RValue rvalue, clang::QualType type)
Definition: CIRGenCall.h:231
Address getAddress() const
Definition: CIRGenValue.h:211
mlir::Value getPointer() const
Definition: CIRGenValue.h:204
void setAddress(Address address)
Definition: CIRGenValue.h:215
This trivial value class is used to represent the result of an expression that is evaluated.
Definition: CIRGenValue.h:33
static RValue get(mlir::Value v)
Definition: CIRGenValue.h:82
mlir::Value getValue() const
Return the value of this scalar value.
Definition: CIRGenValue.h:56
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...
Definition: CIRGenCall.h:252
Represents a static or instance method of a struct/union/class.
Definition: DeclCXX.h:2129
bool isVirtual() const
Definition: DeclCXX.h:2184
const CXXRecordDecl * getParent() const
Return the parent of this method declaration, which is the class in which this method is defined.
Definition: DeclCXX.h:2255
bool isInstance() const
Definition: DeclCXX.h:2156
Represents a new-expression for memory allocation and constructor calls, e.g: "new CXXNewExpr(foo)".
Definition: ExprCXX.h:2349
bool isArray() const
Definition: ExprCXX.h:2458
llvm::iterator_range< arg_iterator > placement_arguments()
Definition: ExprCXX.h:2566
QualType getAllocatedType() const
Definition: ExprCXX.h:2428
bool hasInitializer() const
Whether this new-expression has any initializer at all.
Definition: ExprCXX.h:2518
bool shouldNullCheckAllocation() const
True if the allocation result needs to be null-checked.
Definition: ExprCXX.cpp:326
bool passAlignment() const
Indicates whether the required alignment should be implicitly passed to the allocation function.
Definition: ExprCXX.h:2545
FunctionDecl * getOperatorDelete() const
Definition: ExprCXX.h:2455
SourceRange getSourceRange() const
Definition: ExprCXX.h:2604
FunctionDecl * getOperatorNew() const
Definition: ExprCXX.h:2453
Expr * getInitializer()
The initializer of this new-expression.
Definition: ExprCXX.h:2527
A call to an overloaded operator written using operator syntax.
Definition: ExprCXX.h:84
Represents a C++ struct/union/class.
Definition: DeclCXX.h:258
CallExpr - Represents a function call (C99 6.5.2.2, C++ [expr.call]).
Definition: Expr.h:2879
Expr * getArg(unsigned Arg)
getArg - Return the specified argument.
Definition: Expr.h:3083
FunctionDecl * getDirectCallee()
If the callee is a FunctionDecl, return it. Otherwise return null.
Definition: Expr.h:3062
arg_range arguments()
Definition: Expr.h:3131
CharUnits - This is an opaque type for sizes expressed in character units.
Definition: CharUnits.h:38
QuantityType getQuantity() const
getQuantity - Get the raw integer representation of this quantity.
Definition: CharUnits.h:185
virtual SourceRange getSourceRange() const LLVM_READONLY
Source range that this declaration covers.
Definition: DeclBase.h:427
This represents one expression.
Definition: Expr.h:112
SourceLocation getExprLoc() const LLVM_READONLY
getExprLoc - Return the preferred location for the arrow when diagnosing a problem with a generic exp...
Definition: Expr.cpp:273
QualType getType() const
Definition: Expr.h:144
Represents a function declaration or definition.
Definition: Decl.h:1999
bool isTrivial() const
Whether this function is "trivial" in some specialized C++ senses.
Definition: Decl.h:2376
bool isReplaceableGlobalAllocationFunction(UnsignedOrNone *AlignmentParam=nullptr, bool *IsNothrow=nullptr) const
Determines whether this function is one of the replaceable global allocation functions: void *operato...
Definition: Decl.h:2593
bool isReservedGlobalPlacementOperator() const
Determines whether this operator new or delete is one of the reserved global placement operators: voi...
Definition: Decl.cpp:3391
bool isDefaulted() const
Whether this function is defaulted.
Definition: Decl.h:2384
Represents a prototype with parameter type info, e.g.
Definition: TypeBase.h:5282
GlobalDecl - represents a global declaration.
Definition: GlobalDecl.h:57
const Decl * getDecl() const
Definition: GlobalDecl.h:106
Represents a C++ nested name specifier, such as "\::std::vector<int>::".
A (possibly-)qualified type.
Definition: TypeBase.h:937
bool isNull() const
Return true if this QualType doesn't point to a type yet.
Definition: TypeBase.h:1004
Qualifiers getQualifiers() const
Retrieve the set of qualifiers applied to this type.
Definition: TypeBase.h:8383
bool isPODType(const ASTContext &Context) const
Determine whether this is a Plain Old Data (POD) type (C++ 3.9p10).
Definition: Type.cpp:2699
SourceRange getSourceRange() const LLVM_READONLY
SourceLocation tokens are not useful in isolation - they are low level value objects created/interpre...
Definition: Stmt.cpp:334
bool isUnion() const
Definition: Decl.h:3915
Exposes information about the current target.
Definition: TargetInfo.h:226
unsigned getNewAlign() const
Return the largest alignment for which a suitably-sized allocation with '::operator new(size_t)' is g...
Definition: TargetInfo.h:761
CXXRecordDecl * getAsCXXRecordDecl() const
Retrieves the CXXRecordDecl that this type refers to, either because the type is a RecordType or beca...
Definition: Type.h:26
const T * castAs() const
Member-template castAs<specific type>.
Definition: TypeBase.h:9226
QualType getType() const
Definition: Decl.h:722
const internal::VariadicAllOfMatcher< Type > type
Matches Types in the clang AST.
The JSON file list parser is used to communicate input to InstallAPI.
static bool addressSpace()
static bool aggValueSlotGC()
static bool devirtualizeMemberFunction()
static bool sanitizers()
static bool emitTypeCheck()
static bool opCallMustTail()
static bool exprNewNullCheck()
static bool attributeBuiltin()
static bool generateDebugInfo()
clang::CharUnits getSizeAlign() const