clang  6.0.0svn
CGCXXABI.h
Go to the documentation of this file.
1 //===----- CGCXXABI.h - Interface to C++ ABIs -------------------*- C++ -*-===//
2 //
3 // The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 //
10 // This provides an abstract class for C++ code generation. Concrete subclasses
11 // of this implement code generation for specific C++ ABIs.
12 //
13 //===----------------------------------------------------------------------===//
14 
15 #ifndef LLVM_CLANG_LIB_CODEGEN_CGCXXABI_H
16 #define LLVM_CLANG_LIB_CODEGEN_CGCXXABI_H
17 
18 #include "CodeGenFunction.h"
19 #include "clang/Basic/LLVM.h"
20 
21 namespace llvm {
22 class Constant;
23 class Type;
24 class Value;
25 class CallInst;
26 }
27 
28 namespace clang {
29 class CastExpr;
30 class CXXConstructorDecl;
31 class CXXDestructorDecl;
32 class CXXMethodDecl;
33 class CXXRecordDecl;
34 class FieldDecl;
35 class MangleContext;
36 
37 namespace CodeGen {
38 class CGCallee;
39 class CodeGenFunction;
40 class CodeGenModule;
41 struct CatchTypeInfo;
42 
43 /// \brief Implements C++ ABI-specific code generation functions.
44 class CGCXXABI {
45 protected:
47  std::unique_ptr<MangleContext> MangleCtx;
48 
50  : CGM(CGM), MangleCtx(CGM.getContext().createMangleContext()) {}
51 
52 protected:
54  return CGF.CXXABIThisDecl;
55  }
57  return CGF.CXXABIThisValue;
58  }
60  return Address(CGF.CXXABIThisValue, CGF.CXXABIThisAlignment);
61  }
62 
63  /// Issue a diagnostic about unsupported features in the ABI.
64  void ErrorUnsupportedABI(CodeGenFunction &CGF, StringRef S);
65 
66  /// Get a null value for unsupported member pointers.
67  llvm::Constant *GetBogusMemberPointer(QualType T);
68 
70  return CGF.CXXStructorImplicitParamDecl;
71  }
73  return CGF.CXXStructorImplicitParamValue;
74  }
75 
76  /// Perform prolog initialization of the parameter variable suitable
77  /// for 'this' emitted by buildThisParam.
78  void EmitThisParam(CodeGenFunction &CGF);
79 
80  ASTContext &getContext() const { return CGM.getContext(); }
81 
82  virtual bool requiresArrayCookie(const CXXDeleteExpr *E, QualType 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 GD) const = 0;
90 
91 public:
92 
93  virtual ~CGCXXABI();
94 
95  /// Gets the mangle context.
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 GD) const { return false; }
107 
108  virtual bool hasMostDerivedReturn(GlobalDecl GD) const { 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 &FI) const = 0;
123 
124  /// Specify how one should pass an argument of a record type.
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.
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 *RD) const;
142 
143  /// Returns how an argument of the given record type should be passed.
144  virtual RecordArgABI getRecordArgABI(const CXXRecordDecl *RD) const = 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 &CGF, const Expr *E, Address This,
160  llvm::Value *&ThisPtrForCall, llvm::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 &CGF, const Expr *E,
166  Address Base, llvm::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 *MPT) const {
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 &MP, QualType 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 
216 protected:
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  /// \brief 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 
230 public:
231  virtual void emitVirtualObjectDelete(CodeGenFunction &CGF,
232  const CXXDeleteExpr *DE,
233  Address Ptr, QualType ElementType,
234  const CXXDestructorDecl *Dtor) = 0;
235  virtual void emitRethrow(CodeGenFunction &CGF, bool isNoReturn) = 0;
236  virtual void emitThrow(CodeGenFunction &CGF, const CXXThrowExpr *E) = 0;
237  virtual llvm::GlobalVariable *getThrowInfo(QualType T) { return nullptr; }
238 
239  /// \brief 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 *RD) const = 0;
243 
244  virtual void emitBeginCatch(CodeGenFunction &CGF, const 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 Ty, QualType 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 &CGF, QualType 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 &CGF, Address Value,
267  QualType SrcRecordTy, QualType DestTy,
268  QualType DestRecordTy, llvm::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
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.
300  unsigned Prefix = 0;
301  unsigned Suffix = 0;
302  AddedStructorArgs() = default;
303  AddedStructorArgs(unsigned P, unsigned S) : Prefix(P), Suffix(S) {}
304  static AddedStructorArgs prefix(unsigned N) { return {N, 0}; }
305  static AddedStructorArgs suffix(unsigned N) { return {0, N}; }
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(const CXXMethodDecl *MD, StructorType T,
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 DT) const = 0;
320 
321  /// Emit destructor variants required by this ABI.
322  virtual void EmitCXXDestructors(const CXXDestructorDecl *D) = 0;
323 
324  /// Get the type of the implicit "this" parameter used by a method. May return
325  /// zero if no specific type is applicable, e.g. if the ABI expects the "this"
326  /// parameter to point to some artificial offset in a complete object due to
327  /// vbases being reordered.
328  virtual const CXXRecordDecl *
330  return MD->getParent();
331  }
332 
333  /// Perform ABI-specific "this" argument adjustment required prior to
334  /// a call of a virtual function.
335  /// The "VirtualCall" argument is true iff the call itself is virtual.
336  virtual Address
338  Address This, bool VirtualCall) {
339  return This;
340  }
341 
342  /// Build a parameter variable suitable for 'this'.
343  void buildThisParam(CodeGenFunction &CGF, FunctionArgList &Params);
344 
345  /// Insert any ABI-specific implicit parameters into the parameter list for a
346  /// function. This generally involves extra data for constructors and
347  /// destructors.
348  ///
349  /// ABIs may also choose to override the return type, which has been
350  /// initialized with the type of 'this' if HasThisReturn(CGF.CurGD) is true or
351  /// the formal return type of the function otherwise.
352  virtual void addImplicitStructorParams(CodeGenFunction &CGF, QualType &ResTy,
353  FunctionArgList &Params) = 0;
354 
355  /// Get the ABI-specific "this" parameter adjustment to apply in the prologue
356  /// of a virtual function.
358  return CharUnits::Zero();
359  }
360 
361  /// Perform ABI-specific "this" parameter adjustment in a virtual function
362  /// prologue.
364  CodeGenFunction &CGF, GlobalDecl GD, llvm::Value *This) {
365  return This;
366  }
367 
368  /// Emit the ABI-specific prolog for the function.
369  virtual void EmitInstanceFunctionProlog(CodeGenFunction &CGF) = 0;
370 
371  /// Add any ABI-specific implicit arguments needed to call a constructor.
372  ///
373  /// \return The number of arguments added at the beginning and end of the
374  /// call, which is typically zero or one.
375  virtual AddedStructorArgs
376  addImplicitConstructorArgs(CodeGenFunction &CGF, const CXXConstructorDecl *D,
377  CXXCtorType Type, bool ForVirtualBase,
378  bool Delegating, CallArgList &Args) = 0;
379 
380  /// Emit the destructor call.
381  virtual void EmitDestructorCall(CodeGenFunction &CGF,
382  const CXXDestructorDecl *DD, CXXDtorType Type,
383  bool ForVirtualBase, bool Delegating,
384  Address This) = 0;
385 
386  /// Emits the VTable definitions required for the given record type.
387  virtual void emitVTableDefinitions(CodeGenVTables &CGVT,
388  const CXXRecordDecl *RD) = 0;
389 
390  /// Checks if ABI requires extra virtual offset for vtable field.
391  virtual bool
392  isVirtualOffsetNeededForVTableField(CodeGenFunction &CGF,
393  CodeGenFunction::VPtr Vptr) = 0;
394 
395  /// Checks if ABI requires to initialize vptrs for given dynamic class.
396  virtual bool doStructorsInitializeVPtrs(const CXXRecordDecl *VTableClass) = 0;
397 
398  /// Get the address point of the vtable for the given base subobject.
399  virtual llvm::Constant *
400  getVTableAddressPoint(BaseSubobject Base,
401  const CXXRecordDecl *VTableClass) = 0;
402 
403  /// Get the address point of the vtable for the given base subobject while
404  /// building a constructor or a destructor.
405  virtual llvm::Value *
406  getVTableAddressPointInStructor(CodeGenFunction &CGF, const CXXRecordDecl *RD,
407  BaseSubobject Base,
408  const CXXRecordDecl *NearestVBase) = 0;
409 
410  /// Get the address point of the vtable for the given base subobject while
411  /// building a constexpr.
412  virtual llvm::Constant *
413  getVTableAddressPointForConstExpr(BaseSubobject Base,
414  const CXXRecordDecl *VTableClass) = 0;
415 
416  /// Get the address of the vtable for the given record decl which should be
417  /// used for the vptr at the given offset in RD.
418  virtual llvm::GlobalVariable *getAddrOfVTable(const CXXRecordDecl *RD,
419  CharUnits VPtrOffset) = 0;
420 
421  /// Build a virtual function pointer in the ABI-specific way.
422  virtual CGCallee getVirtualFunctionPointer(CodeGenFunction &CGF,
423  GlobalDecl GD,
424  Address 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 &CGF, const CXXDestructorDecl *Dtor,
431  CXXDtorType DtorType, Address This,
432  const CXXMemberCallExpr *CE) = 0;
433 
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 void setThunkLinkage(llvm::Function *Thunk, bool ForVTable,
444  GlobalDecl GD, bool ReturnAdjustment) = 0;
445 
446  virtual llvm::Value *performThisAdjustment(CodeGenFunction &CGF,
447  Address This,
448  const ThisAdjustment &TA) = 0;
449 
450  virtual llvm::Value *performReturnAdjustment(CodeGenFunction &CGF,
451  Address Ret,
452  const ReturnAdjustment &RA) = 0;
453 
454  virtual void EmitReturnFromThunk(CodeGenFunction &CGF,
455  RValue RV, QualType ResultType);
456 
457  virtual size_t getSrcArgforCopyCtor(const CXXConstructorDecl *,
458  FunctionArgList &Args) const = 0;
459 
460  /// Gets the offsets of all the virtual base pointers in a given class.
461  virtual std::vector<CharUnits> getVBPtrOffsets(const CXXRecordDecl *RD);
462 
463  /// Gets the pure virtual member call function.
464  virtual StringRef GetPureVirtualCallName() = 0;
465 
466  /// Gets the deleted virtual member call name.
467  virtual StringRef GetDeletedVirtualCallName() = 0;
468 
469  /**************************** Array cookies ******************************/
470 
471  /// Returns the extra size required in order to store the array
472  /// cookie for the given new-expression. May return 0 to indicate that no
473  /// array cookie is required.
474  ///
475  /// Several cases are filtered out before this method is called:
476  /// - non-array allocations never need a cookie
477  /// - calls to \::operator new(size_t, void*) never need a cookie
478  ///
479  /// \param expr - the new-expression being allocated.
480  virtual CharUnits GetArrayCookieSize(const CXXNewExpr *expr);
481 
482  /// Initialize the array cookie for the given allocation.
483  ///
484  /// \param NewPtr - a char* which is the presumed-non-null
485  /// return value of the allocation function
486  /// \param NumElements - the computed number of elements,
487  /// potentially collapsed from the multidimensional array case;
488  /// always a size_t
489  /// \param ElementType - the base element allocated type,
490  /// i.e. the allocated type after stripping all array types
491  virtual Address InitializeArrayCookie(CodeGenFunction &CGF,
492  Address NewPtr,
493  llvm::Value *NumElements,
494  const CXXNewExpr *expr,
495  QualType ElementType);
496 
497  /// Reads the array cookie associated with the given pointer,
498  /// if it has one.
499  ///
500  /// \param Ptr - a pointer to the first element in the array
501  /// \param ElementType - the base element type of elements of the array
502  /// \param NumElements - an out parameter which will be initialized
503  /// with the number of elements allocated, or zero if there is no
504  /// cookie
505  /// \param AllocPtr - an out parameter which will be initialized
506  /// with a char* pointing to the address returned by the allocation
507  /// function
508  /// \param CookieSize - an out parameter which will be initialized
509  /// with the size of the cookie, or zero if there is no cookie
510  virtual void ReadArrayCookie(CodeGenFunction &CGF, Address Ptr,
511  const CXXDeleteExpr *expr,
512  QualType ElementType, llvm::Value *&NumElements,
513  llvm::Value *&AllocPtr, CharUnits &CookieSize);
514 
515  /// Return whether the given global decl needs a VTT parameter.
516  virtual bool NeedsVTTParameter(GlobalDecl GD);
517 
518 protected:
519  /// Returns the extra size required in order to store the array
520  /// cookie for the given type. Assumes that an array cookie is
521  /// required.
522  virtual CharUnits getArrayCookieSizeImpl(QualType elementType);
523 
524  /// Reads the array cookie for an allocation which is known to have one.
525  /// This is called by the standard implementation of ReadArrayCookie.
526  ///
527  /// \param ptr - a pointer to the allocation made for an array, as a char*
528  /// \param cookieSize - the computed cookie size of an array
529  ///
530  /// Other parameters are as above.
531  ///
532  /// \return a size_t
533  virtual llvm::Value *readArrayCookieImpl(CodeGenFunction &IGF, Address ptr,
534  CharUnits cookieSize);
535 
536 public:
537 
538  /*************************** Static local guards ****************************/
539 
540  /// Emits the guarded initializer and destructor setup for the given
541  /// variable, given that it couldn't be emitted as a constant.
542  /// If \p PerformInit is false, the initialization has been folded to a
543  /// constant and should not be performed.
544  ///
545  /// The variable may be:
546  /// - a static local variable
547  /// - a static data member of a class template instantiation
548  virtual void EmitGuardedInit(CodeGenFunction &CGF, const VarDecl &D,
549  llvm::GlobalVariable *DeclPtr,
550  bool PerformInit) = 0;
551 
552  /// Emit code to force the execution of a destructor during global
553  /// teardown. The default implementation of this uses atexit.
554  ///
555  /// \param Dtor - a function taking a single pointer argument
556  /// \param Addr - a pointer to pass to the destructor function.
557  virtual void registerGlobalDtor(CodeGenFunction &CGF, const VarDecl &D,
558  llvm::Constant *Dtor,
559  llvm::Constant *Addr) = 0;
560 
561  /*************************** thread_local initialization ********************/
562 
563  /// Emits ABI-required functions necessary to initialize thread_local
564  /// variables in this translation unit.
565  ///
566  /// \param CXXThreadLocals - The thread_local declarations in this translation
567  /// unit.
568  /// \param CXXThreadLocalInits - If this translation unit contains any
569  /// non-constant initialization or non-trivial destruction for
570  /// thread_local variables, a list of functions to perform the
571  /// initialization.
572  virtual void EmitThreadLocalInitFuncs(
573  CodeGenModule &CGM, ArrayRef<const VarDecl *> CXXThreadLocals,
574  ArrayRef<llvm::Function *> CXXThreadLocalInits,
575  ArrayRef<const VarDecl *> CXXThreadLocalInitVars) = 0;
576 
577  // Determine if references to thread_local global variables can be made
578  // directly or require access through a thread wrapper function.
579  virtual bool usesThreadWrapperFunction() const = 0;
580 
581  /// Emit a reference to a non-local thread_local variable (including
582  /// triggering the initialization of all thread_local variables in its
583  /// translation unit).
584  virtual LValue EmitThreadLocalVarDeclLValue(CodeGenFunction &CGF,
585  const VarDecl *VD,
586  QualType LValType) = 0;
587 
588  /// Emit a single constructor/destructor with the given type from a C++
589  /// constructor Decl.
590  virtual void emitCXXStructor(const CXXMethodDecl *MD, StructorType Type) = 0;
591 };
592 
593 // Create an instance of a C++ ABI class:
594 
595 /// Creates an Itanium-family ABI.
597 
598 /// Creates a Microsoft-family ABI.
600 
601 }
602 }
603 
604 #endif
virtual llvm::Value * adjustThisParameterInVirtualFunctionPrologue(CodeGenFunction &CGF, GlobalDecl GD, llvm::Value *This)
Perform ABI-specific "this" parameter adjustment in a virtual function prologue.
Definition: CGCXXABI.h:363
const internal::VariadicDynCastAllOfMatcher< Stmt, Expr > expr
Matches expressions.
Definition: ASTMatchers.h:1538
A (possibly-)qualified type.
Definition: Type.h:614
DominatorTree GraphTraits specialization so the DominatorTree can be iterable by generic graph iterat...
Definition: Dominators.h:26
virtual Address adjustThisArgumentForVirtualFunctionCall(CodeGenFunction &CGF, GlobalDecl GD, Address This, bool VirtualCall)
Perform ABI-specific "this" argument adjustment required prior to a call of a virtual function...
Definition: CGCXXABI.h:337
StringRef P
The base class of the type hierarchy.
Definition: Type.h:1300
Represents a C++ constructor within a class.
Definition: DeclCXX.h:2344
llvm::Value *& getStructorImplicitParamValue(CodeGenFunction &CGF)
Definition: CGCXXABI.h:72
VarDecl - An instance of this class is created to represent a variable declaration or definition...
Definition: Decl.h:771
A this pointer adjustment.
Definition: ABI.h:108
A C++ throw-expression (C++ [except.throw]).
Definition: ExprCXX.h:928
CodeGenFunction - This class organizes the per-function state that is used while generating LLVM code...
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
Definition: ASTContext.h:128
ABIArgInfo classifyReturnType(CodeGenModule &CGM, CanQualType type)
Classify the rules for how to return a particular type.
A return adjustment.
Definition: ABI.h:42
CharUnits - This is an opaque type for sizes expressed in character units.
Definition: CharUnits.h:38
Forward-declares and imports various common LLVM datatypes that clang wants to use unqualified...
virtual bool hasMostDerivedReturn(GlobalDecl GD) const
Definition: CGCXXABI.h:108
CodeGenModule & CGM
Definition: CGCXXABI.h:46
ImplicitParamDecl * getThisDecl(CodeGenFunction &CGF)
Definition: CGCXXABI.h:53
CastExpr - Base class for type casts, including both implicit casts (ImplicitCastExpr) and explicit c...
Definition: Expr.h:2710
virtual bool canCallMismatchedFunctionType() const
Returns true if the target allows calling a function through a pointer with a different signature tha...
Definition: CGCXXABI.h:118
RValue - This trivial value class is used to represent the result of an expression that is evaluated...
Definition: CGValue.h:39
ImplicitParamDecl *& getStructorImplicitParamDecl(CodeGenFunction &CGF)
Definition: CGCXXABI.h:69
virtual bool HasThisReturn(GlobalDecl GD) const
Returns true if the given constructor or destructor is one of the kinds that the ABI says returns &#39;th...
Definition: CGCXXABI.h:106
CXXDtorType
C++ destructor types.
Definition: ABI.h:34
Expr - This represents one expression.
Definition: Expr.h:106
const FunctionProtoType * T
Represents a C++ destructor within a class.
Definition: DeclCXX.h:2566
virtual CharUnits getVirtualFunctionPrologueThisAdjustment(GlobalDecl GD)
Get the ABI-specific "this" parameter adjustment to apply in the prologue of a virtual function...
Definition: CGCXXABI.h:357
CGCXXABI(CodeGenModule &CGM)
Definition: CGCXXABI.h:49
ASTContext & getContext() const
Definition: CGCXXABI.h:80
ASTContext & getContext() const
virtual void adjustCallArgsForDestructorThunk(CodeGenFunction &CGF, GlobalDecl GD, CallArgList &CallArgs)
Definition: CGCXXABI.h:434
GlobalDecl - represents a global declaration.
Definition: GlobalDecl.h:29
The l-value was considered opaque, so the alignment was determined from a type.
Encodes a location in the source.
Represents a new-expression for memory allocation and constructor calls, e.g: "new CXXNewExpr(foo)"...
Definition: ExprCXX.h:1780
Represents a call to a member function that may be written either with member call syntax (e...
Definition: ExprCXX.h:136
static AddedStructorArgs suffix(unsigned N)
Definition: CGCXXABI.h:305
Represents a static or instance method of a struct/union/class.
Definition: DeclCXX.h:1918
MangleContext - Context for tracking state which persists across multiple calls to the C++ name mangl...
Definition: Mangle.h:42
An aligned address.
Definition: Address.h:25
All available information about a concrete callee.
Definition: CGCall.h:66
MangleContext & getMangleContext()
Gets the mangle context.
Definition: CGCXXABI.h:96
CGCXXABI * CreateMicrosoftCXXABI(CodeGenModule &CGM)
Creates a Microsoft-family ABI.
The MS C++ ABI needs a pointer to RTTI data plus some flags to describe the type of a catch handler...
Definition: CGCleanup.h:38
CXXCtorType
C++ constructor types.
Definition: ABI.h:25
FunctionArgList - Type for representing both the decl and type of parameters to a function...
Definition: CGCall.h:276
CGFunctionInfo - Class to encapsulate the information about a function definition.
This class organizes the cross-function state that is used while generating LLVM code.
Dataflow Directional Tag Classes.
Represents a delete expression for memory deallocation and destructor calls, e.g. ...
Definition: ExprCXX.h:1992
virtual bool isSRetParameterAfterThis() const
Returns true if the implicit &#39;sret&#39; parameter comes after the implicit &#39;this&#39; parameter of C++ instan...
Definition: CGCXXABI.h:148
static AddedStructorArgs prefix(unsigned N)
Definition: CGCXXABI.h:304
virtual bool isMemberPointerConvertible(const MemberPointerType *MPT) const
Return whether or not a member pointers type is convertible to an IR type.
Definition: CGCXXABI.h:185
const CXXRecordDecl * getParent() const
Returns the parent of this method declaration, which is the class in which this method is defined...
Definition: DeclCXX.h:2033
A pointer to member type per C++ 8.3.3 - Pointers to members.
Definition: Type.h:2440
std::unique_ptr< MangleContext > MangleCtx
Definition: CGCXXABI.h:47
virtual void initializeHiddenVirtualInheritanceMembers(CodeGenFunction &CGF, const CXXRecordDecl *RD)
Emit the code to initialize hidden members required to handle virtual inheritance, if needed by the ABI.
Definition: CGCXXABI.h:288
Address getThisAddress(CodeGenFunction &CGF)
Definition: CGCXXABI.h:59
Implements C++ ABI-specific code generation functions.
Definition: CGCXXABI.h:44
APValue - This class implements a discriminated union of [uninitialized] [APSInt] [APFloat]...
Definition: APValue.h:38
Pass it on the stack using its defined layout.
Definition: CGCXXABI.h:133
static CGCXXABI::RecordArgABI getRecordArgABI(const RecordType *RT, CGCXXABI &CXXABI)
Definition: TargetInfo.cpp:140
Represents a C++ struct/union/class.
Definition: DeclCXX.h:266
CGCXXABI * CreateItaniumCXXABI(CodeGenModule &CGM)
Creates an Itanium-family ABI.
virtual const CXXRecordDecl * getThisArgumentTypeForMethod(const CXXMethodDecl *MD)
Get the type of the implicit "this" parameter used by a method.
Definition: CGCXXABI.h:329
CXXCatchStmt - This represents a C++ catch block.
Definition: StmtCXX.h:29
Struct with all informations about dynamic [sub]class needed to set vptr.
virtual llvm::GlobalVariable * getThrowInfo(QualType T)
Definition: CGCXXABI.h:237
LValue - This represents an lvalue references.
Definition: CGValue.h:172
Notes how many arguments were added to the beginning (Prefix) and ending (Suffix) of an arg list...
Definition: CGCXXABI.h:299
RecordArgABI
Specify how one should pass an argument of a record type.
Definition: CGCXXABI.h:125
CallArgList - Type for representing both the value and type of arguments in a call.
Definition: CGCall.h:182
llvm::Value * getThisValue(CodeGenFunction &CGF)
Definition: CGCXXABI.h:56
AddedStructorArgs(unsigned P, unsigned S)
Definition: CGCXXABI.h:303