CGCXXABI.h revision 1af610f8533b8b4a7b0b176aa8082f5b6dde904c
13a811f1f4286ee3fd0c563c1cfe623956f3caa24Charles Davis//===----- CGCXXABI.h - Interface to C++ ABIs -------------------*- C++ -*-===//
23a811f1f4286ee3fd0c563c1cfe623956f3caa24Charles Davis//
33a811f1f4286ee3fd0c563c1cfe623956f3caa24Charles Davis//                     The LLVM Compiler Infrastructure
43a811f1f4286ee3fd0c563c1cfe623956f3caa24Charles Davis//
53a811f1f4286ee3fd0c563c1cfe623956f3caa24Charles Davis// This file is distributed under the University of Illinois Open Source
63a811f1f4286ee3fd0c563c1cfe623956f3caa24Charles Davis// License. See LICENSE.TXT for details.
73a811f1f4286ee3fd0c563c1cfe623956f3caa24Charles Davis//
83a811f1f4286ee3fd0c563c1cfe623956f3caa24Charles Davis//===----------------------------------------------------------------------===//
93a811f1f4286ee3fd0c563c1cfe623956f3caa24Charles Davis//
103a811f1f4286ee3fd0c563c1cfe623956f3caa24Charles Davis// This provides an abstract class for C++ code generation. Concrete subclasses
113a811f1f4286ee3fd0c563c1cfe623956f3caa24Charles Davis// of this implement code generation for specific C++ ABIs.
123a811f1f4286ee3fd0c563c1cfe623956f3caa24Charles Davis//
133a811f1f4286ee3fd0c563c1cfe623956f3caa24Charles Davis//===----------------------------------------------------------------------===//
143a811f1f4286ee3fd0c563c1cfe623956f3caa24Charles Davis
153a811f1f4286ee3fd0c563c1cfe623956f3caa24Charles Davis#ifndef CLANG_CODEGEN_CXXABI_H
163a811f1f4286ee3fd0c563c1cfe623956f3caa24Charles Davis#define CLANG_CODEGEN_CXXABI_H
173a811f1f4286ee3fd0c563c1cfe623956f3caa24Charles Davis
184c40d98ab7acf5f27fa89b17bd8fc0ef7683df37John McCall#include "CodeGenFunction.h"
194c40d98ab7acf5f27fa89b17bd8fc0ef7683df37John McCall
2093d557bc1867b7d7b102f87290194b4be7932c92John McCallnamespace llvm {
21cf2c85e76fdafe7e634810a292321a6c8322483dJohn McCall  class Constant;
220bab0cdab751248ca389a5592bcb70eac5d39260John McCall  class Type;
2393d557bc1867b7d7b102f87290194b4be7932c92John McCall  class Value;
244c40d98ab7acf5f27fa89b17bd8fc0ef7683df37John McCall
254c40d98ab7acf5f27fa89b17bd8fc0ef7683df37John McCall  template <class T> class SmallVectorImpl;
2693d557bc1867b7d7b102f87290194b4be7932c92John McCall}
2793d557bc1867b7d7b102f87290194b4be7932c92John McCall
283a811f1f4286ee3fd0c563c1cfe623956f3caa24Charles Davisnamespace clang {
293023def6bea3af6dbb51eea51f8cb8ea892d26cfJohn McCall  class CastExpr;
304c40d98ab7acf5f27fa89b17bd8fc0ef7683df37John McCall  class CXXConstructorDecl;
314c40d98ab7acf5f27fa89b17bd8fc0ef7683df37John McCall  class CXXDestructorDecl;
32875ab10245d3bf37252dd822aa1616bb0a391095John McCall  class CXXMethodDecl;
33cf2c85e76fdafe7e634810a292321a6c8322483dJohn McCall  class CXXRecordDecl;
340bab0cdab751248ca389a5592bcb70eac5d39260John McCall  class FieldDecl;
3593d557bc1867b7d7b102f87290194b4be7932c92John McCall
363a811f1f4286ee3fd0c563c1cfe623956f3caa24Charles Davisnamespace CodeGen {
3793d557bc1867b7d7b102f87290194b4be7932c92John McCall  class CodeGenFunction;
383a811f1f4286ee3fd0c563c1cfe623956f3caa24Charles Davis  class CodeGenModule;
393a811f1f4286ee3fd0c563c1cfe623956f3caa24Charles Davis  class MangleContext;
403a811f1f4286ee3fd0c563c1cfe623956f3caa24Charles Davis
413a811f1f4286ee3fd0c563c1cfe623956f3caa24Charles Davis/// Implements C++ ABI-specific code generation functions.
42071cc7deffad608165b1ddd5263e8bf181861520Charles Davisclass CGCXXABI {
43d608cdb7c044365cf4e8764ade1e11e99c176078John McCallprotected:
44d608cdb7c044365cf4e8764ade1e11e99c176078John McCall  CodeGenModule &CGM;
45d608cdb7c044365cf4e8764ade1e11e99c176078John McCall
46d608cdb7c044365cf4e8764ade1e11e99c176078John McCall  CGCXXABI(CodeGenModule &CGM) : CGM(CGM) {}
47d608cdb7c044365cf4e8764ade1e11e99c176078John McCall
484c40d98ab7acf5f27fa89b17bd8fc0ef7683df37John McCallprotected:
494c40d98ab7acf5f27fa89b17bd8fc0ef7683df37John McCall  ImplicitParamDecl *&getThisDecl(CodeGenFunction &CGF) {
504c40d98ab7acf5f27fa89b17bd8fc0ef7683df37John McCall    return CGF.CXXThisDecl;
514c40d98ab7acf5f27fa89b17bd8fc0ef7683df37John McCall  }
524c40d98ab7acf5f27fa89b17bd8fc0ef7683df37John McCall  llvm::Value *&getThisValue(CodeGenFunction &CGF) {
534c40d98ab7acf5f27fa89b17bd8fc0ef7683df37John McCall    return CGF.CXXThisValue;
544c40d98ab7acf5f27fa89b17bd8fc0ef7683df37John McCall  }
554c40d98ab7acf5f27fa89b17bd8fc0ef7683df37John McCall
564c40d98ab7acf5f27fa89b17bd8fc0ef7683df37John McCall  ImplicitParamDecl *&getVTTDecl(CodeGenFunction &CGF) {
574c40d98ab7acf5f27fa89b17bd8fc0ef7683df37John McCall    return CGF.CXXVTTDecl;
584c40d98ab7acf5f27fa89b17bd8fc0ef7683df37John McCall  }
594c40d98ab7acf5f27fa89b17bd8fc0ef7683df37John McCall  llvm::Value *&getVTTValue(CodeGenFunction &CGF) {
604c40d98ab7acf5f27fa89b17bd8fc0ef7683df37John McCall    return CGF.CXXVTTValue;
614c40d98ab7acf5f27fa89b17bd8fc0ef7683df37John McCall  }
624c40d98ab7acf5f27fa89b17bd8fc0ef7683df37John McCall
634c40d98ab7acf5f27fa89b17bd8fc0ef7683df37John McCall  /// Build a parameter variable suitable for 'this'.
644c40d98ab7acf5f27fa89b17bd8fc0ef7683df37John McCall  void BuildThisParam(CodeGenFunction &CGF, FunctionArgList &Params);
654c40d98ab7acf5f27fa89b17bd8fc0ef7683df37John McCall
664c40d98ab7acf5f27fa89b17bd8fc0ef7683df37John McCall  /// Perform prolog initialization of the parameter variable suitable
674c40d98ab7acf5f27fa89b17bd8fc0ef7683df37John McCall  /// for 'this' emitted by BuildThisParam.
684c40d98ab7acf5f27fa89b17bd8fc0ef7683df37John McCall  void EmitThisParam(CodeGenFunction &CGF);
694c40d98ab7acf5f27fa89b17bd8fc0ef7683df37John McCall
701e7fe751466ea82665fd21e9162fd7cc9c5f412dJohn McCall  ASTContext &getContext() const { return CGM.getContext(); }
711e7fe751466ea82665fd21e9162fd7cc9c5f412dJohn McCall
723a811f1f4286ee3fd0c563c1cfe623956f3caa24Charles Davispublic:
73d608cdb7c044365cf4e8764ade1e11e99c176078John McCall
741af610f8533b8b4a7b0b176aa8082f5b6dde904cAnders Carlsson  virtual ~CGCXXABI();
753a811f1f4286ee3fd0c563c1cfe623956f3caa24Charles Davis
763a811f1f4286ee3fd0c563c1cfe623956f3caa24Charles Davis  /// Gets the mangle context.
773a811f1f4286ee3fd0c563c1cfe623956f3caa24Charles Davis  virtual MangleContext &getMangleContext() = 0;
7893d557bc1867b7d7b102f87290194b4be7932c92John McCall
790bab0cdab751248ca389a5592bcb70eac5d39260John McCall  /// Find the LLVM type used to represent the given member pointer
800bab0cdab751248ca389a5592bcb70eac5d39260John McCall  /// type.
810bab0cdab751248ca389a5592bcb70eac5d39260John McCall  virtual const llvm::Type *
820bab0cdab751248ca389a5592bcb70eac5d39260John McCall  ConvertMemberPointerType(const MemberPointerType *MPT);
830bab0cdab751248ca389a5592bcb70eac5d39260John McCall
840bab0cdab751248ca389a5592bcb70eac5d39260John McCall  /// Load a member function from an object and a member function
850bab0cdab751248ca389a5592bcb70eac5d39260John McCall  /// pointer.  Apply the this-adjustment and set 'This' to the
860bab0cdab751248ca389a5592bcb70eac5d39260John McCall  /// adjusted value.
8793d557bc1867b7d7b102f87290194b4be7932c92John McCall  virtual llvm::Value *
8893d557bc1867b7d7b102f87290194b4be7932c92John McCall  EmitLoadOfMemberFunctionPointer(CodeGenFunction &CGF,
8993d557bc1867b7d7b102f87290194b4be7932c92John McCall                                  llvm::Value *&This,
9093d557bc1867b7d7b102f87290194b4be7932c92John McCall                                  llvm::Value *MemPtr,
9193d557bc1867b7d7b102f87290194b4be7932c92John McCall                                  const MemberPointerType *MPT);
923023def6bea3af6dbb51eea51f8cb8ea892d26cfJohn McCall
936c2ab1d578c6cc1f3ddcc948532cd625f1092ef2John McCall  /// Calculate an l-value from an object and a data member pointer.
946c2ab1d578c6cc1f3ddcc948532cd625f1092ef2John McCall  virtual llvm::Value *EmitMemberDataPointerAddress(CodeGenFunction &CGF,
956c2ab1d578c6cc1f3ddcc948532cd625f1092ef2John McCall                                                    llvm::Value *Base,
966c2ab1d578c6cc1f3ddcc948532cd625f1092ef2John McCall                                                    llvm::Value *MemPtr,
976c2ab1d578c6cc1f3ddcc948532cd625f1092ef2John McCall                                            const MemberPointerType *MPT);
986c2ab1d578c6cc1f3ddcc948532cd625f1092ef2John McCall
990bab0cdab751248ca389a5592bcb70eac5d39260John McCall  /// Perform a derived-to-base or base-to-derived member pointer
1000bab0cdab751248ca389a5592bcb70eac5d39260John McCall  /// conversion.
1010bab0cdab751248ca389a5592bcb70eac5d39260John McCall  virtual llvm::Value *EmitMemberPointerConversion(CodeGenFunction &CGF,
1020bab0cdab751248ca389a5592bcb70eac5d39260John McCall                                                   const CastExpr *E,
1030bab0cdab751248ca389a5592bcb70eac5d39260John McCall                                                   llvm::Value *Src);
104d608cdb7c044365cf4e8764ade1e11e99c176078John McCall
1050bab0cdab751248ca389a5592bcb70eac5d39260John McCall  /// Perform a derived-to-base or base-to-derived member pointer
1060bab0cdab751248ca389a5592bcb70eac5d39260John McCall  /// conversion on a constant member pointer.
1070bab0cdab751248ca389a5592bcb70eac5d39260John McCall  virtual llvm::Constant *EmitMemberPointerConversion(llvm::Constant *C,
1080bab0cdab751248ca389a5592bcb70eac5d39260John McCall                                                      const CastExpr *E);
109cf2c85e76fdafe7e634810a292321a6c8322483dJohn McCall
1100bab0cdab751248ca389a5592bcb70eac5d39260John McCall  /// Return true if the given member pointer can be zero-initialized
1110bab0cdab751248ca389a5592bcb70eac5d39260John McCall  /// (in the C++ sense) with an LLVM zeroinitializer.
112f16aa103d3afd42fbca2ab346f191bf745cec092John McCall  virtual bool isZeroInitializable(const MemberPointerType *MPT);
113cf2c85e76fdafe7e634810a292321a6c8322483dJohn McCall
1140bab0cdab751248ca389a5592bcb70eac5d39260John McCall  /// Create a null member pointer of the given type.
1150bab0cdab751248ca389a5592bcb70eac5d39260John McCall  virtual llvm::Constant *EmitNullMemberPointer(const MemberPointerType *MPT);
116cf2c85e76fdafe7e634810a292321a6c8322483dJohn McCall
1170bab0cdab751248ca389a5592bcb70eac5d39260John McCall  /// Create a member pointer for the given method.
1180bab0cdab751248ca389a5592bcb70eac5d39260John McCall  virtual llvm::Constant *EmitMemberPointer(const CXXMethodDecl *MD);
119875ab10245d3bf37252dd822aa1616bb0a391095John McCall
1200bab0cdab751248ca389a5592bcb70eac5d39260John McCall  /// Create a member pointer for the given field.
1210bab0cdab751248ca389a5592bcb70eac5d39260John McCall  virtual llvm::Constant *EmitMemberPointer(const FieldDecl *FD);
122e9fd7eb6c67676dc27e84eac429aec4f3be51f26John McCall
1230bab0cdab751248ca389a5592bcb70eac5d39260John McCall  /// Emit a comparison between two member pointers.  Returns an i1.
124e9fd7eb6c67676dc27e84eac429aec4f3be51f26John McCall  virtual llvm::Value *
1250bab0cdab751248ca389a5592bcb70eac5d39260John McCall  EmitMemberPointerComparison(CodeGenFunction &CGF,
1260bab0cdab751248ca389a5592bcb70eac5d39260John McCall                              llvm::Value *L,
1270bab0cdab751248ca389a5592bcb70eac5d39260John McCall                              llvm::Value *R,
1280bab0cdab751248ca389a5592bcb70eac5d39260John McCall                              const MemberPointerType *MPT,
1290bab0cdab751248ca389a5592bcb70eac5d39260John McCall                              bool Inequality);
130e9fd7eb6c67676dc27e84eac429aec4f3be51f26John McCall
1310bab0cdab751248ca389a5592bcb70eac5d39260John McCall  /// Determine if a member pointer is non-null.  Returns an i1.
132e9fd7eb6c67676dc27e84eac429aec4f3be51f26John McCall  virtual llvm::Value *
1330bab0cdab751248ca389a5592bcb70eac5d39260John McCall  EmitMemberPointerIsNotNull(CodeGenFunction &CGF,
1340bab0cdab751248ca389a5592bcb70eac5d39260John McCall                             llvm::Value *MemPtr,
1350bab0cdab751248ca389a5592bcb70eac5d39260John McCall                             const MemberPointerType *MPT);
1364c40d98ab7acf5f27fa89b17bd8fc0ef7683df37John McCall
1374c40d98ab7acf5f27fa89b17bd8fc0ef7683df37John McCall  /// Build the signature of the given constructor variant by adding
1384c40d98ab7acf5f27fa89b17bd8fc0ef7683df37John McCall  /// any required parameters.  For convenience, ResTy has been
1394c40d98ab7acf5f27fa89b17bd8fc0ef7683df37John McCall  /// initialized to 'void', and ArgTys has been initialized with the
1404c40d98ab7acf5f27fa89b17bd8fc0ef7683df37John McCall  /// type of 'this' (although this may be changed by the ABI) and
1414c40d98ab7acf5f27fa89b17bd8fc0ef7683df37John McCall  /// will have the formal parameters added to it afterwards.
1424c40d98ab7acf5f27fa89b17bd8fc0ef7683df37John McCall  ///
1434c40d98ab7acf5f27fa89b17bd8fc0ef7683df37John McCall  /// If there are ever any ABIs where the implicit parameters are
1444c40d98ab7acf5f27fa89b17bd8fc0ef7683df37John McCall  /// intermixed with the formal parameters, we can address those
1454c40d98ab7acf5f27fa89b17bd8fc0ef7683df37John McCall  /// then.
1464c40d98ab7acf5f27fa89b17bd8fc0ef7683df37John McCall  virtual void BuildConstructorSignature(const CXXConstructorDecl *Ctor,
1474c40d98ab7acf5f27fa89b17bd8fc0ef7683df37John McCall                                         CXXCtorType T,
1484c40d98ab7acf5f27fa89b17bd8fc0ef7683df37John McCall                                         CanQualType &ResTy,
1494c40d98ab7acf5f27fa89b17bd8fc0ef7683df37John McCall                               llvm::SmallVectorImpl<CanQualType> &ArgTys) = 0;
1504c40d98ab7acf5f27fa89b17bd8fc0ef7683df37John McCall
1514c40d98ab7acf5f27fa89b17bd8fc0ef7683df37John McCall  /// Build the signature of the given destructor variant by adding
1524c40d98ab7acf5f27fa89b17bd8fc0ef7683df37John McCall  /// any required parameters.  For convenience, ResTy has been
1534c40d98ab7acf5f27fa89b17bd8fc0ef7683df37John McCall  /// initialized to 'void' and ArgTys has been initialized with the
1544c40d98ab7acf5f27fa89b17bd8fc0ef7683df37John McCall  /// type of 'this' (although this may be changed by the ABI).
1554c40d98ab7acf5f27fa89b17bd8fc0ef7683df37John McCall  virtual void BuildDestructorSignature(const CXXDestructorDecl *Dtor,
1564c40d98ab7acf5f27fa89b17bd8fc0ef7683df37John McCall                                        CXXDtorType T,
1574c40d98ab7acf5f27fa89b17bd8fc0ef7683df37John McCall                                        CanQualType &ResTy,
1584c40d98ab7acf5f27fa89b17bd8fc0ef7683df37John McCall                               llvm::SmallVectorImpl<CanQualType> &ArgTys) = 0;
1594c40d98ab7acf5f27fa89b17bd8fc0ef7683df37John McCall
1604c40d98ab7acf5f27fa89b17bd8fc0ef7683df37John McCall  /// Build the ABI-specific portion of the parameter list for a
1614c40d98ab7acf5f27fa89b17bd8fc0ef7683df37John McCall  /// function.  This generally involves a 'this' parameter and
1624c40d98ab7acf5f27fa89b17bd8fc0ef7683df37John McCall  /// possibly some extra data for constructors and destructors.
1634c40d98ab7acf5f27fa89b17bd8fc0ef7683df37John McCall  ///
1644c40d98ab7acf5f27fa89b17bd8fc0ef7683df37John McCall  /// ABIs may also choose to override the return type, which has been
1654c40d98ab7acf5f27fa89b17bd8fc0ef7683df37John McCall  /// initialized with the formal return type of the function.
1664c40d98ab7acf5f27fa89b17bd8fc0ef7683df37John McCall  virtual void BuildInstanceFunctionParams(CodeGenFunction &CGF,
1674c40d98ab7acf5f27fa89b17bd8fc0ef7683df37John McCall                                           QualType &ResTy,
1684c40d98ab7acf5f27fa89b17bd8fc0ef7683df37John McCall                                           FunctionArgList &Params) = 0;
1694c40d98ab7acf5f27fa89b17bd8fc0ef7683df37John McCall
1704c40d98ab7acf5f27fa89b17bd8fc0ef7683df37John McCall  /// Emit the ABI-specific prolog for the function.
1714c40d98ab7acf5f27fa89b17bd8fc0ef7683df37John McCall  virtual void EmitInstanceFunctionProlog(CodeGenFunction &CGF) = 0;
1724c40d98ab7acf5f27fa89b17bd8fc0ef7683df37John McCall
1734c40d98ab7acf5f27fa89b17bd8fc0ef7683df37John McCall  virtual void EmitReturnFromThunk(CodeGenFunction &CGF,
1744c40d98ab7acf5f27fa89b17bd8fc0ef7683df37John McCall                                   RValue RV, QualType ResultType);
1751e7fe751466ea82665fd21e9162fd7cc9c5f412dJohn McCall
1761e7fe751466ea82665fd21e9162fd7cc9c5f412dJohn McCall  /**************************** Array cookies ******************************/
1771e7fe751466ea82665fd21e9162fd7cc9c5f412dJohn McCall
1781e7fe751466ea82665fd21e9162fd7cc9c5f412dJohn McCall  /// Returns the extra size required in order to store the array
1791e7fe751466ea82665fd21e9162fd7cc9c5f412dJohn McCall  /// cookie for the given type.  May return 0 to indicate that no
1801e7fe751466ea82665fd21e9162fd7cc9c5f412dJohn McCall  /// array cookie is required.
1811e7fe751466ea82665fd21e9162fd7cc9c5f412dJohn McCall  ///
1821e7fe751466ea82665fd21e9162fd7cc9c5f412dJohn McCall  /// Several cases are filtered out before this method is called:
1831e7fe751466ea82665fd21e9162fd7cc9c5f412dJohn McCall  ///   - non-array allocations never need a cookie
1841e7fe751466ea82665fd21e9162fd7cc9c5f412dJohn McCall  ///   - calls to ::operator new(size_t, void*) never need a cookie
1851e7fe751466ea82665fd21e9162fd7cc9c5f412dJohn McCall  ///
1861e7fe751466ea82665fd21e9162fd7cc9c5f412dJohn McCall  /// \param ElementType - the allocated type of the expression,
1871e7fe751466ea82665fd21e9162fd7cc9c5f412dJohn McCall  ///   i.e. the pointee type of the expression result type
1881e7fe751466ea82665fd21e9162fd7cc9c5f412dJohn McCall  virtual CharUnits GetArrayCookieSize(QualType ElementType);
1891e7fe751466ea82665fd21e9162fd7cc9c5f412dJohn McCall
1901e7fe751466ea82665fd21e9162fd7cc9c5f412dJohn McCall  /// Initialize the array cookie for the given allocation.
1911e7fe751466ea82665fd21e9162fd7cc9c5f412dJohn McCall  ///
1921e7fe751466ea82665fd21e9162fd7cc9c5f412dJohn McCall  /// \param NewPtr - a char* which is the presumed-non-null
1931e7fe751466ea82665fd21e9162fd7cc9c5f412dJohn McCall  ///   return value of the allocation function
1941e7fe751466ea82665fd21e9162fd7cc9c5f412dJohn McCall  /// \param NumElements - the computed number of elements,
1951e7fe751466ea82665fd21e9162fd7cc9c5f412dJohn McCall  ///   potentially collapsed from the multidimensional array case
1961e7fe751466ea82665fd21e9162fd7cc9c5f412dJohn McCall  /// \param ElementType - the base element allocated type,
1971e7fe751466ea82665fd21e9162fd7cc9c5f412dJohn McCall  ///   i.e. the allocated type after stripping all array types
1981e7fe751466ea82665fd21e9162fd7cc9c5f412dJohn McCall  virtual llvm::Value *InitializeArrayCookie(CodeGenFunction &CGF,
1991e7fe751466ea82665fd21e9162fd7cc9c5f412dJohn McCall                                             llvm::Value *NewPtr,
2001e7fe751466ea82665fd21e9162fd7cc9c5f412dJohn McCall                                             llvm::Value *NumElements,
2011e7fe751466ea82665fd21e9162fd7cc9c5f412dJohn McCall                                             QualType ElementType);
2021e7fe751466ea82665fd21e9162fd7cc9c5f412dJohn McCall
2031e7fe751466ea82665fd21e9162fd7cc9c5f412dJohn McCall  /// Reads the array cookie associated with the given pointer,
2041e7fe751466ea82665fd21e9162fd7cc9c5f412dJohn McCall  /// if it has one.
2051e7fe751466ea82665fd21e9162fd7cc9c5f412dJohn McCall  ///
2061e7fe751466ea82665fd21e9162fd7cc9c5f412dJohn McCall  /// \param Ptr - a pointer to the first element in the array
2071e7fe751466ea82665fd21e9162fd7cc9c5f412dJohn McCall  /// \param ElementType - the base element type of elements of the array
2081e7fe751466ea82665fd21e9162fd7cc9c5f412dJohn McCall  /// \param NumElements - an out parameter which will be initialized
2091e7fe751466ea82665fd21e9162fd7cc9c5f412dJohn McCall  ///   with the number of elements allocated, or zero if there is no
2101e7fe751466ea82665fd21e9162fd7cc9c5f412dJohn McCall  ///   cookie
2111e7fe751466ea82665fd21e9162fd7cc9c5f412dJohn McCall  /// \param AllocPtr - an out parameter which will be initialized
2121e7fe751466ea82665fd21e9162fd7cc9c5f412dJohn McCall  ///   with a char* pointing to the address returned by the allocation
2131e7fe751466ea82665fd21e9162fd7cc9c5f412dJohn McCall  ///   function
2141e7fe751466ea82665fd21e9162fd7cc9c5f412dJohn McCall  /// \param CookieSize - an out parameter which will be initialized
2151e7fe751466ea82665fd21e9162fd7cc9c5f412dJohn McCall  ///   with the size of the cookie, or zero if there is no cookie
2161e7fe751466ea82665fd21e9162fd7cc9c5f412dJohn McCall  virtual void ReadArrayCookie(CodeGenFunction &CGF, llvm::Value *Ptr,
2171e7fe751466ea82665fd21e9162fd7cc9c5f412dJohn McCall                               QualType ElementType, llvm::Value *&NumElements,
2181e7fe751466ea82665fd21e9162fd7cc9c5f412dJohn McCall                               llvm::Value *&AllocPtr, CharUnits &CookieSize);
2191e7fe751466ea82665fd21e9162fd7cc9c5f412dJohn McCall
2205cd91b513455fd7753e8815b54f0a49bbca6602dJohn McCall  /*************************** Static local guards ****************************/
2215cd91b513455fd7753e8815b54f0a49bbca6602dJohn McCall
2223030eb82593097502469a8b3fc26112c79c75605John McCall  /// Emits the guarded initializer and destructor setup for the given
2233030eb82593097502469a8b3fc26112c79c75605John McCall  /// variable, given that it couldn't be emitted as a constant.
2243030eb82593097502469a8b3fc26112c79c75605John McCall  ///
2253030eb82593097502469a8b3fc26112c79c75605John McCall  /// The variable may be:
2263030eb82593097502469a8b3fc26112c79c75605John McCall  ///   - a static local variable
2273030eb82593097502469a8b3fc26112c79c75605John McCall  ///   - a static data member of a class template instantiation
2283030eb82593097502469a8b3fc26112c79c75605John McCall  virtual void EmitGuardedInit(CodeGenFunction &CGF, const VarDecl &D,
2293030eb82593097502469a8b3fc26112c79c75605John McCall                               llvm::GlobalVariable *DeclPtr);
2305cd91b513455fd7753e8815b54f0a49bbca6602dJohn McCall
2313a811f1f4286ee3fd0c563c1cfe623956f3caa24Charles Davis};
2323a811f1f4286ee3fd0c563c1cfe623956f3caa24Charles Davis
2333a811f1f4286ee3fd0c563c1cfe623956f3caa24Charles Davis/// Creates an instance of a C++ ABI class.
234ee79a4c30e5d1c5285551c9a25b8ec6d45d46aa7John McCallCGCXXABI *CreateARMCXXABI(CodeGenModule &CGM);
235071cc7deffad608165b1ddd5263e8bf181861520Charles DavisCGCXXABI *CreateItaniumCXXABI(CodeGenModule &CGM);
236071cc7deffad608165b1ddd5263e8bf181861520Charles DavisCGCXXABI *CreateMicrosoftCXXABI(CodeGenModule &CGM);
23793d557bc1867b7d7b102f87290194b4be7932c92John McCall
2383a811f1f4286ee3fd0c563c1cfe623956f3caa24Charles Davis}
2393a811f1f4286ee3fd0c563c1cfe623956f3caa24Charles Davis}
2403a811f1f4286ee3fd0c563c1cfe623956f3caa24Charles Davis
2413a811f1f4286ee3fd0c563c1cfe623956f3caa24Charles Davis#endif
242