diff options
author | Peter Collingbourne <peter@pcc.me.uk> | 2011-06-14 04:02:39 +0000 |
---|---|---|
committer | Peter Collingbourne <peter@pcc.me.uk> | 2011-06-14 04:02:39 +0000 |
commit | fd05ca03abdfb38f78b9535d996ecc9c39d3b0db (patch) | |
tree | c6756338ea52c91ce62ffaaa4ea3cc67fb37b722 /lib/CodeGen | |
parent | 467f7c8ba2b3c3b65065d05323696ded5d8a93a9 (diff) |
Move GlobalDecl to AST
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@132973 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen')
-rw-r--r-- | lib/CodeGen/CGDebugInfo.h | 2 | ||||
-rw-r--r-- | lib/CodeGen/CGVTables.h | 2 | ||||
-rw-r--r-- | lib/CodeGen/CodeGenModule.h | 2 | ||||
-rw-r--r-- | lib/CodeGen/CodeGenTypes.h | 2 | ||||
-rw-r--r-- | lib/CodeGen/GlobalDecl.h | 127 |
5 files changed, 4 insertions, 131 deletions
diff --git a/lib/CodeGen/CGDebugInfo.h b/lib/CodeGen/CGDebugInfo.h index 6ec6b65f5e..eb1b22d902 100644 --- a/lib/CodeGen/CGDebugInfo.h +++ b/lib/CodeGen/CGDebugInfo.h @@ -33,11 +33,11 @@ namespace clang { class VarDecl; class ObjCInterfaceDecl; class ClassTemplateSpecializationDecl; + class GlobalDecl; namespace CodeGen { class CodeGenModule; class CodeGenFunction; - class GlobalDecl; class CGBlockInfo; /// CGDebugInfo - This class gathers all debug information during compilation diff --git a/lib/CodeGen/CGVTables.h b/lib/CodeGen/CGVTables.h index e830e9a6fb..eff6e56c1f 100644 --- a/lib/CodeGen/CGVTables.h +++ b/lib/CodeGen/CGVTables.h @@ -18,7 +18,7 @@ #include "llvm/GlobalVariable.h" #include "clang/Basic/ABI.h" #include "clang/AST/CharUnits.h" -#include "GlobalDecl.h" +#include "clang/AST/GlobalDecl.h" namespace clang { class CXXRecordDecl; diff --git a/lib/CodeGen/CodeGenModule.h b/lib/CodeGen/CodeGenModule.h index 779a3523b7..09741dfada 100644 --- a/lib/CodeGen/CodeGenModule.h +++ b/lib/CodeGen/CodeGenModule.h @@ -19,10 +19,10 @@ #include "clang/AST/Attr.h" #include "clang/AST/DeclCXX.h" #include "clang/AST/DeclObjC.h" +#include "clang/AST/GlobalDecl.h" #include "clang/AST/Mangle.h" #include "CGVTables.h" #include "CodeGenTypes.h" -#include "GlobalDecl.h" #include "llvm/Module.h" #include "llvm/ADT/DenseMap.h" #include "llvm/ADT/StringMap.h" diff --git a/lib/CodeGen/CodeGenTypes.h b/lib/CodeGen/CodeGenTypes.h index ff1eb4c45b..b4a9aea21f 100644 --- a/lib/CodeGen/CodeGenTypes.h +++ b/lib/CodeGen/CodeGenTypes.h @@ -15,7 +15,7 @@ #define CLANG_CODEGEN_CODEGENTYPES_H #include "CGCall.h" -#include "GlobalDecl.h" +#include "clang/AST/GlobalDecl.h" #include "llvm/Module.h" #include "llvm/ADT/DenseMap.h" #include <vector> diff --git a/lib/CodeGen/GlobalDecl.h b/lib/CodeGen/GlobalDecl.h deleted file mode 100644 index c2f36d210b..0000000000 --- a/lib/CodeGen/GlobalDecl.h +++ /dev/null @@ -1,127 +0,0 @@ -//===--- GlobalDecl.h - Global declaration holder ---------------*- C++ -*-===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// -// -// A GlobalDecl can hold either a regular variable/function or a C++ ctor/dtor -// together with its type. -// -//===----------------------------------------------------------------------===// - -#ifndef CLANG_CODEGEN_GLOBALDECL_H -#define CLANG_CODEGEN_GLOBALDECL_H - -#include "clang/AST/DeclCXX.h" -#include "clang/AST/DeclObjC.h" -#include "clang/Basic/ABI.h" - -namespace clang { - -namespace CodeGen { - -/// 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 VarDecl, a FunctionDecl or a BlockDecl. -class GlobalDecl { - llvm::PointerIntPair<const Decl*, 2> Value; - - void Init(const Decl *D) { - assert(!isa<CXXConstructorDecl>(D) && "Use other ctor with ctor decls!"); - assert(!isa<CXXDestructorDecl>(D) && "Use other ctor with dtor decls!"); - - Value.setPointer(D); - } - -public: - GlobalDecl() {} - - GlobalDecl(const VarDecl *D) { Init(D);} - GlobalDecl(const FunctionDecl *D) { Init(D); } - GlobalDecl(const BlockDecl *D) { Init(D); } - GlobalDecl(const ObjCMethodDecl *D) { Init(D); } - - GlobalDecl(const CXXConstructorDecl *D, CXXCtorType Type) - : Value(D, Type) {} - GlobalDecl(const CXXDestructorDecl *D, CXXDtorType Type) - : Value(D, Type) {} - - GlobalDecl getCanonicalDecl() const { - GlobalDecl CanonGD; - CanonGD.Value.setPointer(Value.getPointer()->getCanonicalDecl()); - CanonGD.Value.setInt(Value.getInt()); - - return CanonGD; - } - - const Decl *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()); - } - - friend bool operator==(const GlobalDecl &LHS, const GlobalDecl &RHS) { - return LHS.Value == RHS.Value; - } - - void *getAsOpaquePtr() const { return Value.getOpaqueValue(); } - - static GlobalDecl getFromOpaquePtr(void *P) { - GlobalDecl GD; - GD.Value.setFromOpaqueValue(P); - return GD; - } - - GlobalDecl getWithDecl(const Decl *D) { - GlobalDecl Result(*this); - Result.Value.setPointer(D); - return Result; - } -}; - -} // end namespace CodeGen -} // end namespace clang - -namespace llvm { - template<class> struct DenseMapInfo; - - template<> struct DenseMapInfo<clang::CodeGen::GlobalDecl> { - static inline clang::CodeGen::GlobalDecl getEmptyKey() { - return clang::CodeGen::GlobalDecl(); - } - - static inline clang::CodeGen::GlobalDecl getTombstoneKey() { - return clang::CodeGen::GlobalDecl:: - getFromOpaquePtr(reinterpret_cast<void*>(-1)); - } - - static unsigned getHashValue(clang::CodeGen::GlobalDecl GD) { - return DenseMapInfo<void*>::getHashValue(GD.getAsOpaquePtr()); - } - - static bool isEqual(clang::CodeGen::GlobalDecl LHS, - clang::CodeGen::GlobalDecl RHS) { - return LHS == RHS; - } - - }; - - // GlobalDecl isn't *technically* a POD type. However, its copy constructor, - // copy assignment operator, and destructor are all trivial. - template <> - struct isPodLike<clang::CodeGen::GlobalDecl> { - static const bool value = true; - }; -} // end namespace llvm - -#endif |