diff options
author | Chris Lattner <sabre@nondot.org> | 2009-05-12 21:21:08 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2009-05-12 21:21:08 +0000 |
commit | b4880bab7fc1b61267cfd9a0ad52188e7a828cb3 (patch) | |
tree | 81f09c73e7a4d1d6105481b6c253a01fb8738b50 /lib/CodeGen/CodeGenModule.h | |
parent | 0c337ed63ff0f04fd8315afabb2d7a51969fdc97 (diff) |
push GlobalDecl through enough of the CodeGenModule interfaces
to allow us to support generation of deferred ctors/dtors.
It looks like codegen isn't emitting a call to the dtor in
member-functions.cpp:test2, but when it does, its body should
get emitted.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@71594 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/CodeGenModule.h')
-rw-r--r-- | lib/CodeGen/CodeGenModule.h | 78 |
1 files changed, 39 insertions, 39 deletions
diff --git a/lib/CodeGen/CodeGenModule.h b/lib/CodeGen/CodeGenModule.h index 3db311243c..5c780e755b 100644 --- a/lib/CodeGen/CodeGenModule.h +++ b/lib/CodeGen/CodeGenModule.h @@ -65,6 +65,38 @@ namespace CodeGen { class CGDebugInfo; class CGObjCRuntime; +/// GlobalDecl - represents a global declaration. This can either be a +/// CXXConstructorDecl and the constructor type (Base, Complete). +/// a CXXDestructorDecl and the destructor type (Base, Complete) or +// a regular VarDecl or a FunctionDecl. +class GlobalDecl { + llvm::PointerIntPair<const ValueDecl*, 2> Value; + +public: + GlobalDecl() {} + + explicit GlobalDecl(const ValueDecl *VD) : Value(VD, 0) { + assert(!isa<CXXConstructorDecl>(VD) && "Use other ctor with ctor decls!"); + assert(!isa<CXXDestructorDecl>(VD) && "Use other ctor with dtor decls!"); + } + GlobalDecl(const CXXConstructorDecl *D, CXXCtorType Type) + : Value(D, Type) {} + GlobalDecl(const CXXDestructorDecl *D, CXXDtorType Type) + : Value(D, Type) {} + + const ValueDecl *getDecl() const { return Value.getPointer(); } + + CXXCtorType getCtorType() const { + assert(isa<CXXConstructorDecl>(getDecl()) && "Decl is not a ctor!"); + return static_cast<CXXCtorType>(Value.getInt()); + } + + CXXDtorType getDtorType() const { + assert(isa<CXXDestructorDecl>(getDecl()) && "Decl is not a dtor!"); + return static_cast<CXXDtorType>(Value.getInt()); + } +}; + /// CodeGenModule - This class organizes the cross-function state that is used /// while generating LLVM code. class CodeGenModule : public BlockModule { @@ -109,38 +141,6 @@ class CodeGenModule : public BlockModule { /// has one). llvm::StringSet<> MangledNames; - /// GlobalDecl - represents a global declaration. This can either be a - /// CXXConstructorDecl and the constructor type (Base, Complete). - /// a CXXDestructorDecl and the destructor type (Base, Complete) or - // a regular VarDecl or a FunctionDecl. - class GlobalDecl { - llvm::PointerIntPair<const ValueDecl*, 2> Value; - - public: - GlobalDecl() {} - - explicit GlobalDecl(const ValueDecl *VD) : Value(VD, 0) { - assert(!isa<CXXConstructorDecl>(VD) && "Use other ctor with ctor decls!"); - assert(!isa<CXXDestructorDecl>(VD) && "Use other ctor with dtor decls!"); - } - GlobalDecl(const CXXConstructorDecl *D, CXXCtorType Type) - : Value(D, Type) {} - GlobalDecl(const CXXDestructorDecl *D, CXXDtorType Type) - : Value(D, Type) {} - - const ValueDecl *getDecl() const { return Value.getPointer(); } - - CXXCtorType getCtorType() const { - assert(isa<CXXConstructorDecl>(getDecl()) && "Decl is not a ctor!"); - return static_cast<CXXCtorType>(Value.getInt()); - } - - CXXDtorType getDtorType() const { - assert(isa<CXXDestructorDecl>(getDecl()) && "Decl is not a dtor!"); - return static_cast<CXXDtorType>(Value.getInt()); - } - }; - /// DeferredDecls - This contains all the decls which have definitions but /// which are deferred for emission and therefore should only be output if /// they are actually used. If a decl is in this, then it is known to have @@ -220,7 +220,7 @@ public: /// GetAddrOfFunction - Return the address of the given function. If Ty is /// non-null, then this function will use the specified type if it has to /// create it. - llvm::Constant *GetAddrOfFunction(const FunctionDecl *D, + llvm::Constant *GetAddrOfFunction(GlobalDecl GD, const llvm::Type *Ty = 0); /// GetStringForStringLiteral - Return the appropriate bytes for a string @@ -383,7 +383,7 @@ private: llvm::Constant *GetOrCreateLLVMFunction(const char *MangledName, const llvm::Type *Ty, - const FunctionDecl *D); + GlobalDecl D); llvm::Constant *GetOrCreateLLVMGlobal(const char *MangledName, const llvm::PointerType *PTy, const VarDecl *D); @@ -406,11 +406,11 @@ private: /// EmitGlobal - Emit code for a singal global function or var decl. Forward /// declarations are emitted lazily. - void EmitGlobal(const GlobalDecl& D); + void EmitGlobal(GlobalDecl D); - void EmitGlobalDefinition(const GlobalDecl& D); + void EmitGlobalDefinition(GlobalDecl D); - void EmitGlobalFunctionDefinition(const FunctionDecl *D); + void EmitGlobalFunctionDefinition(GlobalDecl GD); void EmitGlobalVarDefinition(const VarDecl *D); void EmitAliasDefinition(const ValueDecl *D); void EmitObjCPropertyImplementations(const ObjCImplementationDecl *D); @@ -437,8 +437,8 @@ private: void EmitCXXDestructor(const CXXDestructorDecl *D, CXXDtorType Type); // FIXME: Hardcoding priority here is gross. - void AddGlobalCtor(llvm::Function * Ctor, int Priority=65535); - void AddGlobalDtor(llvm::Function * Dtor, int Priority=65535); + void AddGlobalCtor(llvm::Function *Ctor, int Priority=65535); + void AddGlobalDtor(llvm::Function *Dtor, int Priority=65535); /// EmitCtorList - Generates a global array of functions and priorities using /// the given list and name. This array will have appending linkage and is |