Patchwork [gccgo] More header file and unordered_set cleanup

login
register
mail settings
Submitter Ian Taylor
Date Nov. 17, 2010, 10:30 p.m.
Message ID <mcripzvy44z.fsf@google.com>
Download mbox | patch
Permalink /patch/71626/
State New
Headers show

Comments

Ian Taylor - Nov. 17, 2010, 10:30 p.m.
This patch removes a more unnecessary #include <> header files from the
Go frontend.  It adds #include of <map> and <set> to go-system.h.  It
fixes the use of Unordered_set to actually work.  Committed to gccgo
branch.

Ian

Patch

diff -r 9322c4f59566 go/dataflow.h
--- a/go/dataflow.h	Wed Nov 17 14:11:36 2010 -0800
+++ b/go/dataflow.h	Wed Nov 17 14:27:41 2010 -0800
@@ -7,8 +7,6 @@ 
 #ifndef GO_DATAFLOW_H
 #define GO_DATAFLOW_H
 
-#include <map>
-
 class Expression;
 class Named_object;
 class Statement;
diff -r 9322c4f59566 go/export.h
--- a/go/export.h	Wed Nov 17 14:11:36 2010 -0800
+++ b/go/export.h	Wed Nov 17 14:27:41 2010 -0800
@@ -4,8 +4,6 @@ 
 // Use of this source code is governed by a BSD-style
 // license that can be found in the LICENSE file.
 
-#include <set>
-
 #ifndef GO_EXPORT_H
 #define GO_EXPORT_H
 
diff -r 9322c4f59566 go/go-dump.cc
--- a/go/go-dump.cc	Wed Nov 17 14:11:36 2010 -0800
+++ b/go/go-dump.cc	Wed Nov 17 14:27:41 2010 -0800
@@ -6,8 +6,6 @@ 
 
 #include "go-system.h"
 
-#include <cstring>
-
 #include "go-c.h"
 #include "go-dump.h"
 
diff -r 9322c4f59566 go/gogo-tree.cc
--- a/go/gogo-tree.cc	Wed Nov 17 14:11:36 2010 -0800
+++ b/go/gogo-tree.cc	Wed Nov 17 14:27:41 2010 -0800
@@ -416,7 +416,7 @@ 
   // A hash table we use to avoid looping.  The index is the name of a
   // named object.  We only look through objects defined in this
   // package.
-  typedef std::tr1::unordered_set<std::string> Seen_objects;
+  typedef Unordered_set(std::string) Seen_objects;
 
   Find_var(Named_object* var, Seen_objects* seen_objects)
     : Traverse(traverse_expressions),
diff -r 9322c4f59566 go/gogo.h
--- a/go/gogo.h	Wed Nov 17 14:11:36 2010 -0800
+++ b/go/gogo.h	Wed Nov 17 14:27:41 2010 -0800
@@ -4,10 +4,6 @@ 
 // Use of this source code is governed by a BSD-style
 // license that can be found in the LICENSE file.
 
-#include <map>
-#include <set>
-#include <tr1/unordered_set>
-
 #ifndef GO_GOGO_H
 #define GO_GOGO_H
 
@@ -2373,10 +2369,10 @@ 
   type(Type*);
 
  private:
-  typedef std::tr1::unordered_set<const Type*, Type_hash_identical,
-				  Type_identical> Types_seen;
-
-  typedef std::tr1::unordered_set<const Expression*> Expressions_seen;
+  typedef Unordered_set_hash(const Type*, Type_hash_identical,
+			     Type_identical) Types_seen;
+
+  typedef Unordered_set(const Expression*) Expressions_seen;
 
   // Bitmask of what sort of objects to traverse.
   unsigned int traverse_mask_;
diff -r 9322c4f59566 go/import-archive.cc
--- a/go/import-archive.cc	Wed Nov 17 14:11:36 2010 -0800
+++ b/go/import-archive.cc	Wed Nov 17 14:27:41 2010 -0800
@@ -6,13 +6,6 @@ 
 
 #include "go-system.h"
 
-#include <cerrno>
-#include <cstring>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <list>
-#include <map>
-
 #include "import.h"
 
 // Archive magic numbers.
diff -r 9322c4f59566 go/import.cc
--- a/go/import.cc	Wed Nov 17 14:11:36 2010 -0800
+++ b/go/import.cc	Wed Nov 17 14:27:41 2010 -0800
@@ -6,10 +6,6 @@ 
 
 #include "go-system.h"
 
-#include <cerrno>
-#include <cstring>
-#include <unistd.h>
-
 #include "filenames.h"
 #include "simple-object.h"
 
diff -r 9322c4f59566 go/import.h
--- a/go/import.h	Wed Nov 17 14:11:36 2010 -0800
+++ b/go/import.h	Wed Nov 17 14:27:41 2010 -0800
@@ -7,8 +7,6 @@ 
 #ifndef GO_IMPORT_H
 #define GO_IMPORT_H
 
-#include <sys/types.h>
-
 #include "export.h"
 
 class Gogo;
diff -r 9322c4f59566 go/parse.h
--- a/go/parse.h	Wed Nov 17 14:11:36 2010 -0800
+++ b/go/parse.h	Wed Nov 17 14:27:41 2010 -0800
@@ -7,8 +7,6 @@ 
 #ifndef GO_PARSE_H
 #define GO_PARSE_H
 
-#include <set>
-
 class Set_iota_traverse;
 class Lex;
 class Gogo;
diff -r 9322c4f59566 go/statements.cc
--- a/go/statements.cc	Wed Nov 17 14:11:36 2010 -0800
+++ b/go/statements.cc	Wed Nov 17 14:27:41 2010 -0800
@@ -3714,8 +3714,8 @@ 
 void
 Type_case_clauses::check_duplicates() const
 {
-  typedef std::tr1::unordered_set<const Type*, Type_hash_identical,
-				  Type_identical> Types_seen;
+  typedef Unordered_set_hash(const Type*, Type_hash_identical,
+			     Type_identical) Types_seen;
   Types_seen types_seen;
   for (Type_clauses::const_iterator p = this->clauses_.begin();
        p != this->clauses_.end();
diff -r 9322c4f59566 go/statements.h
--- a/go/statements.h	Wed Nov 17 14:11:36 2010 -0800
+++ b/go/statements.h	Wed Nov 17 14:27:41 2010 -0800
@@ -7,8 +7,6 @@ 
 #ifndef GO_STATEMENTS_H
 #define GO_STATEMENTS_H
 
-#include <tr1/unordered_set>
-
 #include "operator.h"
 
 class Gogo;
@@ -1139,7 +1137,7 @@ 
  private:
   // For a constant tree we need to keep a record of constants we have
   // already seen.  Note that INTEGER_CST trees are interned.
-  typedef std::tr1::unordered_set<tree> Case_constants;
+  typedef Unordered_set(tree) Case_constants;
 
   // One case clause.
   class Case_clause
diff -r 9322c4f59566 go/types.h
--- a/go/types.h	Wed Nov 17 14:11:36 2010 -0800
+++ b/go/types.h	Wed Nov 17 14:27:41 2010 -0800
@@ -7,9 +7,6 @@ 
 #ifndef GO_TYPES_H
 #define GO_TYPES_H
 
-#include <map>
-#include <tr1/unordered_set>
-
 class Gogo;
 class Package;
 class Traverse;
@@ -1024,8 +1021,8 @@ 
   build_receive_return_type(tree type);
 
   // A hash table we use to avoid infinite recursion.
-  typedef std::tr1::unordered_set<const Named_type*, Type_hash_identical,
-				  Type_identical> Types_seen;
+  typedef Unordered_set_hash(const Named_type*, Type_hash_identical,
+			     Type_identical) Types_seen;
 
   // Add all methods for TYPE to the list of methods for THIS.
   static void
Index: go-system.h
===================================================================
--- go-system.h	(revision 166883)
+++ go-system.h	(working copy)
@@ -27,6 +27,8 @@ 
 #include <algorithm>
 #include <string>
 #include <list>
+#include <map>
+#include <set>
 #include <vector>
 
 #if defined(HAVE_UNORDERED_MAP)
@@ -40,11 +42,11 @@ 
 # define Unordered_map_hash(KEYTYPE, VALTYPE, HASHFN, EQFN) \
 	std::unordered_map<KEYTYPE, VALTYPE, HASHFN, EQFN>
 
-# define Unordered_set(KEYTYPE, VALTYPE) \
-	std::unordered_set<KEYTYPE, VALTYPE>
+# define Unordered_set(KEYTYPE) \
+	std::unordered_set<KEYTYPE>
 
-# define Unordered_set_hash(KEYTYPE, VALTYPE, HASHFN, EQFN) \
-	std::unordered_set<KEYTYPE, VALTYPE, HASHFN, EQFN>
+# define Unordered_set_hash(KEYTYPE, HASHFN, EQFN) \
+	std::unordered_set<KEYTYPE, HASHFN, EQFN>
 
 #elif defined(HAVE_TR1_UNORDERED_MAP)
 
@@ -57,11 +59,11 @@ 
 # define Unordered_map_hash(KEYTYPE, VALTYPE, HASHFN, EQFN) \
 	std::tr1::unordered_map<KEYTYPE, VALTYPE, HASHFN, EQFN>
 
-# define Unordered_set(KEYTYPE, VALTYPE) \
-	std::tr1::unordered_set<KEYTYPE, VALTYPE>
+# define Unordered_set(KEYTYPE) \
+	std::tr1::unordered_set<KEYTYPE>
 
-# define Unordered_set_hash(KEYTYPE, VALTYPE, HASHFN, EQFN) \
-	std::tr1::unordered_set<KEYTYPE, VALTYPE, HASHFN, EQFN>
+# define Unordered_set_hash(KEYTYPE, HASHFN, EQFN) \
+	std::tr1::unordered_set<KEYTYPE, HASHFN, EQFN>
 
 #elif defined(HAVE_EXT_HASH_MAP)
 
@@ -74,11 +76,11 @@ 
 # define Unordered_map_hash(KEYTYPE, VALTYPE, HASHFN, EQFN) \
 	__gnu_cxx::hash_map<KEYTYPE, VALTYPE, HASHFN, EQFN>
 
-# define Unordered_set(KEYTYPE, VALTYPE) \
-	__gnu_cxx::hash_set<KEYTYPE, VALTYPE>
+# define Unordered_set(KEYTYPE) \
+	__gnu_cxx::hash_set<KEYTYPE>
 
-# define Unordered_set_hash(KEYTYPE, VALTYPE, HASHFN, EQFN) \
-	__gnu_cxx::hash_set<KEYTYPE, VALTYPE, HASHFN, EQFN>
+# define Unordered_set_hash(KEYTYPE, HASHFN, EQFN) \
+	__gnu_cxx::hash_set<KEYTYPE, HASHFN, EQFN>
 
 // Provide hash functions for strings and pointers.
 
@@ -105,14 +107,11 @@  struct hash<T*>
 
 #else
 
-# include <map>
-# include <set>
-
 # define Unordered_map(KEYTYPE, VALTYPE) \
 	std::map<KEYTYPE, VALTYPE>
 
-# define Unordered_set(KEYTYPE, VALTYPE) \
-	std::set<KEYTYPE, VALTYPE>
+# define Unordered_set(KEYTYPE) \
+	std::set<KEYTYPE>
 
 // We could make this work by writing an adapter class which
 // implemented operator< in terms of the hash function.