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

1

2

3

4

5

6

7

8

9

10

11

12

13

17

18using namespace clang;

20

22

26 CGF.CXXABIThisAlignment);

27}

28

32 "cannot yet compile %0 in this ABI");

34 DiagID)

35 << S;

36}

37

39 return llvm::Constant::getNullValue(CGM.getTypes().ConvertType(T));

40}

41

42llvm::Type *

44 return CGM.getTypes().ConvertType(CGM.getContext().getPointerDiffType());

45}

46

49 llvm::Value *&ThisPtrForCall,

52

54 ThisPtrForCall =

58 llvm::Constant *FnPtr = llvm::Constant::getNullValue(

59 llvm::PointerType::getUnqual(CGM.getLLVMContext()));

61}

62

67 llvm::Type *Ty =

69 return llvm::Constant::getNullValue(Ty);

70}

71

74 llvm::Value *Src) {

77}

78

80 llvm::Constant *Src) {

82}

83

84llvm::Value *

86 llvm::Value *L,

87 llvm::Value *R,

89 bool Inequality) {

91 return CGF.Builder.getFalse();

92}

93

94llvm::Value *

96 llvm::Value *MemPtr,

99 return CGF.Builder.getFalse();

100}

101

102llvm::Constant *

106

111

116

120

122

123 return true;

124}

125

128

129

130

131 auto *ThisDecl =

133 &CGM.getContext().Idents.get("this"),

135 params.push_back(ThisDecl);

136 CGF.CXXABIThisDecl = ThisDecl;

137

138

139

144 CGF.CXXABIThisAlignment = Layout.getAlignment();

145 } else {

146 CGF.CXXABIThisAlignment = Layout.getNonVirtualAlignment();

147 }

148}

149

154

156

157 assert(getThisDecl(CGF) && "no 'this' variable for function");

158 CGF.CXXABIThisValue = ThisPtr;

159}

160

163 return true;

164

165

166

168 return T->isRecordType() && T->isIncompleteType();

169}

170

172 const VarDecl *VD, bool InspectInitForWeakDef) const {

174 if (VD->hasAttr())

175 return true;

176

177

178

179 if (!InspectInitForWeakDef && (VD->isWeak() || VD->hasAttr()))

180 return false;

181

183 if (!InitDecl)

184 return false;

185

186

187 if (!InitDecl->hasInit())

188 return true;

189

190

191

194

195

196

197

198

199

201}

202

206 "cannot handle aggregates");

207 CGF.EmitReturnOfRValue(RV, ResultType);

208}

209

215

220

223 llvm::Value *NumElements,

226

229}

230

233

234

235 if (expr->doesUsualArrayDeleteWantSize())

236 return true;

237

239}

240

242

243

244 if (expr->doesUsualArrayDeleteWantSize())

245 return true;

246

247 return expr->getAllocatedType().isDestructedType();

248}

249

252 llvm::Value *&numElements,

253 llvm::Value *&allocPtr, CharUnits &cookieSize) {

254

256

257

260 numElements = nullptr;

262 return;

263 }

264

269}

270

272 QualType eltTy, llvm::Value *&numElements,

273 llvm::Value *&allocPtr, CharUnits &cookieSize) {

275

276

278

283}

284

289 return llvm::ConstantInt::get(CGF.SizeTy, 0);

290}

291

292

293

294

296 assert(E->getCastKind() == CK_DerivedToBaseMemberPointer ||

297 E->getCastKind() == CK_BaseToDerivedMemberPointer);

298

300 if (E->getCastKind() == CK_DerivedToBaseMemberPointer)

302 else

303 derivedType = E->getType();

304

307

308 return CGM.GetNonVirtualBaseClassOffset(derivedClass,

311}

312

313llvm::BasicBlock *

316 if (CGM.getTarget().getCXXABI().hasConstructorVariants())

317 llvm_unreachable("shouldn't be called in this ABI");

318

320 return nullptr;

321}

322

326

327 CGM.setDLLImportDLLExport(GV, Dtor);

328}

329

332

333 return CGM.getLLVMLinkageForDeclarator(Dtor, Linkage);

334}

335

339

340llvm::CallInst *

342 llvm::Value *Exn) {

343

345}

346

350

352 return std::vector();

353}

354

360 for (size_t i = 0; i < AddedArgs.Prefix.size(); ++i) {

361 Args.insert(Args.begin() + 1 + i,

363 AddedArgs.Prefix[i].Type));

364 }

365 for (const auto &arg : AddedArgs.Suffix) {

367 }

369 AddedArgs.Suffix.size());

370}

a trap message and trap category.

APValue - This class implements a discriminated union of [uninitialized] [APSInt] [APFloat],...

const ASTRecordLayout & getASTRecordLayout(const RecordDecl *D) const

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

FullSourceLoc getFullLoc(SourceLocation Loc) const

CanQualType getCanonicalTagType(const TagDecl *TD) const

Represents a C++ constructor within a class.

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

Represents a C++ destructor within a class.

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.

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

Represents a C++ struct/union/class.

bool isEffectivelyFinal() const

Determine whether it's impossible for a class to be derived from this class.

unsigned getNumVBases() const

Retrieves the number of virtual base classes of this class.

CastExpr - Base class for type casts, including both implicit casts (ImplicitCastExpr) and explicit c...

path_iterator path_begin()

CastKind getCastKind() const

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

static CharUnits Zero()

Zero - Construct a CharUnits quantity of zero.

Like RawAddress, an abstract representation of an aligned address, but the pointer contained in this ...

llvm::Value * emitRawPointer(CodeGenFunction &CGF) const

Return the pointer contained in this class after authenticating it and adding offset to it if necessa...

Address withElementType(llvm::Type *ElemTy) const

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

Address CreateConstInBoundsByteGEP(Address Addr, CharUnits Offset, const llvm::Twine &Name="")

Given a pointer to i8, adjust it by a given constant offset.

llvm::LoadInst * CreateLoad(Address Addr, const llvm::Twine &Name="")

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

Definition CGCXXABI.cpp:295

virtual std::vector< CharUnits > getVBPtrOffsets(const CXXRecordDecl *RD)

Gets the offsets of all the virtual base pointers in a given class.

Definition CGCXXABI.cpp:351

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.

Definition CGCXXABI.cpp:250

virtual void setCXXDestructorDLLStorage(llvm::GlobalValue *GV, const CXXDestructorDecl *Dtor, CXXDtorType DT) const

Definition CGCXXABI.cpp:323

virtual bool NeedsVTTParameter(GlobalDecl GD)

Return whether the given global decl needs a VTT parameter.

Definition CGCXXABI.cpp:336

virtual llvm::CallInst * emitTerminateForUnexpectedException(CodeGenFunction &CGF, llvm::Value *Exn)

Definition CGCXXABI.cpp:341

ImplicitParamDecl * getThisDecl(CodeGenFunction &CGF)

virtual llvm::Type * ConvertMemberPointerType(const MemberPointerType *MPT)

Find the LLVM type used to represent the given member pointer type.

Definition CGCXXABI.cpp:43

virtual llvm::Constant * EmitNullMemberPointer(const MemberPointerType *MPT)

Create a null member pointer of the given type.

Definition CGCXXABI.cpp:103

virtual CharUnits getArrayCookieSizeImpl(QualType elementType)

Returns the extra size required in order to store the array cookie for the given type.

Definition CGCXXABI.cpp:216

virtual void EmitReturnFromThunk(CodeGenFunction &CGF, RValue RV, QualType ResultType)

Definition CGCXXABI.cpp:203

void buildThisParam(CodeGenFunction &CGF, FunctionArgList &Params)

Build a parameter variable suitable for 'this'.

Definition CGCXXABI.cpp:126

virtual llvm::Value * EmitMemberPointerIsNotNull(CodeGenFunction &CGF, llvm::Value *MemPtr, const MemberPointerType *MPT)

Determine if a member pointer is non-null. Returns an i1.

Definition CGCXXABI.cpp:95

bool isEmittedWithConstantInitializer(const VarDecl *VD, bool InspectInitForWeakDef=false) const

Determine whether we will definitely emit this variable with a constant initializer,...

Definition CGCXXABI.cpp:171

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.

Definition CGCXXABI.cpp:85

virtual llvm::Constant * EmitMemberPointer(const APValue &MP, QualType MPT)

Create a member pointer for the given member pointer constant.

Definition CGCXXABI.cpp:117

Address getThisAddress(CodeGenFunction &CGF)

Definition CGCXXABI.cpp:23

virtual llvm::Value * readArrayCookieImpl(CodeGenFunction &IGF, Address ptr, CharUnits cookieSize)

Reads the array cookie for an allocation which is known to have one.

Definition CGCXXABI.cpp:285

virtual bool requiresArrayCookie(const CXXDeleteExpr *E, QualType eltType)

Definition CGCXXABI.cpp:231

virtual CatchTypeInfo getCatchAllTypeInfo()

Definition CGCXXABI.cpp:347

bool mayNeedDestruction(const VarDecl *VD) const

Definition CGCXXABI.cpp:161

virtual llvm::BasicBlock * EmitCtorCompleteObjectHandler(CodeGenFunction &CGF, const CXXRecordDecl *RD)

Definition CGCXXABI.cpp:314

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

void setCXXABIThisValue(CodeGenFunction &CGF, llvm::Value *ThisPtr)

Definition CGCXXABI.cpp:155

virtual llvm::Value * EmitMemberDataPointerAddress(CodeGenFunction &CGF, const Expr *E, Address Base, llvm::Value *MemPtr, const MemberPointerType *MPT, bool IsInBounds)

Calculate an l-value from an object and a data member pointer.

Definition CGCXXABI.cpp:63

llvm::Value * loadIncomingCXXThis(CodeGenFunction &CGF)

Loads the incoming C++ this pointer as it was passed by the caller.

Definition CGCXXABI.cpp:150

void ErrorUnsupportedABI(CodeGenFunction &CGF, StringRef S)

Issue a diagnostic about unsupported features in the ABI.

Definition CGCXXABI.cpp:29

virtual llvm::Constant * EmitMemberDataPointer(const MemberPointerType *MPT, CharUnits offset)

Create a member pointer for the given field.

Definition CGCXXABI.cpp:112

llvm::Constant * GetBogusMemberPointer(QualType T)

Get a null value for unsupported member pointers.

Definition CGCXXABI.cpp:38

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.

Definition CGCXXABI.cpp:47

virtual CharUnits GetArrayCookieSize(const CXXNewExpr *expr)

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

Definition CGCXXABI.cpp:210

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

Definition CGCXXABI.cpp:121

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.

Definition CGCXXABI.cpp:355

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.

Definition CGCXXABI.cpp:72

virtual llvm::Constant * EmitMemberFunctionPointer(const CXXMethodDecl *MD)

Create a member pointer for the given method.

Definition CGCXXABI.cpp:107

virtual ~CGCXXABI()

Definition CGCXXABI.cpp:21

virtual llvm::GlobalValue::LinkageTypes getCXXDestructorLinkage(GVALinkage Linkage, const CXXDestructorDecl *Dtor, CXXDtorType DT) const

Definition CGCXXABI.cpp:330

virtual Address InitializeArrayCookie(CodeGenFunction &CGF, Address NewPtr, llvm::Value *NumElements, const CXXNewExpr *expr, QualType ElementType)

Initialize the array cookie for the given allocation.

Definition CGCXXABI.cpp:221

ASTContext & getContext() const

virtual AddedStructorArgs getImplicitConstructorArgs(CodeGenFunction &CGF, const CXXConstructorDecl *D, CXXCtorType Type, bool ForVirtualBase, bool Delegating)=0

All available information about a concrete callee.

static CGCallee forDirect(llvm::Constant *functionPtr, const CGCalleeInfo &abstractInfo=CGCalleeInfo())

CallArgList - Type for representing both the value and type of arguments in a call.

void add(RValue rvalue, QualType type)

CodeGenFunction - This class organizes the per-function state that is used while generating LLVM code...

GlobalDecl CurGD

CurGD - The GlobalDecl for the current function being compiled.

llvm::Value * getAsNaturalPointerTo(Address Addr, QualType PointeeType)

Address makeNaturalAddressForPointer(llvm::Value *Ptr, QualType T, CharUnits Alignment=CharUnits::Zero(), bool ForPointeeType=false, LValueBaseInfo *BaseInfo=nullptr, TBAAAccessInfo *TBAAInfo=nullptr, KnownNonNull_t IsKnownNonNull=NotKnownNonNull)

Construct an address with the natural alignment of T.

const Decl * CurCodeDecl

CurCodeDecl - This is the inner-most code context, which includes blocks.

llvm::CallInst * EmitNounwindRuntimeCall(llvm::FunctionCallee callee, const Twine &name="")

ASTContext & getContext() const

static bool hasAggregateEvaluationKind(QualType T)

Address GetAddrOfLocalVar(const VarDecl *VD)

GetAddrOfLocalVar - Return the address of a local variable.

llvm::LLVMContext & getLLVMContext()

DiagnosticsEngine & getDiags() const

llvm::FunctionCallee getTerminateFn()

Get the declaration of std::terminate for the platform.

FunctionArgList - Type for representing both the decl and type of parameters to a function.

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

static RValue get(llvm::Value *V)

SourceLocation getLocation() const

Concrete class used by the front-end to report problems and issues.

DiagnosticBuilder Report(SourceLocation Loc, unsigned DiagID)

Issue the message to the client.

unsigned getCustomDiagID(Level L, const char(&FormatString)[N])

Return an ID for a diagnostic with the specified format string and level.

This represents one expression.

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

GlobalDecl - represents a global declaration.

const Decl * getDecl() const

static ImplicitParamDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation IdLoc, IdentifierInfo *Id, QualType T, ImplicitParamKind ParamKind)

Create implicit parameter.

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

A (possibly-)qualified type.

DestructionKind isDestructedType() const

Returns a nonzero value if objects of this type require non-trivial work to clean up after.

const T * castAs() const

Member-template castAs.

QualType getPointeeType() const

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

const Type * getBaseElementTypeUnsafe() const

Get the base element type of this type, potentially discarding type qualifiers.

const T * getAs() const

Member-template getAs'.

bool isWeak() const

Determine whether this symbol is weakly-imported, or declared with the weak or weak-ref attr.

Represents a variable declaration or definition.

VarDecl * getMostRecentDecl()

Returns the most recent (re)declaration of this declaration.

APValue * evaluateValue() const

Attempt to evaluate the value of the initializer attached to this declaration, and produce notes expl...

bool hasConstantInitialization() const

Determine whether this variable has constant initialization.

QualType::DestructionKind needsDestruction(const ASTContext &Ctx) const

Would the destruction of this variable have any effect, and if so, what kind?

VarDecl * getInitializingDeclaration()

Get the initializing declaration of this variable, if any.

@ Type

The l-value was considered opaque, so the alignment was determined from a type.

const internal::VariadicDynCastAllOfMatcher< Stmt, Expr > expr

Matches expressions.

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

CXXCtorType

C++ constructor types.

GVALinkage

A more specific kind of linkage than enum Linkage.

bool isUniqueGVALinkage(GVALinkage L)

Do we know that this will be the only definition of this symbol (excluding inlining-only definitions)...

Linkage

Describes the different kinds of linkage (C++ [basic.link], C99 6.2.2) that an entity may have.

const FunctionProtoType * T

CXXDtorType

C++ destructor types.

U cast(CodeGen::Address addr)

@ CXXThis

Parameter for C++ 'this' argument.

Similar to AddedStructorArgs, but only notes the number of additional arguments.

Additional implicit arguments to add to the beginning (Prefix) and end (Suffix) of a constructor / de...

SmallVector< Arg, 1 > Prefix

SmallVector< Arg, 1 > Suffix

The MS C++ ABI needs a pointer to RTTI data plus some flags to describe the type of a catch handler,...

llvm::IntegerType * Int8Ty

i8, i16, i32, and i64

llvm::IntegerType * SizeTy