[cfe-commits] r132973 - in /cfe/trunk: include/clang/AST/GlobalDecl.h lib/CodeGen/CGDebugInfo.h lib/CodeGen/CGVTables.h lib/CodeGen/CodeGenModule.h lib/CodeGen/CodeGenTypes.h lib/CodeGen/GlobalDecl.h

Peter Collingbourne peter at pcc.me.uk
Mon Jun 13 21:02:40 PDT 2011


Author: pcc
Date: Mon Jun 13 23:02:39 2011
New Revision: 132973

URL: http://llvm.org/viewvc/llvm-project?rev=132973&view=rev
Log:
Move GlobalDecl to AST

Added:
    cfe/trunk/include/clang/AST/GlobalDecl.h
      - copied, changed from r132958, cfe/trunk/lib/CodeGen/GlobalDecl.h
Removed:
    cfe/trunk/lib/CodeGen/GlobalDecl.h
Modified:
    cfe/trunk/lib/CodeGen/CGDebugInfo.h
    cfe/trunk/lib/CodeGen/CGVTables.h
    cfe/trunk/lib/CodeGen/CodeGenModule.h
    cfe/trunk/lib/CodeGen/CodeGenTypes.h

Copied: cfe/trunk/include/clang/AST/GlobalDecl.h (from r132958, cfe/trunk/lib/CodeGen/GlobalDecl.h)
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/GlobalDecl.h?p2=cfe/trunk/include/clang/AST/GlobalDecl.h&p1=cfe/trunk/lib/CodeGen/GlobalDecl.h&r1=132958&r2=132973&rev=132973&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/GlobalDecl.h (original)
+++ cfe/trunk/include/clang/AST/GlobalDecl.h Mon Jun 13 23:02:39 2011
@@ -12,8 +12,8 @@
 //
 //===----------------------------------------------------------------------===//
 
-#ifndef CLANG_CODEGEN_GLOBALDECL_H
-#define CLANG_CODEGEN_GLOBALDECL_H
+#ifndef LLVM_CLANG_AST_GLOBALDECL_H
+#define LLVM_CLANG_AST_GLOBALDECL_H
 
 #include "clang/AST/DeclCXX.h"
 #include "clang/AST/DeclObjC.h"
@@ -21,8 +21,6 @@
 
 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
@@ -89,28 +87,27 @@
   }
 };
 
-} // 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();
+  template<> struct DenseMapInfo<clang::GlobalDecl> {
+    static inline clang::GlobalDecl getEmptyKey() {
+      return clang::GlobalDecl();
     }
   
-    static inline clang::CodeGen::GlobalDecl getTombstoneKey() {
-      return clang::CodeGen::GlobalDecl::
+    static inline clang::GlobalDecl getTombstoneKey() {
+      return clang::GlobalDecl::
         getFromOpaquePtr(reinterpret_cast<void*>(-1));
     }
 
-    static unsigned getHashValue(clang::CodeGen::GlobalDecl GD) {
+    static unsigned getHashValue(clang::GlobalDecl GD) {
       return DenseMapInfo<void*>::getHashValue(GD.getAsOpaquePtr());
     }
     
-    static bool isEqual(clang::CodeGen::GlobalDecl LHS, 
-                        clang::CodeGen::GlobalDecl RHS) {
+    static bool isEqual(clang::GlobalDecl LHS, 
+                        clang::GlobalDecl RHS) {
       return LHS == RHS;
     }
       
@@ -119,7 +116,7 @@
   // 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> {
+  struct isPodLike<clang::GlobalDecl> {
     static const bool value = true;
   };
 } // end namespace llvm

Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.h?rev=132973&r1=132972&r2=132973&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGDebugInfo.h (original)
+++ cfe/trunk/lib/CodeGen/CGDebugInfo.h Mon Jun 13 23:02:39 2011
@@ -33,11 +33,11 @@
   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

Modified: cfe/trunk/lib/CodeGen/CGVTables.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGVTables.h?rev=132973&r1=132972&r2=132973&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGVTables.h (original)
+++ cfe/trunk/lib/CodeGen/CGVTables.h Mon Jun 13 23:02:39 2011
@@ -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;

Modified: cfe/trunk/lib/CodeGen/CodeGenModule.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenModule.h?rev=132973&r1=132972&r2=132973&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CodeGenModule.h (original)
+++ cfe/trunk/lib/CodeGen/CodeGenModule.h Mon Jun 13 23:02:39 2011
@@ -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"

Modified: cfe/trunk/lib/CodeGen/CodeGenTypes.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenTypes.h?rev=132973&r1=132972&r2=132973&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CodeGenTypes.h (original)
+++ cfe/trunk/lib/CodeGen/CodeGenTypes.h Mon Jun 13 23:02:39 2011
@@ -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>

Removed: cfe/trunk/lib/CodeGen/GlobalDecl.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/GlobalDecl.h?rev=132972&view=auto
==============================================================================
--- cfe/trunk/lib/CodeGen/GlobalDecl.h (original)
+++ cfe/trunk/lib/CodeGen/GlobalDecl.h (removed)
@@ -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





More information about the cfe-commits mailing list