Clang Project

clang_source_code/lib/CodeGen/CGCXXABI.h
1//===----- CGCXXABI.h - Interface to C++ ABIs -------------------*- C++ -*-===//
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 provides an abstract class for C++ code generation. Concrete subclasses
10// of this implement code generation for specific C++ ABIs.
11//
12//===----------------------------------------------------------------------===//
13
14#ifndef LLVM_CLANG_LIB_CODEGEN_CGCXXABI_H
15#define LLVM_CLANG_LIB_CODEGEN_CGCXXABI_H
16
17#include "CodeGenFunction.h"
18#include "clang/Basic/LLVM.h"
19
20namespace llvm {
21class Constant;
22class Type;
23class Value;
24class CallInst;
25}
26
27namespace clang {
28class CastExpr;
29class CXXConstructorDecl;
30class CXXDestructorDecl;
31class CXXMethodDecl;
32class CXXRecordDecl;
33class FieldDecl;
34class MangleContext;
35
36namespace CodeGen {
37class CGCallee;
38class CodeGenFunction;
39class CodeGenModule;
40struct CatchTypeInfo;
41
42/// Implements C++ ABI-specific code generation functions.
43class CGCXXABI {
44protected:
45  CodeGenModule &CGM;
46  std::unique_ptr<MangleContextMangleCtx;
47
48  CGCXXABI(CodeGenModule &CGM)
49    : CGM(CGM), MangleCtx(CGM.getContext().createMangleContext()) {}
50
51protected:
52  ImplicitParamDecl *getThisDecl(CodeGenFunction &CGF) {
53    return CGF.CXXABIThisDecl;
54  }
55  llvm::Value *getThisValue(CodeGenFunction &CGF) {
56    return CGF.CXXABIThisValue;
57  }
58  Address getThisAddress(CodeGenFunction &CGF) {
59    return Address(CGF.CXXABIThisValueCGF.CXXABIThisAlignment);
60  }
61
62  /// Issue a diagnostic about unsupported features in the ABI.
63  void ErrorUnsupportedABI(CodeGenFunction &CGFStringRef S);
64
65  /// Get a null value for unsupported member pointers.
66  llvm::Constant *GetBogusMemberPointer(QualType T);
67
68  ImplicitParamDecl *&getStructorImplicitParamDecl(CodeGenFunction &CGF) {
69    return CGF.CXXStructorImplicitParamDecl;
70  }
71  llvm::Value *&getStructorImplicitParamValue(CodeGenFunction &CGF) {
72    return CGF.CXXStructorImplicitParamValue;
73  }
74
75  /// Loads the incoming C++ this pointer as it was passed by the caller.
76  llvm::Value *loadIncomingCXXThis(CodeGenFunction &CGF);
77
78  void setCXXABIThisValue(CodeGenFunction &CGFllvm::Value *ThisPtr);
79
80  ASTContext &getContext() const { return CGM.getContext(); }
81
82  virtual bool requiresArrayCookie(const CXXDeleteExpr *EQualType eltType);
83  virtual bool requiresArrayCookie(const CXXNewExpr *E);
84
85  /// Determine whether there's something special about the rules of
86  /// the ABI tell us that 'this' is a complete object within the
87  /// given function.  Obvious common logic like being defined on a
88  /// final class will have been taken care of by the caller.
89  virtual bool isThisCompleteObject(GlobalDecl GDconst = 0;
90
91public:
92
93  virtual ~CGCXXABI();
94
95  /// Gets the mangle context.
96  MangleContext &getMangleContext() {
97    return *MangleCtx;
98  }
99
100  /// Returns true if the given constructor or destructor is one of the
101  /// kinds that the ABI says returns 'this' (only applies when called
102  /// non-virtually for destructors).
103  ///
104  /// There currently is no way to indicate if a destructor returns 'this'
105  /// when called virtually, and code generation does not support the case.
106  virtual bool HasThisReturn(GlobalDecl GDconst { return false; }
107
108  virtual bool hasMostDerivedReturn(GlobalDecl GDconst { return false; }
109
110  /// Returns true if the target allows calling a function through a pointer
111  /// with a different signature than the actual function (or equivalently,
112  /// bitcasting a function or function pointer to a different function type).
113  /// In principle in the most general case this could depend on the target, the
114  /// calling convention, and the actual types of the arguments and return
115  /// value. Here it just means whether the signature mismatch could *ever* be
116  /// allowed; in other words, does the target do strict checking of signatures
117  /// for all calls.
118  virtual bool canCallMismatchedFunctionType() const { return true; }
119
120  /// If the C++ ABI requires the given type be returned in a particular way,
121  /// this method sets RetAI and returns true.
122  virtual bool classifyReturnType(CGFunctionInfo &FIconst = 0;
123
124  /// Specify how one should pass an argument of a record type.
125  enum RecordArgABI {
126    /// Pass it using the normal C aggregate rules for the ABI, potentially
127    /// introducing extra copies and passing some or all of it in registers.
128    RAA_Default = 0,
129
130    /// Pass it on the stack using its defined layout.  The argument must be
131    /// evaluated directly into the correct stack position in the arguments area,
132    /// and the call machinery must not move it or introduce extra copies.
133    RAA_DirectInMemory,
134
135    /// Pass it as a pointer to temporary memory.
136    RAA_Indirect
137  };
138
139  /// Returns true if C++ allows us to copy the memory of an object of type RD
140  /// when it is passed as an argument.
141  bool canCopyArgument(const CXXRecordDecl *RDconst;
142
143  /// Returns how an argument of the given record type should be passed.
144  virtual RecordArgABI getRecordArgABI(const CXXRecordDecl *RDconst = 0;
145
146  /// Returns true if the implicit 'sret' parameter comes after the implicit
147  /// 'this' parameter of C++ instance methods.
148  virtual bool isSRetParameterAfterThis() const { return false; }
149
150  /// Find the LLVM type used to represent the given member pointer
151  /// type.
152  virtual llvm::Type *
153  ConvertMemberPointerType(const MemberPointerType *MPT);
154
155  /// Load a member function from an object and a member function
156  /// pointer.  Apply the this-adjustment and set 'This' to the
157  /// adjusted value.
158  virtual CGCallee EmitLoadOfMemberFunctionPointer(
159      CodeGenFunction &CGFconst Expr *EAddress This,
160      llvm::Value *&ThisPtrForCallllvm::Value *MemPtr,
161      const MemberPointerType *MPT);
162
163  /// Calculate an l-value from an object and a data member pointer.
164  virtual llvm::Value *
165  EmitMemberDataPointerAddress(CodeGenFunction &CGFconst Expr *E,
166                               Address Basellvm::Value *MemPtr,
167                               const MemberPointerType *MPT);
168
169  /// Perform a derived-to-base, base-to-derived, or bitcast member
170  /// pointer conversion.
171  virtual llvm::Value *EmitMemberPointerConversion(CodeGenFunction &CGF,
172                                                   const CastExpr *E,
173                                                   llvm::Value *Src);
174
175  /// Perform a derived-to-base, base-to-derived, or bitcast member
176  /// pointer conversion on a constant value.
177  virtual llvm::Constant *EmitMemberPointerConversion(const CastExpr *E,
178                                                      llvm::Constant *Src);
179
180  /// Return true if the given member pointer can be zero-initialized
181  /// (in the C++ sense) with an LLVM zeroinitializer.
182  virtual bool isZeroInitializable(const MemberPointerType *MPT);
183
184  /// Return whether or not a member pointers type is convertible to an IR type.
185  virtual bool isMemberPointerConvertible(const MemberPointerType *MPTconst {
186    return true;
187  }
188
189  /// Create a null member pointer of the given type.
190  virtual llvm::Constant *EmitNullMemberPointer(const MemberPointerType *MPT);
191
192  /// Create a member pointer for the given method.
193  virtual llvm::Constant *EmitMemberFunctionPointer(const CXXMethodDecl *MD);
194
195  /// Create a member pointer for the given field.
196  virtual llvm::Constant *EmitMemberDataPointer(const MemberPointerType *MPT,
197                                                CharUnits offset);
198
199  /// Create a member pointer for the given member pointer constant.
200  virtual llvm::Constant *EmitMemberPointer(const APValue &MPQualType MPT);
201
202  /// Emit a comparison between two member pointers.  Returns an i1.
203  virtual llvm::Value *
204  EmitMemberPointerComparison(CodeGenFunction &CGF,
205                              llvm::Value *L,
206                              llvm::Value *R,
207                              const MemberPointerType *MPT,
208                              bool Inequality);
209
210  /// Determine if a member pointer is non-null.  Returns an i1.
211  virtual llvm::Value *
212  EmitMemberPointerIsNotNull(CodeGenFunction &CGF,
213                             llvm::Value *MemPtr,
214                             const MemberPointerType *MPT);
215
216protected:
217  /// A utility method for computing the offset required for the given
218  /// base-to-derived or derived-to-base member-pointer conversion.
219  /// Does not handle virtual conversions (in case we ever fully
220  /// support an ABI that allows this).  Returns null if no adjustment
221  /// is required.
222  llvm::Constant *getMemberPointerAdjustment(const CastExpr *E);
223
224  /// Computes the non-virtual adjustment needed for a member pointer
225  /// conversion along an inheritance path stored in an APValue.  Unlike
226  /// getMemberPointerAdjustment(), the adjustment can be negative if the path
227  /// is from a derived type to a base type.
228  CharUnits getMemberPointerPathAdjustment(const APValue &MP);
229
230public:
231  virtual void emitVirtualObjectDelete(CodeGenFunction &CGF,
232                                       const CXXDeleteExpr *DE,
233                                       Address PtrQualType ElementType,
234                                       const CXXDestructorDecl *Dtor) = 0;
235  virtual void emitRethrow(CodeGenFunction &CGFbool isNoReturn) = 0;
236  virtual void emitThrow(CodeGenFunction &CGFconst CXXThrowExpr *E) = 0;
237  virtual llvm::GlobalVariable *getThrowInfo(QualType T) { return nullptr; }
238
239  /// Determine whether it's possible to emit a vtable for \p RD, even
240  /// though we do not know that the vtable has been marked as used by semantic
241  /// analysis.
242  virtual bool canSpeculativelyEmitVTable(const CXXRecordDecl *RDconst = 0;
243
244  virtual void emitBeginCatch(CodeGenFunction &CGFconst CXXCatchStmt *C) = 0;
245
246  virtual llvm::CallInst *
247  emitTerminateForUnexpectedException(CodeGenFunction &CGF,
248                                      llvm::Value *Exn);
249
250  virtual llvm::Constant *getAddrOfRTTIDescriptor(QualType Ty) = 0;
251  virtual CatchTypeInfo
252  getAddrOfCXXCatchHandlerType(QualType TyQualType CatchHandlerType) = 0;
253  virtual CatchTypeInfo getCatchAllTypeInfo();
254
255  virtual bool shouldTypeidBeNullChecked(bool IsDeref,
256                                         QualType SrcRecordTy) = 0;
257  virtual void EmitBadTypeidCall(CodeGenFunction &CGF) = 0;
258  virtual llvm::Value *EmitTypeid(CodeGenFunction &CGFQualType SrcRecordTy,
259                                  Address ThisPtr,
260                                  llvm::Type *StdTypeInfoPtrTy) = 0;
261
262  virtual bool shouldDynamicCastCallBeNullChecked(bool SrcIsPtr,
263                                                  QualType SrcRecordTy) = 0;
264
265  virtual llvm::Value *
266  EmitDynamicCastCall(CodeGenFunction &CGFAddress Value,
267                      QualType SrcRecordTyQualType DestTy,
268                      QualType DestRecordTyllvm::BasicBlock *CastEnd) = 0;
269
270  virtual llvm::Value *EmitDynamicCastToVoid(CodeGenFunction &CGF,
271                                             Address Value,
272                                             QualType SrcRecordTy,
273                                             QualType DestTy) = 0;
274
275  virtual bool EmitBadCastCall(CodeGenFunction &CGF) = 0;
276
277  virtual llvm::Value *GetVirtualBaseClassOffset(CodeGenFunction &CGF,
278                                                 Address This,
279                                                 const CXXRecordDecl *ClassDecl,
280                                        const CXXRecordDecl *BaseClassDecl) = 0;
281
282  virtual llvm::BasicBlock *EmitCtorCompleteObjectHandler(CodeGenFunction &CGF,
283                                                          const CXXRecordDecl *RD);
284
285  /// Emit the code to initialize hidden members required
286  /// to handle virtual inheritance, if needed by the ABI.
287  virtual void
288  initializeHiddenVirtualInheritanceMembers(CodeGenFunction &CGF,
289                                            const CXXRecordDecl *RD) {}
290
291  /// Emit constructor variants required by this ABI.
292  virtual void EmitCXXConstructors(const CXXConstructorDecl *D) = 0;
293
294  /// Notes how many arguments were added to the beginning (Prefix) and ending
295  /// (Suffix) of an arg list.
296  ///
297  /// Note that Prefix actually refers to the number of args *after* the first
298  /// one: `this` arguments always come first.
299  struct AddedStructorArgs {
300    unsigned Prefix = 0;
301    unsigned Suffix = 0;
302    AddedStructorArgs() = default;
303    AddedStructorArgs(unsigned Punsigned S) : Prefix(P), Suffix(S) {}
304    static AddedStructorArgs prefix(unsigned N) { return {N0}; }
305    static AddedStructorArgs suffix(unsigned N) { return {0N}; }
306  };
307
308  /// Build the signature of the given constructor or destructor variant by
309  /// adding any required parameters.  For convenience, ArgTys has been
310  /// initialized with the type of 'this'.
311  virtual AddedStructorArgs
312  buildStructorSignature(GlobalDecl GD,
313                         SmallVectorImpl<CanQualType> &ArgTys) = 0;
314
315  /// Returns true if the given destructor type should be emitted as a linkonce
316  /// delegating thunk, regardless of whether the dtor is defined in this TU or
317  /// not.
318  virtual bool useThunkForDtorVariant(const CXXDestructorDecl *Dtor,
319                                      CXXDtorType DTconst = 0;
320
321  virtual void setCXXDestructorDLLStorage(llvm::GlobalValue *GV,
322                                          const CXXDestructorDecl *Dtor,
323                                          CXXDtorType DTconst;
324
325  virtual llvm::GlobalValue::LinkageTypes
326  getCXXDestructorLinkage(GVALinkage Linkage, const CXXDestructorDecl *Dtor,
327                          CXXDtorType DT) const;
328
329  /// Emit destructor variants required by this ABI.
330  virtual void EmitCXXDestructors(const CXXDestructorDecl *D) = 0;
331
332  /// Get the type of the implicit "this" parameter used by a method. May return
333  /// zero if no specific type is applicable, e.g. if the ABI expects the "this"
334  /// parameter to point to some artificial offset in a complete object due to
335  /// vbases being reordered.
336  virtual const CXXRecordDecl *
337  getThisArgumentTypeForMethod(const CXXMethodDecl *MD) {
338    return MD->getParent();
339  }
340
341  /// Perform ABI-specific "this" argument adjustment required prior to
342  /// a call of a virtual function.
343  /// The "VirtualCall" argument is true iff the call itself is virtual.
344  virtual Address
345  adjustThisArgumentForVirtualFunctionCall(CodeGenFunction &CGFGlobalDecl GD,
346                                           Address Thisbool VirtualCall) {
347    return This;
348  }
349
350  /// Build a parameter variable suitable for 'this'.
351  void buildThisParam(CodeGenFunction &CGFFunctionArgList &Params);
352
353  /// Insert any ABI-specific implicit parameters into the parameter list for a
354  /// function.  This generally involves extra data for constructors and
355  /// destructors.
356  ///
357  /// ABIs may also choose to override the return type, which has been
358  /// initialized with the type of 'this' if HasThisReturn(CGF.CurGD) is true or
359  /// the formal return type of the function otherwise.
360  virtual void addImplicitStructorParams(CodeGenFunction &CGFQualType &ResTy,
361                                         FunctionArgList &Params) = 0;
362
363  /// Get the ABI-specific "this" parameter adjustment to apply in the prologue
364  /// of a virtual function.
365  virtual CharUnits getVirtualFunctionPrologueThisAdjustment(GlobalDecl GD) {
366    return CharUnits::Zero();
367  }
368
369  /// Emit the ABI-specific prolog for the function.
370  virtual void EmitInstanceFunctionProlog(CodeGenFunction &CGF) = 0;
371
372  /// Add any ABI-specific implicit arguments needed to call a constructor.
373  ///
374  /// \return The number of arguments added at the beginning and end of the
375  /// call, which is typically zero or one.
376  virtual AddedStructorArgs
377  addImplicitConstructorArgs(CodeGenFunction &CGFconst CXXConstructorDecl *D,
378                             CXXCtorType Typebool ForVirtualBase,
379                             bool DelegatingCallArgList &Args) = 0;
380
381  /// Emit the destructor call.
382  virtual void EmitDestructorCall(CodeGenFunction &CGF,
383                                  const CXXDestructorDecl *DDCXXDtorType Type,
384                                  bool ForVirtualBasebool Delegating,
385                                  Address This) = 0;
386
387  /// Emits the VTable definitions required for the given record type.
388  virtual void emitVTableDefinitions(CodeGenVTables &CGVT,
389                                     const CXXRecordDecl *RD) = 0;
390
391  /// Checks if ABI requires extra virtual offset for vtable field.
392  virtual bool
393  isVirtualOffsetNeededForVTableField(CodeGenFunction &CGF,
394                                      CodeGenFunction::VPtr Vptr) = 0;
395
396  /// Checks if ABI requires to initialize vptrs for given dynamic class.
397  virtual bool doStructorsInitializeVPtrs(const CXXRecordDecl *VTableClass) = 0;
398
399  /// Get the address point of the vtable for the given base subobject.
400  virtual llvm::Constant *
401  getVTableAddressPoint(BaseSubobject Base,
402                        const CXXRecordDecl *VTableClass) = 0;
403
404  /// Get the address point of the vtable for the given base subobject while
405  /// building a constructor or a destructor.
406  virtual llvm::Value *
407  getVTableAddressPointInStructor(CodeGenFunction &CGFconst CXXRecordDecl *RD,
408                                  BaseSubobject Base,
409                                  const CXXRecordDecl *NearestVBase) = 0;
410
411  /// Get the address point of the vtable for the given base subobject while
412  /// building a constexpr.
413  virtual llvm::Constant *
414  getVTableAddressPointForConstExpr(BaseSubobject Base,
415                                    const CXXRecordDecl *VTableClass) = 0;
416
417  /// Get the address of the vtable for the given record decl which should be
418  /// used for the vptr at the given offset in RD.
419  virtual llvm::GlobalVariable *getAddrOfVTable(const CXXRecordDecl *RD,
420                                                CharUnits VPtrOffset) = 0;
421
422  /// Build a virtual function pointer in the ABI-specific way.
423  virtual CGCallee getVirtualFunctionPointer(CodeGenFunction &CGF,
424                                             GlobalDecl GDAddress This,
425                                             llvm::Type *Ty,
426                                             SourceLocation Loc) = 0;
427
428  /// Emit the ABI-specific virtual destructor call.
429  virtual llvm::Value *
430  EmitVirtualDestructorCall(CodeGenFunction &CGFconst CXXDestructorDecl *Dtor,
431                            CXXDtorType DtorTypeAddress This,
432                            const CXXMemberCallExpr *CE) = 0;
433
434  virtual void adjustCallArgsForDestructorThunk(CodeGenFunction &CGF,
435                                                GlobalDecl GD,
436                                                CallArgList &CallArgs) {}
437
438  /// Emit any tables needed to implement virtual inheritance.  For Itanium,
439  /// this emits virtual table tables.  For the MSVC++ ABI, this emits virtual
440  /// base tables.
441  virtual void emitVirtualInheritanceTables(const CXXRecordDecl *RD) = 0;
442
443  virtual bool exportThunk() = 0;
444  virtual void setThunkLinkage(llvm::Function *Thunkbool ForVTable,
445                               GlobalDecl GDbool ReturnAdjustment) = 0;
446
447  virtual llvm::Value *performThisAdjustment(CodeGenFunction &CGF,
448                                             Address This,
449                                             const ThisAdjustment &TA) = 0;
450
451  virtual llvm::Value *performReturnAdjustment(CodeGenFunction &CGF,
452                                               Address Ret,
453                                               const ReturnAdjustment &RA) = 0;
454
455  virtual void EmitReturnFromThunk(CodeGenFunction &CGF,
456                                   RValue RVQualType ResultType);
457
458  virtual size_t getSrcArgforCopyCtor(const CXXConstructorDecl *,
459                                      FunctionArgList &Args) const = 0;
460
461  /// Gets the offsets of all the virtual base pointers in a given class.
462  virtual std::vector<CharUnitsgetVBPtrOffsets(const CXXRecordDecl *RD);
463
464  /// Gets the pure virtual member call function.
465  virtual StringRef GetPureVirtualCallName() = 0;
466
467  /// Gets the deleted virtual member call name.
468  virtual StringRef GetDeletedVirtualCallName() = 0;
469
470  /**************************** Array cookies ******************************/
471
472  /// Returns the extra size required in order to store the array
473  /// cookie for the given new-expression.  May return 0 to indicate that no
474  /// array cookie is required.
475  ///
476  /// Several cases are filtered out before this method is called:
477  ///   - non-array allocations never need a cookie
478  ///   - calls to \::operator new(size_t, void*) never need a cookie
479  ///
480  /// \param expr - the new-expression being allocated.
481  virtual CharUnits GetArrayCookieSize(const CXXNewExpr *expr);
482
483  /// Initialize the array cookie for the given allocation.
484  ///
485  /// \param NewPtr - a char* which is the presumed-non-null
486  ///   return value of the allocation function
487  /// \param NumElements - the computed number of elements,
488  ///   potentially collapsed from the multidimensional array case;
489  ///   always a size_t
490  /// \param ElementType - the base element allocated type,
491  ///   i.e. the allocated type after stripping all array types
492  virtual Address InitializeArrayCookie(CodeGenFunction &CGF,
493                                        Address NewPtr,
494                                        llvm::Value *NumElements,
495                                        const CXXNewExpr *expr,
496                                        QualType ElementType);
497
498  /// Reads the array cookie associated with the given pointer,
499  /// if it has one.
500  ///
501  /// \param Ptr - a pointer to the first element in the array
502  /// \param ElementType - the base element type of elements of the array
503  /// \param NumElements - an out parameter which will be initialized
504  ///   with the number of elements allocated, or zero if there is no
505  ///   cookie
506  /// \param AllocPtr - an out parameter which will be initialized
507  ///   with a char* pointing to the address returned by the allocation
508  ///   function
509  /// \param CookieSize - an out parameter which will be initialized
510  ///   with the size of the cookie, or zero if there is no cookie
511  virtual void ReadArrayCookie(CodeGenFunction &CGFAddress Ptr,
512                               const CXXDeleteExpr *expr,
513                               QualType ElementTypellvm::Value *&NumElements,
514                               llvm::Value *&AllocPtrCharUnits &CookieSize);
515
516  /// Return whether the given global decl needs a VTT parameter.
517  virtual bool NeedsVTTParameter(GlobalDecl GD);
518
519protected:
520  /// Returns the extra size required in order to store the array
521  /// cookie for the given type.  Assumes that an array cookie is
522  /// required.
523  virtual CharUnits getArrayCookieSizeImpl(QualType elementType);
524
525  /// Reads the array cookie for an allocation which is known to have one.
526  /// This is called by the standard implementation of ReadArrayCookie.
527  ///
528  /// \param ptr - a pointer to the allocation made for an array, as a char*
529  /// \param cookieSize - the computed cookie size of an array
530  ///
531  /// Other parameters are as above.
532  ///
533  /// \return a size_t
534  virtual llvm::Value *readArrayCookieImpl(CodeGenFunction &IGFAddress ptr,
535                                           CharUnits cookieSize);
536
537public:
538
539  /*************************** Static local guards ****************************/
540
541  /// Emits the guarded initializer and destructor setup for the given
542  /// variable, given that it couldn't be emitted as a constant.
543  /// If \p PerformInit is false, the initialization has been folded to a
544  /// constant and should not be performed.
545  ///
546  /// The variable may be:
547  ///   - a static local variable
548  ///   - a static data member of a class template instantiation
549  virtual void EmitGuardedInit(CodeGenFunction &CGFconst VarDecl &D,
550                               llvm::GlobalVariable *DeclPtr,
551                               bool PerformInit) = 0;
552
553  /// Emit code to force the execution of a destructor during global
554  /// teardown.  The default implementation of this uses atexit.
555  ///
556  /// \param Dtor - a function taking a single pointer argument
557  /// \param Addr - a pointer to pass to the destructor function.
558  virtual void registerGlobalDtor(CodeGenFunction &CGFconst VarDecl &D,
559                                  llvm::FunctionCallee Dtor,
560                                  llvm::Constant *Addr) = 0;
561
562  /*************************** thread_local initialization ********************/
563
564  /// Emits ABI-required functions necessary to initialize thread_local
565  /// variables in this translation unit.
566  ///
567  /// \param CXXThreadLocals - The thread_local declarations in this translation
568  ///        unit.
569  /// \param CXXThreadLocalInits - If this translation unit contains any
570  ///        non-constant initialization or non-trivial destruction for
571  ///        thread_local variables, a list of functions to perform the
572  ///        initialization.
573  virtual void EmitThreadLocalInitFuncs(
574      CodeGenModule &CGMArrayRef<const VarDecl *> CXXThreadLocals,
575      ArrayRef<llvm::Function *> CXXThreadLocalInits,
576      ArrayRef<const VarDecl *> CXXThreadLocalInitVars) = 0;
577
578  // Determine if references to thread_local global variables can be made
579  // directly or require access through a thread wrapper function.
580  virtual bool usesThreadWrapperFunction() const = 0;
581
582  /// Emit a reference to a non-local thread_local variable (including
583  /// triggering the initialization of all thread_local variables in its
584  /// translation unit).
585  virtual LValue EmitThreadLocalVarDeclLValue(CodeGenFunction &CGF,
586                                              const VarDecl *VD,
587                                              QualType LValType) = 0;
588
589  /// Emit a single constructor/destructor with the given type from a C++
590  /// constructor Decl.
591  virtual void emitCXXStructor(GlobalDecl GD) = 0;
592
593  /// Load a vtable from This, an object of polymorphic type RD, or from one of
594  /// its virtual bases if it does not have its own vtable. Returns the vtable
595  /// and the class from which the vtable was loaded.
596  virtual std::pair<llvm::Value *, const CXXRecordDecl *>
597  LoadVTablePtr(CodeGenFunction &CGFAddress This,
598                const CXXRecordDecl *RD) = 0;
599};
600
601// Create an instance of a C++ ABI class:
602
603/// Creates an Itanium-family ABI.
604CGCXXABI *CreateItaniumCXXABI(CodeGenModule &CGM);
605
606/// Creates a Microsoft-family ABI.
607CGCXXABI *CreateMicrosoftCXXABI(CodeGenModule &CGM);
608
609struct CatchRetScope final : EHScopeStack::Cleanup {
610  llvm::CatchPadInst *CPI;
611
612  CatchRetScope(llvm::CatchPadInst *CPI) : CPI(CPI) {}
613
614  void Emit(CodeGenFunction &CGFFlags flags) override {
615    llvm::BasicBlock *BB = CGF.createBasicBlock("catchret.dest");
616    CGF.Builder.CreateCatchRet(CPI, BB);
617    CGF.EmitBlock(BB);
618  }
619};
620}
621}
622
623#endif
624
clang::CodeGen::CGCXXABI::CGM
clang::CodeGen::CGCXXABI::MangleCtx
clang::CodeGen::CGCXXABI::getThisDecl
clang::CodeGen::CGCXXABI::getThisValue
clang::CodeGen::CGCXXABI::getThisAddress
clang::CodeGen::CGCXXABI::ErrorUnsupportedABI
clang::CodeGen::CGCXXABI::GetBogusMemberPointer
clang::CodeGen::CGCXXABI::getStructorImplicitParamDecl
clang::CodeGen::CGCXXABI::getStructorImplicitParamValue
clang::CodeGen::CGCXXABI::loadIncomingCXXThis
clang::CodeGen::CGCXXABI::setCXXABIThisValue
clang::CodeGen::CGCXXABI::getContext
clang::CodeGen::CGCXXABI::requiresArrayCookie
clang::CodeGen::CGCXXABI::requiresArrayCookie
clang::CodeGen::CGCXXABI::isThisCompleteObject
clang::CodeGen::CGCXXABI::getMangleContext
clang::CodeGen::CGCXXABI::HasThisReturn
clang::CodeGen::CGCXXABI::hasMostDerivedReturn
clang::CodeGen::CGCXXABI::canCallMismatchedFunctionType
clang::CodeGen::CGCXXABI::classifyReturnType
clang::CodeGen::CGCXXABI::RecordArgABI
clang::CodeGen::CGCXXABI::canCopyArgument
clang::CodeGen::CGCXXABI::getRecordArgABI
clang::CodeGen::CGCXXABI::isSRetParameterAfterThis
clang::CodeGen::CGCXXABI::ConvertMemberPointerType
clang::CodeGen::CGCXXABI::EmitLoadOfMemberFunctionPointer
clang::CodeGen::CGCXXABI::EmitMemberDataPointerAddress
clang::CodeGen::CGCXXABI::EmitMemberPointerConversion
clang::CodeGen::CGCXXABI::EmitMemberPointerConversion
clang::CodeGen::CGCXXABI::isZeroInitializable
clang::CodeGen::CGCXXABI::isMemberPointerConvertible
clang::CodeGen::CGCXXABI::EmitNullMemberPointer
clang::CodeGen::CGCXXABI::EmitMemberFunctionPointer
clang::CodeGen::CGCXXABI::EmitMemberDataPointer
clang::CodeGen::CGCXXABI::EmitMemberPointer
clang::CodeGen::CGCXXABI::EmitMemberPointerComparison
clang::CodeGen::CGCXXABI::EmitMemberPointerIsNotNull
clang::CodeGen::CGCXXABI::getMemberPointerAdjustment
clang::CodeGen::CGCXXABI::getMemberPointerPathAdjustment
clang::CodeGen::CGCXXABI::emitVirtualObjectDelete
clang::CodeGen::CGCXXABI::emitRethrow
clang::CodeGen::CGCXXABI::emitThrow
clang::CodeGen::CGCXXABI::getThrowInfo
clang::CodeGen::CGCXXABI::canSpeculativelyEmitVTable
clang::CodeGen::CGCXXABI::emitBeginCatch
clang::CodeGen::CGCXXABI::emitTerminateForUnexpectedException
clang::CodeGen::CGCXXABI::getAddrOfRTTIDescriptor
clang::CodeGen::CGCXXABI::getAddrOfCXXCatchHandlerType
clang::CodeGen::CGCXXABI::getCatchAllTypeInfo
clang::CodeGen::CGCXXABI::shouldTypeidBeNullChecked
clang::CodeGen::CGCXXABI::EmitBadTypeidCall
clang::CodeGen::CGCXXABI::EmitTypeid
clang::CodeGen::CGCXXABI::shouldDynamicCastCallBeNullChecked
clang::CodeGen::CGCXXABI::EmitDynamicCastCall
clang::CodeGen::CGCXXABI::EmitDynamicCastToVoid
clang::CodeGen::CGCXXABI::EmitBadCastCall
clang::CodeGen::CGCXXABI::GetVirtualBaseClassOffset
clang::CodeGen::CGCXXABI::EmitCtorCompleteObjectHandler
clang::CodeGen::CGCXXABI::initializeHiddenVirtualInheritanceMembers
clang::CodeGen::CGCXXABI::EmitCXXConstructors
clang::CodeGen::CGCXXABI::AddedStructorArgs
clang::CodeGen::CGCXXABI::AddedStructorArgs::Prefix
clang::CodeGen::CGCXXABI::AddedStructorArgs::Suffix
clang::CodeGen::CGCXXABI::AddedStructorArgs::prefix
clang::CodeGen::CGCXXABI::AddedStructorArgs::suffix
clang::CodeGen::CGCXXABI::buildStructorSignature
clang::CodeGen::CGCXXABI::useThunkForDtorVariant
clang::CodeGen::CGCXXABI::setCXXDestructorDLLStorage
clang::CodeGen::CGCXXABI::getCXXDestructorLinkage
clang::CodeGen::CGCXXABI::EmitCXXDestructors
clang::CodeGen::CGCXXABI::getThisArgumentTypeForMethod
clang::CodeGen::CGCXXABI::adjustThisArgumentForVirtualFunctionCall
clang::CodeGen::CGCXXABI::buildThisParam
clang::CodeGen::CGCXXABI::addImplicitStructorParams
clang::CodeGen::CGCXXABI::getVirtualFunctionPrologueThisAdjustment
clang::CodeGen::CGCXXABI::EmitInstanceFunctionProlog
clang::CodeGen::CGCXXABI::addImplicitConstructorArgs
clang::CodeGen::CGCXXABI::EmitDestructorCall
clang::CodeGen::CGCXXABI::emitVTableDefinitions
clang::CodeGen::CGCXXABI::isVirtualOffsetNeededForVTableField
clang::CodeGen::CGCXXABI::doStructorsInitializeVPtrs
clang::CodeGen::CGCXXABI::getVTableAddressPoint
clang::CodeGen::CGCXXABI::getVTableAddressPointInStructor
clang::CodeGen::CGCXXABI::getVTableAddressPointForConstExpr
clang::CodeGen::CGCXXABI::getAddrOfVTable
clang::CodeGen::CGCXXABI::getVirtualFunctionPointer
clang::CodeGen::CGCXXABI::EmitVirtualDestructorCall
clang::CodeGen::CGCXXABI::adjustCallArgsForDestructorThunk
clang::CodeGen::CGCXXABI::emitVirtualInheritanceTables
clang::CodeGen::CGCXXABI::exportThunk
clang::CodeGen::CGCXXABI::setThunkLinkage
clang::CodeGen::CGCXXABI::performThisAdjustment
clang::CodeGen::CGCXXABI::performReturnAdjustment
clang::CodeGen::CGCXXABI::EmitReturnFromThunk
clang::CodeGen::CGCXXABI::getSrcArgforCopyCtor
clang::CodeGen::CGCXXABI::getVBPtrOffsets
clang::CodeGen::CGCXXABI::GetPureVirtualCallName
clang::CodeGen::CGCXXABI::GetDeletedVirtualCallName
clang::CodeGen::CGCXXABI::GetArrayCookieSize
clang::CodeGen::CGCXXABI::InitializeArrayCookie
clang::CodeGen::CGCXXABI::ReadArrayCookie
clang::CodeGen::CGCXXABI::NeedsVTTParameter
clang::CodeGen::CGCXXABI::getArrayCookieSizeImpl
clang::CodeGen::CGCXXABI::readArrayCookieImpl
clang::CodeGen::CGCXXABI::EmitGuardedInit
clang::CodeGen::CGCXXABI::registerGlobalDtor
clang::CodeGen::CGCXXABI::EmitThreadLocalInitFuncs
clang::CodeGen::CGCXXABI::usesThreadWrapperFunction
clang::CodeGen::CGCXXABI::EmitThreadLocalVarDeclLValue
clang::CodeGen::CGCXXABI::emitCXXStructor
clang::CodeGen::CGCXXABI::LoadVTablePtr
clang::CodeGen::CatchRetScope::CPI
clang::CodeGen::CatchRetScope::Emit