CGCXXABI.h revision 7ca4850a3e3530fa6c93b64b740446e32c97f992
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;
456f42b62b6194f53bcbc349f5d17388e1936535d7Dylan Noblesmith  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) {
52cec5ebd4a6a89a7023d04cec728fd340b541ed61Eli Friedman    return CGF.CXXABIThisDecl;
534c40d98ab7acf5f27fa89b17bd8fc0ef7683df37John McCall  }
544c40d98ab7acf5f27fa89b17bd8fc0ef7683df37John McCall  llvm::Value *&getThisValue(CodeGenFunction &CGF) {
55cec5ebd4a6a89a7023d04cec728fd340b541ed61Eli Friedman    return CGF.CXXABIThisValue;
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  /// Return true if the given member pointer can be zero-initialized
1100bab0cdab751248ca389a5592bcb70eac5d39260John McCall  /// (in the C++ sense) with an LLVM zeroinitializer.
111f16aa103d3afd42fbca2ab346f191bf745cec092John McCall  virtual bool isZeroInitializable(const MemberPointerType *MPT);
112cf2c85e76fdafe7e634810a292321a6c8322483dJohn McCall
1130bab0cdab751248ca389a5592bcb70eac5d39260John McCall  /// Create a null member pointer of the given type.
1140bab0cdab751248ca389a5592bcb70eac5d39260John McCall  virtual llvm::Constant *EmitNullMemberPointer(const MemberPointerType *MPT);
115cf2c85e76fdafe7e634810a292321a6c8322483dJohn McCall
1160bab0cdab751248ca389a5592bcb70eac5d39260John McCall  /// Create a member pointer for the given method.
117755d8497e39071aa24acc173ff07083e3256b8f8John McCall  virtual llvm::Constant *EmitMemberPointer(const CXXMethodDecl *MD);
118875ab10245d3bf37252dd822aa1616bb0a391095John McCall
1190bab0cdab751248ca389a5592bcb70eac5d39260John McCall  /// Create a member pointer for the given field.
1205808ce43f8d7e71f5acacc9ca320268c4f37565aJohn McCall  virtual llvm::Constant *EmitMemberDataPointer(const MemberPointerType *MPT,
1215808ce43f8d7e71f5acacc9ca320268c4f37565aJohn McCall                                                CharUnits offset);
122e9fd7eb6c67676dc27e84eac429aec4f3be51f26John McCall
1232d6a5670465cb3f1d811695a9f23e372508240d2Richard Smith  /// Create a member pointer for the given member pointer constant.
1242d6a5670465cb3f1d811695a9f23e372508240d2Richard Smith  virtual llvm::Constant *EmitMemberPointer(const APValue &MP, QualType MPT);
1252d6a5670465cb3f1d811695a9f23e372508240d2Richard Smith
1260bab0cdab751248ca389a5592bcb70eac5d39260John McCall  /// Emit a comparison between two member pointers.  Returns an i1.
127e9fd7eb6c67676dc27e84eac429aec4f3be51f26John McCall  virtual llvm::Value *
1280bab0cdab751248ca389a5592bcb70eac5d39260John McCall  EmitMemberPointerComparison(CodeGenFunction &CGF,
1290bab0cdab751248ca389a5592bcb70eac5d39260John McCall                              llvm::Value *L,
1300bab0cdab751248ca389a5592bcb70eac5d39260John McCall                              llvm::Value *R,
1310bab0cdab751248ca389a5592bcb70eac5d39260John McCall                              const MemberPointerType *MPT,
1320bab0cdab751248ca389a5592bcb70eac5d39260John McCall                              bool Inequality);
133e9fd7eb6c67676dc27e84eac429aec4f3be51f26John McCall
1340bab0cdab751248ca389a5592bcb70eac5d39260John McCall  /// Determine if a member pointer is non-null.  Returns an i1.
135e9fd7eb6c67676dc27e84eac429aec4f3be51f26John McCall  virtual llvm::Value *
1360bab0cdab751248ca389a5592bcb70eac5d39260John McCall  EmitMemberPointerIsNotNull(CodeGenFunction &CGF,
1370bab0cdab751248ca389a5592bcb70eac5d39260John McCall                             llvm::Value *MemPtr,
1380bab0cdab751248ca389a5592bcb70eac5d39260John McCall                             const MemberPointerType *MPT);
1394c40d98ab7acf5f27fa89b17bd8fc0ef7683df37John McCall
1404c40d98ab7acf5f27fa89b17bd8fc0ef7683df37John McCall  /// Build the signature of the given constructor variant by adding
1414c40d98ab7acf5f27fa89b17bd8fc0ef7683df37John McCall  /// any required parameters.  For convenience, ResTy has been
1424c40d98ab7acf5f27fa89b17bd8fc0ef7683df37John McCall  /// initialized to 'void', and ArgTys has been initialized with the
1434c40d98ab7acf5f27fa89b17bd8fc0ef7683df37John McCall  /// type of 'this' (although this may be changed by the ABI) and
1444c40d98ab7acf5f27fa89b17bd8fc0ef7683df37John McCall  /// will have the formal parameters added to it afterwards.
1454c40d98ab7acf5f27fa89b17bd8fc0ef7683df37John McCall  ///
1464c40d98ab7acf5f27fa89b17bd8fc0ef7683df37John McCall  /// If there are ever any ABIs where the implicit parameters are
1474c40d98ab7acf5f27fa89b17bd8fc0ef7683df37John McCall  /// intermixed with the formal parameters, we can address those
1484c40d98ab7acf5f27fa89b17bd8fc0ef7683df37John McCall  /// then.
1494c40d98ab7acf5f27fa89b17bd8fc0ef7683df37John McCall  virtual void BuildConstructorSignature(const CXXConstructorDecl *Ctor,
1504c40d98ab7acf5f27fa89b17bd8fc0ef7683df37John McCall                                         CXXCtorType T,
1514c40d98ab7acf5f27fa89b17bd8fc0ef7683df37John McCall                                         CanQualType &ResTy,
152686775deca8b8685eb90801495880e3abdd844c2Chris Lattner                               SmallVectorImpl<CanQualType> &ArgTys) = 0;
1534c40d98ab7acf5f27fa89b17bd8fc0ef7683df37John McCall
1544c40d98ab7acf5f27fa89b17bd8fc0ef7683df37John McCall  /// Build the signature of the given destructor variant by adding
1554c40d98ab7acf5f27fa89b17bd8fc0ef7683df37John McCall  /// any required parameters.  For convenience, ResTy has been
1564c40d98ab7acf5f27fa89b17bd8fc0ef7683df37John McCall  /// initialized to 'void' and ArgTys has been initialized with the
1574c40d98ab7acf5f27fa89b17bd8fc0ef7683df37John McCall  /// type of 'this' (although this may be changed by the ABI).
1584c40d98ab7acf5f27fa89b17bd8fc0ef7683df37John McCall  virtual void BuildDestructorSignature(const CXXDestructorDecl *Dtor,
1594c40d98ab7acf5f27fa89b17bd8fc0ef7683df37John McCall                                        CXXDtorType T,
1604c40d98ab7acf5f27fa89b17bd8fc0ef7683df37John McCall                                        CanQualType &ResTy,
161686775deca8b8685eb90801495880e3abdd844c2Chris Lattner                               SmallVectorImpl<CanQualType> &ArgTys) = 0;
1624c40d98ab7acf5f27fa89b17bd8fc0ef7683df37John McCall
1634c40d98ab7acf5f27fa89b17bd8fc0ef7683df37John McCall  /// Build the ABI-specific portion of the parameter list for a
1644c40d98ab7acf5f27fa89b17bd8fc0ef7683df37John McCall  /// function.  This generally involves a 'this' parameter and
1654c40d98ab7acf5f27fa89b17bd8fc0ef7683df37John McCall  /// possibly some extra data for constructors and destructors.
1664c40d98ab7acf5f27fa89b17bd8fc0ef7683df37John McCall  ///
1674c40d98ab7acf5f27fa89b17bd8fc0ef7683df37John McCall  /// ABIs may also choose to override the return type, which has been
1684c40d98ab7acf5f27fa89b17bd8fc0ef7683df37John McCall  /// initialized with the formal return type of the function.
1694c40d98ab7acf5f27fa89b17bd8fc0ef7683df37John McCall  virtual void BuildInstanceFunctionParams(CodeGenFunction &CGF,
1704c40d98ab7acf5f27fa89b17bd8fc0ef7683df37John McCall                                           QualType &ResTy,
1714c40d98ab7acf5f27fa89b17bd8fc0ef7683df37John McCall                                           FunctionArgList &Params) = 0;
1724c40d98ab7acf5f27fa89b17bd8fc0ef7683df37John McCall
1734c40d98ab7acf5f27fa89b17bd8fc0ef7683df37John McCall  /// Emit the ABI-specific prolog for the function.
1744c40d98ab7acf5f27fa89b17bd8fc0ef7683df37John McCall  virtual void EmitInstanceFunctionProlog(CodeGenFunction &CGF) = 0;
1754c40d98ab7acf5f27fa89b17bd8fc0ef7683df37John McCall
1764c40d98ab7acf5f27fa89b17bd8fc0ef7683df37John McCall  virtual void EmitReturnFromThunk(CodeGenFunction &CGF,
1774c40d98ab7acf5f27fa89b17bd8fc0ef7683df37John McCall                                   RValue RV, QualType ResultType);
1781e7fe751466ea82665fd21e9162fd7cc9c5f412dJohn McCall
1791e7fe751466ea82665fd21e9162fd7cc9c5f412dJohn McCall  /**************************** Array cookies ******************************/
1801e7fe751466ea82665fd21e9162fd7cc9c5f412dJohn McCall
1811e7fe751466ea82665fd21e9162fd7cc9c5f412dJohn McCall  /// Returns the extra size required in order to store the array
1821e7fe751466ea82665fd21e9162fd7cc9c5f412dJohn McCall  /// cookie for the given type.  May return 0 to indicate that no
1831e7fe751466ea82665fd21e9162fd7cc9c5f412dJohn McCall  /// array cookie is required.
1841e7fe751466ea82665fd21e9162fd7cc9c5f412dJohn McCall  ///
1851e7fe751466ea82665fd21e9162fd7cc9c5f412dJohn McCall  /// Several cases are filtered out before this method is called:
1861e7fe751466ea82665fd21e9162fd7cc9c5f412dJohn McCall  ///   - non-array allocations never need a cookie
1871e7fe751466ea82665fd21e9162fd7cc9c5f412dJohn McCall  ///   - calls to ::operator new(size_t, void*) never need a cookie
1881e7fe751466ea82665fd21e9162fd7cc9c5f412dJohn McCall  ///
1891e7fe751466ea82665fd21e9162fd7cc9c5f412dJohn McCall  /// \param ElementType - the allocated type of the expression,
1901e7fe751466ea82665fd21e9162fd7cc9c5f412dJohn McCall  ///   i.e. the pointee type of the expression result type
1916ec278d1a354517e20f13a877481453ee7940c78John McCall  virtual CharUnits GetArrayCookieSize(const CXXNewExpr *expr);
1921e7fe751466ea82665fd21e9162fd7cc9c5f412dJohn McCall
1931e7fe751466ea82665fd21e9162fd7cc9c5f412dJohn McCall  /// Initialize the array cookie for the given allocation.
1941e7fe751466ea82665fd21e9162fd7cc9c5f412dJohn McCall  ///
1951e7fe751466ea82665fd21e9162fd7cc9c5f412dJohn McCall  /// \param NewPtr - a char* which is the presumed-non-null
1961e7fe751466ea82665fd21e9162fd7cc9c5f412dJohn McCall  ///   return value of the allocation function
1971e7fe751466ea82665fd21e9162fd7cc9c5f412dJohn McCall  /// \param NumElements - the computed number of elements,
1981e7fe751466ea82665fd21e9162fd7cc9c5f412dJohn McCall  ///   potentially collapsed from the multidimensional array case
1991e7fe751466ea82665fd21e9162fd7cc9c5f412dJohn McCall  /// \param ElementType - the base element allocated type,
2001e7fe751466ea82665fd21e9162fd7cc9c5f412dJohn McCall  ///   i.e. the allocated type after stripping all array types
2011e7fe751466ea82665fd21e9162fd7cc9c5f412dJohn McCall  virtual llvm::Value *InitializeArrayCookie(CodeGenFunction &CGF,
2021e7fe751466ea82665fd21e9162fd7cc9c5f412dJohn McCall                                             llvm::Value *NewPtr,
2031e7fe751466ea82665fd21e9162fd7cc9c5f412dJohn McCall                                             llvm::Value *NumElements,
2046ec278d1a354517e20f13a877481453ee7940c78John McCall                                             const CXXNewExpr *expr,
2051e7fe751466ea82665fd21e9162fd7cc9c5f412dJohn McCall                                             QualType ElementType);
2061e7fe751466ea82665fd21e9162fd7cc9c5f412dJohn McCall
2071e7fe751466ea82665fd21e9162fd7cc9c5f412dJohn McCall  /// Reads the array cookie associated with the given pointer,
2081e7fe751466ea82665fd21e9162fd7cc9c5f412dJohn McCall  /// if it has one.
2091e7fe751466ea82665fd21e9162fd7cc9c5f412dJohn McCall  ///
2101e7fe751466ea82665fd21e9162fd7cc9c5f412dJohn McCall  /// \param Ptr - a pointer to the first element in the array
2111e7fe751466ea82665fd21e9162fd7cc9c5f412dJohn McCall  /// \param ElementType - the base element type of elements of the array
2121e7fe751466ea82665fd21e9162fd7cc9c5f412dJohn McCall  /// \param NumElements - an out parameter which will be initialized
2131e7fe751466ea82665fd21e9162fd7cc9c5f412dJohn McCall  ///   with the number of elements allocated, or zero if there is no
2141e7fe751466ea82665fd21e9162fd7cc9c5f412dJohn McCall  ///   cookie
2151e7fe751466ea82665fd21e9162fd7cc9c5f412dJohn McCall  /// \param AllocPtr - an out parameter which will be initialized
2161e7fe751466ea82665fd21e9162fd7cc9c5f412dJohn McCall  ///   with a char* pointing to the address returned by the allocation
2171e7fe751466ea82665fd21e9162fd7cc9c5f412dJohn McCall  ///   function
2181e7fe751466ea82665fd21e9162fd7cc9c5f412dJohn McCall  /// \param CookieSize - an out parameter which will be initialized
2191e7fe751466ea82665fd21e9162fd7cc9c5f412dJohn McCall  ///   with the size of the cookie, or zero if there is no cookie
2201e7fe751466ea82665fd21e9162fd7cc9c5f412dJohn McCall  virtual void ReadArrayCookie(CodeGenFunction &CGF, llvm::Value *Ptr,
2216ec278d1a354517e20f13a877481453ee7940c78John McCall                               const CXXDeleteExpr *expr,
2221e7fe751466ea82665fd21e9162fd7cc9c5f412dJohn McCall                               QualType ElementType, llvm::Value *&NumElements,
2231e7fe751466ea82665fd21e9162fd7cc9c5f412dJohn McCall                               llvm::Value *&AllocPtr, CharUnits &CookieSize);
2241e7fe751466ea82665fd21e9162fd7cc9c5f412dJohn McCall
2255cd91b513455fd7753e8815b54f0a49bbca6602dJohn McCall  /*************************** Static local guards ****************************/
2265cd91b513455fd7753e8815b54f0a49bbca6602dJohn McCall
2273030eb82593097502469a8b3fc26112c79c75605John McCall  /// Emits the guarded initializer and destructor setup for the given
2283030eb82593097502469a8b3fc26112c79c75605John McCall  /// variable, given that it couldn't be emitted as a constant.
2297ca4850a3e3530fa6c93b64b740446e32c97f992Richard Smith  /// If \p PerformInit is false, the initialization has been folded to a
2307ca4850a3e3530fa6c93b64b740446e32c97f992Richard Smith  /// constant and should not be performed.
2313030eb82593097502469a8b3fc26112c79c75605John McCall  ///
2323030eb82593097502469a8b3fc26112c79c75605John McCall  /// The variable may be:
2333030eb82593097502469a8b3fc26112c79c75605John McCall  ///   - a static local variable
2343030eb82593097502469a8b3fc26112c79c75605John McCall  ///   - a static data member of a class template instantiation
2353030eb82593097502469a8b3fc26112c79c75605John McCall  virtual void EmitGuardedInit(CodeGenFunction &CGF, const VarDecl &D,
2367ca4850a3e3530fa6c93b64b740446e32c97f992Richard Smith                               llvm::GlobalVariable *DeclPtr, bool PerformInit);
2375cd91b513455fd7753e8815b54f0a49bbca6602dJohn McCall
2383a811f1f4286ee3fd0c563c1cfe623956f3caa24Charles Davis};
2393a811f1f4286ee3fd0c563c1cfe623956f3caa24Charles Davis
2403a811f1f4286ee3fd0c563c1cfe623956f3caa24Charles Davis/// Creates an instance of a C++ ABI class.
241ee79a4c30e5d1c5285551c9a25b8ec6d45d46aa7John McCallCGCXXABI *CreateARMCXXABI(CodeGenModule &CGM);
242071cc7deffad608165b1ddd5263e8bf181861520Charles DavisCGCXXABI *CreateItaniumCXXABI(CodeGenModule &CGM);
243071cc7deffad608165b1ddd5263e8bf181861520Charles DavisCGCXXABI *CreateMicrosoftCXXABI(CodeGenModule &CGM);
24493d557bc1867b7d7b102f87290194b4be7932c92John McCall
2453a811f1f4286ee3fd0c563c1cfe623956f3caa24Charles Davis}
2463a811f1f4286ee3fd0c563c1cfe623956f3caa24Charles Davis}
2473a811f1f4286ee3fd0c563c1cfe623956f3caa24Charles Davis
2483a811f1f4286ee3fd0c563c1cfe623956f3caa24Charles Davis#endif
249