CGCXXABI.h revision 2d6a5670465cb3f1d811695a9f23e372508240d2
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
18d47d3b0cfeb7e8564ff77f48130fe63282b6d127Chris Lattner#include "clang/Basic/LLVM.h"
19d47d3b0cfeb7e8564ff77f48130fe63282b6d127Chris Lattner
204c40d98ab7acf5f27fa89b17bd8fc0ef7683df37John McCall#include "CodeGenFunction.h"
214c40d98ab7acf5f27fa89b17bd8fc0ef7683df37John McCall
2293d557bc1867b7d7b102f87290194b4be7932c92John McCallnamespace llvm {
23cf2c85e76fdafe7e634810a292321a6c8322483dJohn McCall  class Constant;
240bab0cdab751248ca389a5592bcb70eac5d39260John McCall  class Type;
2593d557bc1867b7d7b102f87290194b4be7932c92John McCall  class Value;
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;
3514110477887e3dc168ffc6c191e72d705051f99ePeter Collingbourne  class MangleContext;
3693d557bc1867b7d7b102f87290194b4be7932c92John McCall
373a811f1f4286ee3fd0c563c1cfe623956f3caa24Charles Davisnamespace CodeGen {
3893d557bc1867b7d7b102f87290194b4be7932c92John McCall  class CodeGenFunction;
393a811f1f4286ee3fd0c563c1cfe623956f3caa24Charles Davis  class CodeGenModule;
403a811f1f4286ee3fd0c563c1cfe623956f3caa24Charles Davis
413a811f1f4286ee3fd0c563c1cfe623956f3caa24Charles Davis/// Implements C++ ABI-specific code generation functions.
42071cc7deffad608165b1ddd5263e8bf181861520Charles Davisclass CGCXXABI {
43d608cdb7c044365cf4e8764ade1e11e99c176078John McCallprotected:
44d608cdb7c044365cf4e8764ade1e11e99c176078John McCall  CodeGenModule &CGM;
4514110477887e3dc168ffc6c191e72d705051f99ePeter Collingbourne  llvm::OwningPtr<MangleContext> MangleCtx;
46d608cdb7c044365cf4e8764ade1e11e99c176078John McCall
4714110477887e3dc168ffc6c191e72d705051f99ePeter Collingbourne  CGCXXABI(CodeGenModule &CGM)
4814110477887e3dc168ffc6c191e72d705051f99ePeter Collingbourne    : CGM(CGM), MangleCtx(CGM.getContext().createMangleContext()) {}
49d608cdb7c044365cf4e8764ade1e11e99c176078John McCall
504c40d98ab7acf5f27fa89b17bd8fc0ef7683df37John McCallprotected:
514c40d98ab7acf5f27fa89b17bd8fc0ef7683df37John McCall  ImplicitParamDecl *&getThisDecl(CodeGenFunction &CGF) {
524c40d98ab7acf5f27fa89b17bd8fc0ef7683df37John McCall    return CGF.CXXThisDecl;
534c40d98ab7acf5f27fa89b17bd8fc0ef7683df37John McCall  }
544c40d98ab7acf5f27fa89b17bd8fc0ef7683df37John McCall  llvm::Value *&getThisValue(CodeGenFunction &CGF) {
554c40d98ab7acf5f27fa89b17bd8fc0ef7683df37John McCall    return CGF.CXXThisValue;
564c40d98ab7acf5f27fa89b17bd8fc0ef7683df37John McCall  }
574c40d98ab7acf5f27fa89b17bd8fc0ef7683df37John McCall
584c40d98ab7acf5f27fa89b17bd8fc0ef7683df37John McCall  ImplicitParamDecl *&getVTTDecl(CodeGenFunction &CGF) {
594c40d98ab7acf5f27fa89b17bd8fc0ef7683df37John McCall    return CGF.CXXVTTDecl;
604c40d98ab7acf5f27fa89b17bd8fc0ef7683df37John McCall  }
614c40d98ab7acf5f27fa89b17bd8fc0ef7683df37John McCall  llvm::Value *&getVTTValue(CodeGenFunction &CGF) {
624c40d98ab7acf5f27fa89b17bd8fc0ef7683df37John McCall    return CGF.CXXVTTValue;
634c40d98ab7acf5f27fa89b17bd8fc0ef7683df37John McCall  }
644c40d98ab7acf5f27fa89b17bd8fc0ef7683df37John McCall
654c40d98ab7acf5f27fa89b17bd8fc0ef7683df37John McCall  /// Build a parameter variable suitable for 'this'.
664c40d98ab7acf5f27fa89b17bd8fc0ef7683df37John McCall  void BuildThisParam(CodeGenFunction &CGF, FunctionArgList &Params);
674c40d98ab7acf5f27fa89b17bd8fc0ef7683df37John McCall
684c40d98ab7acf5f27fa89b17bd8fc0ef7683df37John McCall  /// Perform prolog initialization of the parameter variable suitable
694c40d98ab7acf5f27fa89b17bd8fc0ef7683df37John McCall  /// for 'this' emitted by BuildThisParam.
704c40d98ab7acf5f27fa89b17bd8fc0ef7683df37John McCall  void EmitThisParam(CodeGenFunction &CGF);
714c40d98ab7acf5f27fa89b17bd8fc0ef7683df37John McCall
721e7fe751466ea82665fd21e9162fd7cc9c5f412dJohn McCall  ASTContext &getContext() const { return CGM.getContext(); }
731e7fe751466ea82665fd21e9162fd7cc9c5f412dJohn McCall
743a811f1f4286ee3fd0c563c1cfe623956f3caa24Charles Davispublic:
75d608cdb7c044365cf4e8764ade1e11e99c176078John McCall
761af610f8533b8b4a7b0b176aa8082f5b6dde904cAnders Carlsson  virtual ~CGCXXABI();
773a811f1f4286ee3fd0c563c1cfe623956f3caa24Charles Davis
783a811f1f4286ee3fd0c563c1cfe623956f3caa24Charles Davis  /// Gets the mangle context.
7914110477887e3dc168ffc6c191e72d705051f99ePeter Collingbourne  MangleContext &getMangleContext() {
8014110477887e3dc168ffc6c191e72d705051f99ePeter Collingbourne    return *MangleCtx;
8114110477887e3dc168ffc6c191e72d705051f99ePeter Collingbourne  }
8293d557bc1867b7d7b102f87290194b4be7932c92John McCall
830bab0cdab751248ca389a5592bcb70eac5d39260John McCall  /// Find the LLVM type used to represent the given member pointer
840bab0cdab751248ca389a5592bcb70eac5d39260John McCall  /// type.
859cbe4f0ba01ec304e1e3d071c071f7bca33631c0Chris Lattner  virtual llvm::Type *
860bab0cdab751248ca389a5592bcb70eac5d39260John McCall  ConvertMemberPointerType(const MemberPointerType *MPT);
870bab0cdab751248ca389a5592bcb70eac5d39260John McCall
880bab0cdab751248ca389a5592bcb70eac5d39260John McCall  /// Load a member function from an object and a member function
890bab0cdab751248ca389a5592bcb70eac5d39260John McCall  /// pointer.  Apply the this-adjustment and set 'This' to the
900bab0cdab751248ca389a5592bcb70eac5d39260John McCall  /// adjusted value.
9193d557bc1867b7d7b102f87290194b4be7932c92John McCall  virtual llvm::Value *
9293d557bc1867b7d7b102f87290194b4be7932c92John McCall  EmitLoadOfMemberFunctionPointer(CodeGenFunction &CGF,
9393d557bc1867b7d7b102f87290194b4be7932c92John McCall                                  llvm::Value *&This,
9493d557bc1867b7d7b102f87290194b4be7932c92John McCall                                  llvm::Value *MemPtr,
9593d557bc1867b7d7b102f87290194b4be7932c92John McCall                                  const MemberPointerType *MPT);
963023def6bea3af6dbb51eea51f8cb8ea892d26cfJohn McCall
976c2ab1d578c6cc1f3ddcc948532cd625f1092ef2John McCall  /// Calculate an l-value from an object and a data member pointer.
986c2ab1d578c6cc1f3ddcc948532cd625f1092ef2John McCall  virtual llvm::Value *EmitMemberDataPointerAddress(CodeGenFunction &CGF,
996c2ab1d578c6cc1f3ddcc948532cd625f1092ef2John McCall                                                    llvm::Value *Base,
1006c2ab1d578c6cc1f3ddcc948532cd625f1092ef2John McCall                                                    llvm::Value *MemPtr,
1016c2ab1d578c6cc1f3ddcc948532cd625f1092ef2John McCall                                            const MemberPointerType *MPT);
1026c2ab1d578c6cc1f3ddcc948532cd625f1092ef2John McCall
1030bab0cdab751248ca389a5592bcb70eac5d39260John McCall  /// Perform a derived-to-base or base-to-derived member pointer
1040bab0cdab751248ca389a5592bcb70eac5d39260John McCall  /// conversion.
1050bab0cdab751248ca389a5592bcb70eac5d39260John McCall  virtual llvm::Value *EmitMemberPointerConversion(CodeGenFunction &CGF,
1060bab0cdab751248ca389a5592bcb70eac5d39260John McCall                                                   const CastExpr *E,
1070bab0cdab751248ca389a5592bcb70eac5d39260John McCall                                                   llvm::Value *Src);
108d608cdb7c044365cf4e8764ade1e11e99c176078John McCall
1090bab0cdab751248ca389a5592bcb70eac5d39260John McCall  /// Perform a derived-to-base or base-to-derived member pointer
1100bab0cdab751248ca389a5592bcb70eac5d39260John McCall  /// conversion on a constant member pointer.
1110bab0cdab751248ca389a5592bcb70eac5d39260John McCall  virtual llvm::Constant *EmitMemberPointerConversion(llvm::Constant *C,
1120bab0cdab751248ca389a5592bcb70eac5d39260John McCall                                                      const CastExpr *E);
113cf2c85e76fdafe7e634810a292321a6c8322483dJohn McCall
1140bab0cdab751248ca389a5592bcb70eac5d39260John McCall  /// Return true if the given member pointer can be zero-initialized
1150bab0cdab751248ca389a5592bcb70eac5d39260John McCall  /// (in the C++ sense) with an LLVM zeroinitializer.
116f16aa103d3afd42fbca2ab346f191bf745cec092John McCall  virtual bool isZeroInitializable(const MemberPointerType *MPT);
117cf2c85e76fdafe7e634810a292321a6c8322483dJohn McCall
1180bab0cdab751248ca389a5592bcb70eac5d39260John McCall  /// Create a null member pointer of the given type.
1190bab0cdab751248ca389a5592bcb70eac5d39260John McCall  virtual llvm::Constant *EmitNullMemberPointer(const MemberPointerType *MPT);
120cf2c85e76fdafe7e634810a292321a6c8322483dJohn McCall
1210bab0cdab751248ca389a5592bcb70eac5d39260John McCall  /// Create a member pointer for the given method.
122755d8497e39071aa24acc173ff07083e3256b8f8John McCall  virtual llvm::Constant *EmitMemberPointer(const CXXMethodDecl *MD);
123875ab10245d3bf37252dd822aa1616bb0a391095John McCall
1240bab0cdab751248ca389a5592bcb70eac5d39260John McCall  /// Create a member pointer for the given field.
1255808ce43f8d7e71f5acacc9ca320268c4f37565aJohn McCall  virtual llvm::Constant *EmitMemberDataPointer(const MemberPointerType *MPT,
1265808ce43f8d7e71f5acacc9ca320268c4f37565aJohn McCall                                                CharUnits offset);
127e9fd7eb6c67676dc27e84eac429aec4f3be51f26John McCall
1282d6a5670465cb3f1d811695a9f23e372508240d2Richard Smith  /// Create a member pointer for the given member pointer constant.
1292d6a5670465cb3f1d811695a9f23e372508240d2Richard Smith  virtual llvm::Constant *EmitMemberPointer(const APValue &MP, QualType MPT);
1302d6a5670465cb3f1d811695a9f23e372508240d2Richard Smith
1310bab0cdab751248ca389a5592bcb70eac5d39260John McCall  /// Emit a comparison between two member pointers.  Returns an i1.
132e9fd7eb6c67676dc27e84eac429aec4f3be51f26John McCall  virtual llvm::Value *
1330bab0cdab751248ca389a5592bcb70eac5d39260John McCall  EmitMemberPointerComparison(CodeGenFunction &CGF,
1340bab0cdab751248ca389a5592bcb70eac5d39260John McCall                              llvm::Value *L,
1350bab0cdab751248ca389a5592bcb70eac5d39260John McCall                              llvm::Value *R,
1360bab0cdab751248ca389a5592bcb70eac5d39260John McCall                              const MemberPointerType *MPT,
1370bab0cdab751248ca389a5592bcb70eac5d39260John McCall                              bool Inequality);
138e9fd7eb6c67676dc27e84eac429aec4f3be51f26John McCall
1390bab0cdab751248ca389a5592bcb70eac5d39260John McCall  /// Determine if a member pointer is non-null.  Returns an i1.
140e9fd7eb6c67676dc27e84eac429aec4f3be51f26John McCall  virtual llvm::Value *
1410bab0cdab751248ca389a5592bcb70eac5d39260John McCall  EmitMemberPointerIsNotNull(CodeGenFunction &CGF,
1420bab0cdab751248ca389a5592bcb70eac5d39260John McCall                             llvm::Value *MemPtr,
1430bab0cdab751248ca389a5592bcb70eac5d39260John McCall                             const MemberPointerType *MPT);
1444c40d98ab7acf5f27fa89b17bd8fc0ef7683df37John McCall
1454c40d98ab7acf5f27fa89b17bd8fc0ef7683df37John McCall  /// Build the signature of the given constructor variant by adding
1464c40d98ab7acf5f27fa89b17bd8fc0ef7683df37John McCall  /// any required parameters.  For convenience, ResTy has been
1474c40d98ab7acf5f27fa89b17bd8fc0ef7683df37John McCall  /// initialized to 'void', and ArgTys has been initialized with the
1484c40d98ab7acf5f27fa89b17bd8fc0ef7683df37John McCall  /// type of 'this' (although this may be changed by the ABI) and
1494c40d98ab7acf5f27fa89b17bd8fc0ef7683df37John McCall  /// will have the formal parameters added to it afterwards.
1504c40d98ab7acf5f27fa89b17bd8fc0ef7683df37John McCall  ///
1514c40d98ab7acf5f27fa89b17bd8fc0ef7683df37John McCall  /// If there are ever any ABIs where the implicit parameters are
1524c40d98ab7acf5f27fa89b17bd8fc0ef7683df37John McCall  /// intermixed with the formal parameters, we can address those
1534c40d98ab7acf5f27fa89b17bd8fc0ef7683df37John McCall  /// then.
1544c40d98ab7acf5f27fa89b17bd8fc0ef7683df37John McCall  virtual void BuildConstructorSignature(const CXXConstructorDecl *Ctor,
1554c40d98ab7acf5f27fa89b17bd8fc0ef7683df37John McCall                                         CXXCtorType T,
1564c40d98ab7acf5f27fa89b17bd8fc0ef7683df37John McCall                                         CanQualType &ResTy,
157686775deca8b8685eb90801495880e3abdd844c2Chris Lattner                               SmallVectorImpl<CanQualType> &ArgTys) = 0;
1584c40d98ab7acf5f27fa89b17bd8fc0ef7683df37John McCall
1594c40d98ab7acf5f27fa89b17bd8fc0ef7683df37John McCall  /// Build the signature of the given destructor variant by adding
1604c40d98ab7acf5f27fa89b17bd8fc0ef7683df37John McCall  /// any required parameters.  For convenience, ResTy has been
1614c40d98ab7acf5f27fa89b17bd8fc0ef7683df37John McCall  /// initialized to 'void' and ArgTys has been initialized with the
1624c40d98ab7acf5f27fa89b17bd8fc0ef7683df37John McCall  /// type of 'this' (although this may be changed by the ABI).
1634c40d98ab7acf5f27fa89b17bd8fc0ef7683df37John McCall  virtual void BuildDestructorSignature(const CXXDestructorDecl *Dtor,
1644c40d98ab7acf5f27fa89b17bd8fc0ef7683df37John McCall                                        CXXDtorType T,
1654c40d98ab7acf5f27fa89b17bd8fc0ef7683df37John McCall                                        CanQualType &ResTy,
166686775deca8b8685eb90801495880e3abdd844c2Chris Lattner                               SmallVectorImpl<CanQualType> &ArgTys) = 0;
1674c40d98ab7acf5f27fa89b17bd8fc0ef7683df37John McCall
1684c40d98ab7acf5f27fa89b17bd8fc0ef7683df37John McCall  /// Build the ABI-specific portion of the parameter list for a
1694c40d98ab7acf5f27fa89b17bd8fc0ef7683df37John McCall  /// function.  This generally involves a 'this' parameter and
1704c40d98ab7acf5f27fa89b17bd8fc0ef7683df37John McCall  /// possibly some extra data for constructors and destructors.
1714c40d98ab7acf5f27fa89b17bd8fc0ef7683df37John McCall  ///
1724c40d98ab7acf5f27fa89b17bd8fc0ef7683df37John McCall  /// ABIs may also choose to override the return type, which has been
1734c40d98ab7acf5f27fa89b17bd8fc0ef7683df37John McCall  /// initialized with the formal return type of the function.
1744c40d98ab7acf5f27fa89b17bd8fc0ef7683df37John McCall  virtual void BuildInstanceFunctionParams(CodeGenFunction &CGF,
1754c40d98ab7acf5f27fa89b17bd8fc0ef7683df37John McCall                                           QualType &ResTy,
1764c40d98ab7acf5f27fa89b17bd8fc0ef7683df37John McCall                                           FunctionArgList &Params) = 0;
1774c40d98ab7acf5f27fa89b17bd8fc0ef7683df37John McCall
1784c40d98ab7acf5f27fa89b17bd8fc0ef7683df37John McCall  /// Emit the ABI-specific prolog for the function.
1794c40d98ab7acf5f27fa89b17bd8fc0ef7683df37John McCall  virtual void EmitInstanceFunctionProlog(CodeGenFunction &CGF) = 0;
1804c40d98ab7acf5f27fa89b17bd8fc0ef7683df37John McCall
1814c40d98ab7acf5f27fa89b17bd8fc0ef7683df37John McCall  virtual void EmitReturnFromThunk(CodeGenFunction &CGF,
1824c40d98ab7acf5f27fa89b17bd8fc0ef7683df37John McCall                                   RValue RV, QualType ResultType);
1831e7fe751466ea82665fd21e9162fd7cc9c5f412dJohn McCall
1841e7fe751466ea82665fd21e9162fd7cc9c5f412dJohn McCall  /**************************** Array cookies ******************************/
1851e7fe751466ea82665fd21e9162fd7cc9c5f412dJohn McCall
1861e7fe751466ea82665fd21e9162fd7cc9c5f412dJohn McCall  /// Returns the extra size required in order to store the array
1871e7fe751466ea82665fd21e9162fd7cc9c5f412dJohn McCall  /// cookie for the given type.  May return 0 to indicate that no
1881e7fe751466ea82665fd21e9162fd7cc9c5f412dJohn McCall  /// array cookie is required.
1891e7fe751466ea82665fd21e9162fd7cc9c5f412dJohn McCall  ///
1901e7fe751466ea82665fd21e9162fd7cc9c5f412dJohn McCall  /// Several cases are filtered out before this method is called:
1911e7fe751466ea82665fd21e9162fd7cc9c5f412dJohn McCall  ///   - non-array allocations never need a cookie
1921e7fe751466ea82665fd21e9162fd7cc9c5f412dJohn McCall  ///   - calls to ::operator new(size_t, void*) never need a cookie
1931e7fe751466ea82665fd21e9162fd7cc9c5f412dJohn McCall  ///
1941e7fe751466ea82665fd21e9162fd7cc9c5f412dJohn McCall  /// \param ElementType - the allocated type of the expression,
1951e7fe751466ea82665fd21e9162fd7cc9c5f412dJohn McCall  ///   i.e. the pointee type of the expression result type
1966ec278d1a354517e20f13a877481453ee7940c78John McCall  virtual CharUnits GetArrayCookieSize(const CXXNewExpr *expr);
1971e7fe751466ea82665fd21e9162fd7cc9c5f412dJohn McCall
1981e7fe751466ea82665fd21e9162fd7cc9c5f412dJohn McCall  /// Initialize the array cookie for the given allocation.
1991e7fe751466ea82665fd21e9162fd7cc9c5f412dJohn McCall  ///
2001e7fe751466ea82665fd21e9162fd7cc9c5f412dJohn McCall  /// \param NewPtr - a char* which is the presumed-non-null
2011e7fe751466ea82665fd21e9162fd7cc9c5f412dJohn McCall  ///   return value of the allocation function
2021e7fe751466ea82665fd21e9162fd7cc9c5f412dJohn McCall  /// \param NumElements - the computed number of elements,
2031e7fe751466ea82665fd21e9162fd7cc9c5f412dJohn McCall  ///   potentially collapsed from the multidimensional array case
2041e7fe751466ea82665fd21e9162fd7cc9c5f412dJohn McCall  /// \param ElementType - the base element allocated type,
2051e7fe751466ea82665fd21e9162fd7cc9c5f412dJohn McCall  ///   i.e. the allocated type after stripping all array types
2061e7fe751466ea82665fd21e9162fd7cc9c5f412dJohn McCall  virtual llvm::Value *InitializeArrayCookie(CodeGenFunction &CGF,
2071e7fe751466ea82665fd21e9162fd7cc9c5f412dJohn McCall                                             llvm::Value *NewPtr,
2081e7fe751466ea82665fd21e9162fd7cc9c5f412dJohn McCall                                             llvm::Value *NumElements,
2096ec278d1a354517e20f13a877481453ee7940c78John McCall                                             const CXXNewExpr *expr,
2101e7fe751466ea82665fd21e9162fd7cc9c5f412dJohn McCall                                             QualType ElementType);
2111e7fe751466ea82665fd21e9162fd7cc9c5f412dJohn McCall
2121e7fe751466ea82665fd21e9162fd7cc9c5f412dJohn McCall  /// Reads the array cookie associated with the given pointer,
2131e7fe751466ea82665fd21e9162fd7cc9c5f412dJohn McCall  /// if it has one.
2141e7fe751466ea82665fd21e9162fd7cc9c5f412dJohn McCall  ///
2151e7fe751466ea82665fd21e9162fd7cc9c5f412dJohn McCall  /// \param Ptr - a pointer to the first element in the array
2161e7fe751466ea82665fd21e9162fd7cc9c5f412dJohn McCall  /// \param ElementType - the base element type of elements of the array
2171e7fe751466ea82665fd21e9162fd7cc9c5f412dJohn McCall  /// \param NumElements - an out parameter which will be initialized
2181e7fe751466ea82665fd21e9162fd7cc9c5f412dJohn McCall  ///   with the number of elements allocated, or zero if there is no
2191e7fe751466ea82665fd21e9162fd7cc9c5f412dJohn McCall  ///   cookie
2201e7fe751466ea82665fd21e9162fd7cc9c5f412dJohn McCall  /// \param AllocPtr - an out parameter which will be initialized
2211e7fe751466ea82665fd21e9162fd7cc9c5f412dJohn McCall  ///   with a char* pointing to the address returned by the allocation
2221e7fe751466ea82665fd21e9162fd7cc9c5f412dJohn McCall  ///   function
2231e7fe751466ea82665fd21e9162fd7cc9c5f412dJohn McCall  /// \param CookieSize - an out parameter which will be initialized
2241e7fe751466ea82665fd21e9162fd7cc9c5f412dJohn McCall  ///   with the size of the cookie, or zero if there is no cookie
2251e7fe751466ea82665fd21e9162fd7cc9c5f412dJohn McCall  virtual void ReadArrayCookie(CodeGenFunction &CGF, llvm::Value *Ptr,
2266ec278d1a354517e20f13a877481453ee7940c78John McCall                               const CXXDeleteExpr *expr,
2271e7fe751466ea82665fd21e9162fd7cc9c5f412dJohn McCall                               QualType ElementType, llvm::Value *&NumElements,
2281e7fe751466ea82665fd21e9162fd7cc9c5f412dJohn McCall                               llvm::Value *&AllocPtr, CharUnits &CookieSize);
2291e7fe751466ea82665fd21e9162fd7cc9c5f412dJohn McCall
2305cd91b513455fd7753e8815b54f0a49bbca6602dJohn McCall  /*************************** Static local guards ****************************/
2315cd91b513455fd7753e8815b54f0a49bbca6602dJohn McCall
2323030eb82593097502469a8b3fc26112c79c75605John McCall  /// Emits the guarded initializer and destructor setup for the given
2333030eb82593097502469a8b3fc26112c79c75605John McCall  /// variable, given that it couldn't be emitted as a constant.
2343030eb82593097502469a8b3fc26112c79c75605John McCall  ///
2353030eb82593097502469a8b3fc26112c79c75605John McCall  /// The variable may be:
2363030eb82593097502469a8b3fc26112c79c75605John McCall  ///   - a static local variable
2373030eb82593097502469a8b3fc26112c79c75605John McCall  ///   - a static data member of a class template instantiation
2383030eb82593097502469a8b3fc26112c79c75605John McCall  virtual void EmitGuardedInit(CodeGenFunction &CGF, const VarDecl &D,
2393030eb82593097502469a8b3fc26112c79c75605John McCall                               llvm::GlobalVariable *DeclPtr);
2405cd91b513455fd7753e8815b54f0a49bbca6602dJohn McCall
2413a811f1f4286ee3fd0c563c1cfe623956f3caa24Charles Davis};
2423a811f1f4286ee3fd0c563c1cfe623956f3caa24Charles Davis
2433a811f1f4286ee3fd0c563c1cfe623956f3caa24Charles Davis/// Creates an instance of a C++ ABI class.
244ee79a4c30e5d1c5285551c9a25b8ec6d45d46aa7John McCallCGCXXABI *CreateARMCXXABI(CodeGenModule &CGM);
245071cc7deffad608165b1ddd5263e8bf181861520Charles DavisCGCXXABI *CreateItaniumCXXABI(CodeGenModule &CGM);
246071cc7deffad608165b1ddd5263e8bf181861520Charles DavisCGCXXABI *CreateMicrosoftCXXABI(CodeGenModule &CGM);
24793d557bc1867b7d7b102f87290194b4be7932c92John McCall
2483a811f1f4286ee3fd0c563c1cfe623956f3caa24Charles Davis}
2493a811f1f4286ee3fd0c563c1cfe623956f3caa24Charles Davis}
2503a811f1f4286ee3fd0c563c1cfe623956f3caa24Charles Davis
2513a811f1f4286ee3fd0c563c1cfe623956f3caa24Charles Davis#endif
252