Go to the documentation of this file.
18 using namespace clang;
19 using namespace CodeGen;
26 "cannot yet compile %0 in this ABI");
43 llvm::Value *&ThisPtrForCall,
47 ThisPtrForCall =
This.getPointer();
53 llvm::Constant *FnPtr = llvm::Constant::getNullValue(FTy->getPointerTo());
63 ->getPointerTo(
Base.getAddressSpace());
64 return llvm::Constant::getNullValue(Ty);
75 llvm::Constant *Src) {
130 params.push_back(ThisDecl);
131 CGF.CXXABIThisDecl = ThisDecl;
139 CGF.CXXABIThisAlignment = Layout.getAlignment();
141 CGF.CXXABIThisAlignment = Layout.getNonVirtualAlignment();
152 assert(
getThisDecl(CGF) &&
"no 'this' variable for function");
153 CGF.CXXABIThisValue = ThisPtr;
170 const VarDecl *VD,
bool InspectInitForWeakDef)
const {
172 if (VD->
hasAttr<ConstInitAttr>())
177 if (!InspectInitForWeakDef && (VD->
isWeak() || VD->
hasAttr<SelectAnyAttr>()))
204 "cannot handle aggregates");
205 CGF.EmitReturnOfRValue(RV, ResultType);
221 llvm::Value *NumElements,
233 if (
expr->doesUsualArrayDeleteWantSize())
242 if (
expr->doesUsualArrayDeleteWantSize())
245 return expr->getAllocatedType().isDestructedType();
250 llvm::Value *&numElements,
251 llvm::Value *&allocPtr,
CharUnits &cookieSize) {
258 numElements =
nullptr;
274 return llvm::ConstantInt::get(CGF.
SizeTy, 0);
281 assert(E->
getCastKind() == CK_DerivedToBaseMemberPointer ||
282 E->
getCastKind() == CK_BaseToDerivedMemberPointer);
285 if (E->
getCastKind() == CK_DerivedToBaseMemberPointer)
302 llvm_unreachable(
"shouldn't be called in this ABI");
338 return std::vector<CharUnits>();
343 bool ForVirtualBase,
bool Delegating,
CallArgList &Args) {
346 for (
size_t i = 0; i < AddedArgs.
Prefix.size(); ++i) {
347 Args.insert(Args.begin() + 1 + i,
349 AddedArgs.
Prefix[i].Type));
351 for (
const auto &
arg : AddedArgs.
Suffix) {
virtual void ReadArrayCookie(CodeGenFunction &CGF, Address Ptr, const CXXDeleteExpr *expr, QualType ElementType, llvm::Value *&NumElements, llvm::Value *&AllocPtr, CharUnits &CookieSize)
Reads the array cookie associated with the given pointer, if it has one.
QualType getThisType() const
Return the type of the this pointer.
bool isUniqueGVALinkage(GVALinkage L)
Do we know that this will be the only definition of this symbol (excluding inlining-only definitions)...
llvm::IntegerType * SizeTy
virtual llvm::GlobalValue::LinkageTypes getCXXDestructorLinkage(GVALinkage Linkage, const CXXDestructorDecl *Dtor, CXXDtorType DT) const
Represents a C++ constructor within a class.
virtual llvm::Value * EmitMemberPointerConversion(CodeGenFunction &CGF, const CastExpr *E, llvm::Value *Src)
Perform a derived-to-base, base-to-derived, or bitcast member pointer conversion.
RValue - This trivial value class is used to represent the result of an expression that is evaluated.
bool isEffectivelyFinal() const
Determine whether it's impossible for a class to be derived from this class.
@ CXXThis
Parameter for C++ 'this' argument.
virtual llvm::Constant * EmitMemberFunctionPointer(const CXXMethodDecl *MD)
Create a member pointer for the given method.
void ErrorUnsupportedABI(CodeGenFunction &CGF, StringRef S)
Issue a diagnostic about unsupported features in the ABI.
const Decl * CurCodeDecl
CurCodeDecl - This is the inner-most code context, which includes blocks.
llvm::CallInst * EmitNounwindRuntimeCall(llvm::FunctionCallee callee, const Twine &name="")
IdentifierInfo & get(StringRef Name)
Return the identifier token info for the specified named identifier.
Additional implicit arguments to add to the beginning (Prefix) and end (Suffix) of a constructor / de...
FullSourceLoc getFullLoc(SourceLocation Loc) const
virtual bool NeedsVTTParameter(GlobalDecl GD)
Return whether the given global decl needs a VTT parameter.
virtual Address InitializeArrayCookie(CodeGenFunction &CGF, Address NewPtr, llvm::Value *NumElements, const CXXNewExpr *expr, QualType ElementType)
Initialize the array cookie for the given allocation.
A (possibly-)qualified type.
const Type * getTypeForDecl() const
VarDecl * getInitializingDeclaration()
Get the initializing declaration of this variable, if any.
GVALinkage
A more specific kind of linkage than enum Linkage.
ASTContext & getContext() const
Concrete class used by the front-end to report problems and issues.
llvm::GlobalValue::LinkageTypes getLLVMLinkageForDeclarator(const DeclaratorDecl *D, GVALinkage Linkage, bool IsConstantVariable)
Returns LLVM linkage for a declarator.
llvm::Constant * getMemberPointerAdjustment(const CastExpr *E)
A utility method for computing the offset required for the given base-to-derived or derived-to-base m...
void setCXXABIThisValue(CodeGenFunction &CGF, llvm::Value *ThisPtr)
TargetCXXABI getCXXABI() const
Get the C++ ABI currently in use.
bool hasConstantInitialization() const
Determine whether this variable has constant initialization.
Represents a new-expression for memory allocation and constructor calls, e.g: "new CXXNewExpr(foo)".
void add(RValue rvalue, QualType type)
llvm::Type * ConvertType(QualType T)
ConvertType - Convert type T into a llvm::Type.
void setDLLImportDLLExport(llvm::GlobalValue *GV, GlobalDecl D) const
The base class of the type hierarchy.
bool mayNeedDestruction(const VarDecl *VD) const
Address GetAddrOfLocalVar(const VarDecl *VD)
GetAddrOfLocalVar - Return the address of a local variable.
GlobalDecl - represents a global declaration.
virtual CatchTypeInfo getCatchAllTypeInfo()
virtual llvm::Value * readArrayCookieImpl(CodeGenFunction &IGF, Address ptr, CharUnits cookieSize)
Reads the array cookie for an allocation which is known to have one.
llvm::Value * loadIncomingCXXThis(CodeGenFunction &CGF)
Loads the incoming C++ this pointer as it was passed by the caller.
void buildThisParam(CodeGenFunction &CGF, FunctionArgList &Params)
Build a parameter variable suitable for 'this'.
virtual llvm::Constant * EmitNullMemberPointer(const MemberPointerType *MPT)
Create a null member pointer of the given type.
const internal::VariadicDynCastAllOfMatcher< Stmt, Expr > expr
Matches expressions.
A helper class that allows the use of isa/cast/dyncast to detect TagType objects of structs/unions/cl...
CXXCtorType
C++ constructor types.
virtual llvm::Value * EmitMemberPointerComparison(CodeGenFunction &CGF, llvm::Value *L, llvm::Value *R, const MemberPointerType *MPT, bool Inequality)
Emit a comparison between two member pointers. Returns an i1.
virtual AddedStructorArgs getImplicitConstructorArgs(CodeGenFunction &CGF, const CXXConstructorDecl *D, CXXCtorType Type, bool ForVirtualBase, bool Delegating)=0
Linkage
Describes the different kinds of linkage (C++ [basic.link], C99 6.2.2) that an entity may have.
virtual llvm::Constant * EmitMemberDataPointer(const MemberPointerType *MPT, CharUnits offset)
Create a member pointer for the given field.
AddedStructorArgCounts addImplicitConstructorArgs(CodeGenFunction &CGF, const CXXConstructorDecl *D, CXXCtorType Type, bool ForVirtualBase, bool Delegating, CallArgList &Args)
Add any ABI-specific implicit arguments needed to call a constructor.
CXXDtorType
C++ destructor types.
QualType getPointeeType() const
const T * getAs() const
Member-template getAs<specific type>'.
path_iterator path_begin()
Represents a C++ destructor within a class.
virtual CGCallee EmitLoadOfMemberFunctionPointer(CodeGenFunction &CGF, const Expr *E, Address This, llvm::Value *&ThisPtrForCall, llvm::Value *MemPtr, const MemberPointerType *MPT)
Load a member function from an object and a member function pointer.
Represents a variable declaration or definition.
CodeGenTypes & getTypes()
bool isEmittedWithConstantInitializer(const VarDecl *VD, bool InspectInitForWeakDef=false) const
Determine whether we will definitely emit this variable with a constant initializer,...
bool isWeak() const
Determine whether this symbol is weakly-imported, or declared with the weak or weak-ref attr.
CXXRecordDecl * getAsCXXRecordDecl() const
Retrieves the CXXRecordDecl that this type refers to, either because the type is a RecordType or beca...
virtual std::vector< CharUnits > getVBPtrOffsets(const CXXRecordDecl *RD)
Gets the offsets of all the virtual base pointers in a given class.
Address CreateConstInBoundsByteGEP(Address Addr, CharUnits Offset, const llvm::Twine &Name="")
Given a pointer to i8, adjust it by a given constant offset.
ASTContext & getContext() const
const Type * getClass() const
static CharUnits Zero()
Zero - Construct a CharUnits quantity of zero.
llvm::Constant * GetBogusMemberPointer(QualType T)
Get a null value for unsupported member pointers.
CastKind getCastKind() const
static CGCallee forDirect(llvm::Constant *functionPtr, const CGCalleeInfo &abstractInfo=CGCalleeInfo())
const TargetInfo & getTarget() const
virtual void setCXXDestructorDLLStorage(llvm::GlobalValue *GV, const CXXDestructorDecl *Dtor, CXXDtorType DT) const
GlobalDecl CurGD
CurGD - The GlobalDecl for the current function being compiled.
virtual llvm::CallInst * emitTerminateForUnexpectedException(CodeGenFunction &CGF, llvm::Value *Exn)
llvm::FunctionType * GetFunctionType(const CGFunctionInfo &Info)
GetFunctionType - Get the LLVM function type for.
const T * castAs() const
Member-template castAs<specific type>.
virtual llvm::Constant * EmitMemberPointer(const APValue &MP, QualType MPT)
Create a member pointer for the given member pointer constant.
Represents a C++ struct/union/class.
const CGFunctionInfo & arrangeCXXMethodType(const CXXRecordDecl *RD, const FunctionProtoType *FTP, const CXXMethodDecl *MD)
Arrange the argument and result information for a call to an unknown C++ non-static member function o...
llvm::FunctionCallee getTerminateFn()
Get the declaration of std::terminate for the platform.
unsigned getNumVBases() const
Retrieves the number of virtual base classes of this class.
llvm::Value * getPointer() const
CodeGenFunction - This class organizes the per-function state that is used while generating LLVM code...
Represents a prototype with parameter type info, e.g.
Similar to AddedStructorArgs, but only notes the number of additional arguments.
llvm::Constant * GetNonVirtualBaseClassOffset(const CXXRecordDecl *ClassDecl, CastExpr::path_const_iterator PathBegin, CastExpr::path_const_iterator PathEnd)
Returns the offset from a derived class to a class.
Represents a delete expression for memory deallocation and destructor calls, e.g.
virtual bool requiresArrayCookie(const CXXDeleteExpr *E, QualType eltType)
All available information about a concrete callee.
FunctionArgList - Type for representing both the decl and type of parameters to a function.
SmallVector< Arg, 1 > Suffix
llvm::Type * ConvertType(QualType T)
virtual void EmitReturnFromThunk(CodeGenFunction &CGF, RValue RV, QualType ResultType)
virtual llvm::Value * EmitMemberPointerIsNotNull(CodeGenFunction &CGF, llvm::Value *MemPtr, const MemberPointerType *MPT)
Determine if a member pointer is non-null. Returns an i1.
decl_type * getMostRecentDecl()
Returns the most recent (re)declaration of this declaration.
static bool hasAggregateEvaluationKind(QualType T)
bool hasConstructorVariants() const
Does this ABI have different entrypoints for complete-object and base-subobject constructors?
Address CreateElementBitCast(Address Addr, llvm::Type *Ty, const llvm::Twine &Name="")
Cast the element type of the given address to a different type, preserving information like the align...
A pointer to member type per C++ 8.3.3 - Pointers to members.
virtual llvm::Type * ConvertMemberPointerType(const MemberPointerType *MPT)
Find the LLVM type used to represent the given member pointer type.
virtual llvm::Value * EmitMemberDataPointerAddress(CodeGenFunction &CGF, const Expr *E, Address Base, llvm::Value *MemPtr, const MemberPointerType *MPT)
Calculate an l-value from an object and a data member pointer.
const Type * getBaseElementTypeUnsafe() const
Get the base element type of this type, potentially discarding type qualifiers.
bool This(InterpState &S, CodePtr OpPC)
static ImplicitParamDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation IdLoc, IdentifierInfo *Id, QualType T, ImplicitParamKind ParamKind)
Create implicit parameter.
unsigned getCustomDiagID(Level L, const char(&FormatString)[N])
Return an ID for a diagnostic with the specified format string and level.
virtual llvm::BasicBlock * EmitCtorCompleteObjectHandler(CodeGenFunction &CGF, const CXXRecordDecl *RD)
static RValue get(llvm::Value *V)
The MS C++ ABI needs a pointer to RTTI data plus some flags to describe the type of a catch handler,...
__DEVICE__ _Tp arg(const std::complex< _Tp > &__c)
DiagnosticsEngine & getDiags() const
QualType getPointerDiffType() const
Return the unique type for "ptrdiff_t" (C99 7.17) defined in <stddef.h>.
const ASTRecordLayout & getASTRecordLayout(const RecordDecl *D) const
Get or compute information about the layout of the specified record (struct/union/class) D,...
const Decl * getDecl() const
RecordDecl * getDecl() const
QualType::DestructionKind needsDestruction(const ASTContext &Ctx) const
Would the destruction of this variable have any effect, and if so, what kind?
CharUnits - This is an opaque type for sizes expressed in character units.
APValue - This class implements a discriminated union of [uninitialized] [APSInt] [APFloat],...
This represents one expression.
virtual bool isThisCompleteObject(GlobalDecl GD) const =0
Determine whether there's something special about the rules of the ABI tell us that 'this' is a compl...
DestructionKind isDestructedType() const
Returns a nonzero value if objects of this type require non-trivial work to clean up after.
llvm::IntegerType * Int8Ty
i8, i16, i32, and i64
virtual CharUnits getArrayCookieSizeImpl(QualType elementType)
Returns the extra size required in order to store the array cookie for the given type.
bool isIncompleteType(NamedDecl **Def=nullptr) const
Types are partitioned into 3 broad categories (C99 6.2.5p1): object types, function types,...
CastExpr - Base class for type casts, including both implicit casts (ImplicitCastExpr) and explicit c...
SourceLocation getLocation() const
CallArgList - Type for representing both the value and type of arguments in a call.
virtual bool isZeroInitializable(const MemberPointerType *MPT)
Return true if the given member pointer can be zero-initialized (in the C++ sense) with an LLVM zeroi...
virtual CharUnits GetArrayCookieSize(const CXXNewExpr *expr)
Returns the extra size required in order to store the array cookie for the given new-expression.
ASTContext & getContext() const
SmallVector< Arg, 1 > Prefix
QualType getMemberPointerType(QualType T, const Type *Cls) const
Return the uniqued reference to the type for a member pointer to the specified type in the specified ...
APValue * evaluateValue() const
Attempt to evaluate the value of the initializer attached to this declaration, and produce notes expl...
DiagnosticBuilder Report(SourceLocation Loc, unsigned DiagID)
Issue the message to the client.
ImplicitParamDecl * getThisDecl(CodeGenFunction &CGF)
llvm::LoadInst * CreateLoad(Address Addr, const llvm::Twine &Name="")
const CXXRecordDecl * getParent() const
Return the parent of this method declaration, which is the class in which this method is defined.
Represents a static or instance method of a struct/union/class.