On Mon, Jun 13, 2011 at 03:19:11PM -0700, Anders Carlsson wrote:
> 
> On Jun 13, 2011, at 12:41 PM, Peter Collingbourne wrote:
> 
> > Hi,
> > 
> > This patch refactors the vtable and VTT builders to provide a
> > backend-neutral interface to the builders in the AST library, which
> > CodeGen uses to build vtables and VTTs in LLVM.  No functionality
> > change intended.
> 
> While I'm not crazy about this idea, other people (Doug) are in favor of it, 
> so I'm reluctantly fine with it :)
> 
> That being said, I don't think this patch should be committed in its current 
> state. This should be done in incremental steps,
> there's no reason to move both the VTT builder and VTable builder in a single 
> commit.

OK, then.  Following your and Eli's suggestions I will try to
break this patch up into the following steps:

1) Move GlobalDecl to AST
2) Make VTTBuilder independent of CodeGen (broken into sub-steps)
3) Move VTTBuilder to AST
4) Make VTableBuilder independent of CodeGen (broken into sub-steps)
5) Move VTableBuilder to AST

As a start, I am attaching a (simple) patch for 1.  OK to commit?

> Also, the files should be svn cp'ed to preserve history; being able to easily 
> go back and see the rationale behind changes is
> crucial to fixing bugs/regressions in this code.

Hmm, I'll see if I can figure out how to persuade git-svn to do that.

Thanks,
-- 
Peter
>From 93511e483996fe046c40b270adef71a672ce24e1 Mon Sep 17 00:00:00 2001
From: Peter Collingbourne <[email protected]>
Date: Sun, 29 May 2011 01:04:18 +0100
Subject: [PATCH] Move GlobalDecl to AST

---
 {lib/CodeGen => include/clang/AST}/GlobalDecl.h |   25 ++++++++++------------
 lib/CodeGen/CGDebugInfo.h                       |    2 +-
 lib/CodeGen/CGVTables.h                         |    2 +-
 lib/CodeGen/CodeGenModule.h                     |    2 +-
 lib/CodeGen/CodeGenTypes.h                      |    2 +-
 5 files changed, 15 insertions(+), 18 deletions(-)
 rename {lib/CodeGen => include/clang/AST}/GlobalDecl.h (83%)

diff --git a/lib/CodeGen/GlobalDecl.h b/include/clang/AST/GlobalDecl.h
similarity index 83%
rename from lib/CodeGen/GlobalDecl.h
rename to include/clang/AST/GlobalDecl.h
index c2f36d2..c43e44c 100644
--- a/lib/CodeGen/GlobalDecl.h
+++ b/include/clang/AST/GlobalDecl.h
@@ -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 @@ public:
   }
 };
 
-} // 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 @@ namespace llvm {
   // 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
diff --git a/lib/CodeGen/CGDebugInfo.h b/lib/CodeGen/CGDebugInfo.h
index 6ec6b65..eb1b22d 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 e830e9a..eff6e56 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 779a352..09741df 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 ff1eb4c..b4a9aea 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>
-- 
1.7.5.3

_______________________________________________
cfe-commits mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits

Reply via email to