Changes to build successfully with GCC 3.02


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@1503 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/include/Support/Annotation.h b/include/Support/Annotation.h
index 9919732..c0642e1 100644
--- a/include/Support/Annotation.h
+++ b/include/Support/Annotation.h
@@ -166,12 +166,13 @@
   //===--------------------------------------------------------------------===//
   // Basic ID <-> Name map functionality
 
-  static AnnotationID  getID  (const string &Name);  // Name -> ID
-  static const string &getName(AnnotationID ID);     // ID -> Name
+  static AnnotationID         getID(const std::string &Name);  // Name -> ID
+  static const std::string &getName(AnnotationID ID);          // ID -> Name
 
   // getID - Name -> ID + registration of a factory function for demand driven
   // annotation support.
-  static AnnotationID  getID  (const string &Name, Factory Fact, void *Data=0);
+  static AnnotationID getID(const std::string &Name, Factory Fact,
+                            void *Data = 0);
 
   //===--------------------------------------------------------------------===//
   // Annotation creation on demand support...
diff --git a/include/Support/CommandLine.h b/include/Support/CommandLine.h
index 84a3bc9..3c0ac1a 100644
--- a/include/Support/CommandLine.h
+++ b/include/Support/CommandLine.h
@@ -100,7 +100,7 @@
   // an argument.  Should return true if there was an error processing the
   // argument and the program should exit.
   //
-  virtual bool handleOccurance(const char *ArgName, const string &Arg) = 0;
+  virtual bool handleOccurance(const char *ArgName, const std::string &Arg) = 0;
 
   virtual enum NumOccurances getNumOccurancesFlagDefault() const { 
     return Optional;
@@ -146,10 +146,10 @@
 
   // addOccurance - Wrapper around handleOccurance that enforces Flags
   //
-  bool addOccurance(const char *ArgName, const string &Value);
+  bool addOccurance(const char *ArgName, const std::string &Value);
 
   // Prints option name followed by message.  Always returns true.
-  bool error(string Message, const char *ArgName = 0);
+  bool error(std::string Message, const char *ArgName = 0);
 
 public:
   inline int getNumOccurances() const { return NumOccurances; }
@@ -162,7 +162,7 @@
 //
 class Alias : public Option {
   Option &AliasFor;
-  virtual bool handleOccurance(const char *ArgName, const string &Arg) {
+  virtual bool handleOccurance(const char *ArgName, const std::string &Arg) {
     return AliasFor.handleOccurance(AliasFor.ArgStr, Arg);
   }
   virtual enum OptionHidden getOptionHiddenFlagDefault() const {return Hidden;}
@@ -177,7 +177,7 @@
 //
 class Flag : public Option {
   bool Value;
-  virtual bool handleOccurance(const char *ArgName, const string &Arg);
+  virtual bool handleOccurance(const char *ArgName, const std::string &Arg);
 public:
   inline Flag(const char *ArgStr, const char *Message, int Flags = 0, 
 	      bool DefaultVal = 0) : Option(ArgStr, Message, Flags), 
@@ -193,7 +193,7 @@
 //
 class Int : public Option {
   int Value;
-  virtual bool handleOccurance(const char *ArgName, const string &Arg);
+  virtual bool handleOccurance(const char *ArgName, const std::string &Arg);
   virtual enum ValueExpected getValueExpectedFlagDefault() const {
     return ValueRequired; 
   }
@@ -209,18 +209,18 @@
 //===----------------------------------------------------------------------===//
 // String valued command line option
 //
-class String : public Option, public string {
-  virtual bool handleOccurance(const char *ArgName, const string &Arg);
+class String : public Option, public std::string {
+  virtual bool handleOccurance(const char *ArgName, const std::string &Arg);
   virtual enum ValueExpected getValueExpectedFlagDefault() const {
     return ValueRequired; 
   }
 public:
   inline String(const char *ArgStr, const char *Help, int Flags = 0, 
 		const char *DefaultVal = "") 
-    : Option(ArgStr, Help, Flags), string(DefaultVal) {}
+    : Option(ArgStr, Help, Flags), std::string(DefaultVal) {}
 
-  inline const string &operator=(const string &Val) { 
-    return string::operator=(Val);
+  inline const std::string &operator=(const std::string &Val) { 
+    return std::string::operator=(Val);
   }
 };
 
@@ -228,7 +228,7 @@
 //===----------------------------------------------------------------------===//
 // String list command line option
 //
-class StringList : public Option, public vector<string> {
+class StringList : public Option, public std::vector<std::string> {
 
   virtual enum NumOccurances getNumOccurancesFlagDefault() const { 
     return ZeroOrMore;
@@ -236,7 +236,7 @@
   virtual enum ValueExpected getValueExpectedFlagDefault() const {
     return ValueRequired;
   }
-  virtual bool handleOccurance(const char *ArgName, const string &Arg);
+  virtual bool handleOccurance(const char *ArgName, const std::string &Arg);
 
 public:
   inline StringList(const char *ArgStr, const char *Help, int Flags = 0)
@@ -256,7 +256,7 @@
   // Use a vector instead of a map, because the lists should be short,
   // the overhead is less, and most importantly, it keeps them in the order
   // inserted so we can print our option out nicely.
-  vector<pair<const char *, pair<int, const char *> > > ValueMap;
+  std::vector<std::pair<const char *, std::pair<int, const char *> > > ValueMap;
 
   inline EnumBase(const char *ArgStr, const char *Help, int Flags)
     : Option(ArgStr, Help, Flags) {}
@@ -284,7 +284,7 @@
   inline EnumValueBase(int Flags) : EnumBase(Flags) {}
 
   // handleOccurance - Set Value to the enum value specified by Arg
-  virtual bool handleOccurance(const char *ArgName, const string &Arg);
+  virtual bool handleOccurance(const char *ArgName, const std::string &Arg);
 
   // Return the width of the option tag for printing...
   virtual unsigned getOptionWidth() const;
@@ -323,7 +323,7 @@
     return ValueDisallowed;
   }
 protected:
-  virtual bool handleOccurance(const char *ArgName, const string &Arg);
+  virtual bool handleOccurance(const char *ArgName, const std::string &Arg);
   inline EnumFlagsBase(int Flags) : EnumValueBase(Flags) {}
 
   // Return the width of the option tag for printing...
@@ -363,11 +363,11 @@
     return ValueDisallowed;
   }
 protected:
-  vector<int> Values;  // The options specified so far.
+  std::vector<int> Values;  // The options specified so far.
 
   inline EnumListBase(int Flags) 
     : EnumBase(Flags) {}
-  virtual bool handleOccurance(const char *ArgName, const string &Arg);
+  virtual bool handleOccurance(const char *ArgName, const std::string &Arg);
 
   // Return the width of the option tag for printing...
   virtual unsigned getOptionWidth() const;
diff --git a/include/Support/DepthFirstIterator.h b/include/Support/DepthFirstIterator.h
index a2d5a9d..2961497 100644
--- a/include/Support/DepthFirstIterator.h
+++ b/include/Support/DepthFirstIterator.h
@@ -20,21 +20,21 @@
   typedef typename GT::NodeType          NodeType;
   typedef typename GT::ChildIteratorType ChildItTy;
 
-  set<NodeType *>   Visited;    // All of the blocks visited so far...
+  std::set<NodeType *> Visited;    // All of the blocks visited so far...
   // VisitStack - Used to maintain the ordering.  Top = current block
   // First element is node pointer, second is the 'next child' to visit
-  stack<pair<NodeType *, ChildItTy> > VisitStack;
+  std::stack<std::pair<NodeType *, ChildItTy> > VisitStack;
   const bool Reverse;         // Iterate over children before self?
 private:
   void reverseEnterNode() {
-    pair<NodeType *, ChildItTy> &Top = VisitStack.top();
+    std::pair<NodeType *, ChildItTy> &Top = VisitStack.top();
     NodeType *Node = Top.first;
     ChildItTy &It  = Top.second;
     for (; It != GT::child_end(Node); ++It) {
       NodeType *Child = *It;
       if (!Visited.count(Child)) {
 	Visited.insert(Child);
-	VisitStack.push(make_pair(Child, GT::child_begin(Child)));
+	VisitStack.push(std::make_pair(Child, GT::child_begin(Child)));
 	reverseEnterNode();
 	return;
       }
@@ -43,7 +43,7 @@
 
   inline df_iterator(NodeType *Node, bool reverse) : Reverse(reverse) {
     Visited.insert(Node);
-    VisitStack.push(make_pair(Node, GT::child_begin(Node)));
+    VisitStack.push(std::make_pair(Node, GT::child_begin(Node)));
     if (Reverse) reverseEnterNode();
   }
   inline df_iterator() { /* End is when stack is empty */ }
@@ -81,7 +81,7 @@
 	reverseEnterNode();
     } else {                     // Normal Depth First Iterator
       do {
-	pair<NodeType *, ChildItTy> &Top = VisitStack.top();
+	std::pair<NodeType *, ChildItTy> &Top = VisitStack.top();
 	NodeType *Node = Top.first;
 	ChildItTy &It  = Top.second;
 
@@ -90,7 +90,7 @@
 	  if (!Visited.count(Next)) {  // Has our next sibling been visited?
 	    // No, do it now.
 	    Visited.insert(Next);
-	    VisitStack.push(make_pair(Next, GT::child_begin(Next)));
+	    VisitStack.push(std::make_pair(Next, GT::child_begin(Next)));
 	    return *this;
 	  }
 	}
diff --git a/include/Support/HashExtras.h b/include/Support/HashExtras.h
index 6ea831e..d7e48a3 100644
--- a/include/Support/HashExtras.h
+++ b/include/Support/HashExtras.h
@@ -11,7 +11,10 @@
 #define LLVM_SUPPORT_HASHEXTRAS_H
 
 #include <string>
-#include <hash_map>
+#include <ext/hash_map>
+
+// Cannot specialize hash template from outside of the std namespace.
+namespace std {
 
 template <> struct hash<string> {
   size_t operator()(string const &str) const {
@@ -24,4 +27,6 @@
   inline size_t operator()(const T *Val) const { return (size_t)Val; }
 };
 
+}  // End namespace std
+
 #endif
diff --git a/include/Support/PostOrderIterator.h b/include/Support/PostOrderIterator.h
index 89a9b4d..85b3bf6 100644
--- a/include/Support/PostOrderIterator.h
+++ b/include/Support/PostOrderIterator.h
@@ -20,10 +20,10 @@
   typedef typename GT::NodeType          NodeType;
   typedef typename GT::ChildIteratorType ChildItTy;
 
-  set<NodeType *>   Visited;    // All of the blocks visited so far...
+  std::set<NodeType *> Visited;    // All of the blocks visited so far...
   // VisitStack - Used to maintain the ordering.  Top = current block
   // First element is basic block pointer, second is the 'next child' to visit
-  stack<pair<NodeType *, ChildItTy> > VisitStack;
+  std::stack<std::pair<NodeType *, ChildItTy> > VisitStack;
 
   void traverseChild() {
     while (VisitStack.top().second != GT::child_end(VisitStack.top().first)) {
@@ -122,10 +122,10 @@
 // }
 //
 
-typedef reverse_iterator<vector<BasicBlock*>::iterator> rpo_iterator;
+typedef std::vector<BasicBlock*>::reverse_iterator rpo_iterator;
 // TODO: FIXME: ReversePostOrderTraversal is not generic!
 class ReversePostOrderTraversal {
-  vector<BasicBlock*> Blocks;       // Block list in normal PO order
+  std::vector<BasicBlock*> Blocks;       // Block list in normal PO order
   inline void Initialize(BasicBlock *BB) {
     copy(po_begin(BB), po_end(BB), back_inserter(Blocks));
   }
diff --git a/include/Support/STLExtras.h b/include/Support/STLExtras.h
index 44d789d..0168bf2 100644
--- a/include/Support/STLExtras.h
+++ b/include/Support/STLExtras.h
@@ -36,7 +36,7 @@
 // arguments to get a boolean result.
 //
 template<class Ty>
-struct bitwise_or : public binary_function<Ty, Ty, bool> {
+struct bitwise_or : public std::binary_function<Ty, Ty, bool> {
   bool operator()(const Ty& left, const Ty& right) const {
     return left | right;
   }
@@ -70,9 +70,9 @@
   RootIt current;
   UnaryFunc Fn;
 public:
-  typedef typename iterator_traits<RootIt>::iterator_category
+  typedef typename std::iterator_traits<RootIt>::iterator_category
           iterator_category;
-  typedef typename iterator_traits<RootIt>::difference_type
+  typedef typename std::iterator_traits<RootIt>::difference_type
           difference_type;
   typedef typename UnaryFunc::result_type value_type;
   typedef typename UnaryFunc::result_type *pointer;
@@ -102,6 +102,7 @@
   _Self& operator-=   (difference_type n) { current -= n; return *this; }
   reference operator[](difference_type n) const { return *(*this + n); }  
 
+  inline bool operator!=(const _Self &X) const { return !operator==(X); }
   inline bool operator==(const _Self &X) const { return current == X.current; }
   inline bool operator< (const _Self &X) const { return current <  X.current; }
 
diff --git a/include/Support/StringExtras.h b/include/Support/StringExtras.h
index e67e25c..46e2c5a 100644
--- a/include/Support/StringExtras.h
+++ b/include/Support/StringExtras.h
@@ -11,7 +11,7 @@
 #include <string>
 #include <stdio.h>
 
-static inline string utostr(uint64_t X, bool isNeg = false) {
+static inline std::string utostr(uint64_t X, bool isNeg = false) {
   char Buffer[40];
   char *BufPtr = Buffer+39;
 
@@ -25,10 +25,10 @@
 
   if (isNeg) *--BufPtr = '-';   // Add negative sign...
 
-  return string(BufPtr);
+  return std::string(BufPtr);
 }
 
-static inline string itostr(int64_t X) {
+static inline std::string itostr(int64_t X) {
   if (X < 0) 
     return utostr((uint64_t)-X, true);
   else
@@ -36,7 +36,7 @@
 }
 
 
-static inline string utostr(unsigned X, bool isNeg = false) {
+static inline std::string utostr(unsigned X, bool isNeg = false) {
   char Buffer[20];
   char *BufPtr = Buffer+19;
 
@@ -50,17 +50,17 @@
 
   if (isNeg) *--BufPtr = '-';   // Add negative sign...
 
-  return string(BufPtr);
+  return std::string(BufPtr);
 }
 
-static inline string itostr(int X) {
+static inline std::string itostr(int X) {
   if (X < 0) 
     return utostr((unsigned)-X, true);
   else
     return utostr((unsigned)X);
 }
 
-static inline string ftostr(double V) {
+static inline std::string ftostr(double V) {
   char Buffer[200];
   snprintf(Buffer, 200, "%e", V);
   return Buffer;
diff --git a/include/Support/Tree.h b/include/Support/Tree.h
index 33b0bb7..9e8d5ae 100644
--- a/include/Support/Tree.h
+++ b/include/Support/Tree.h
@@ -12,21 +12,21 @@
 
 template<class ConcreteTreeNode, class Payload>
 class Tree {
-  vector<ConcreteTreeNode*>    Children;        // This nodes children, if any
-  ConcreteTreeNode            *Parent;          // Parent of this node...
-  Payload                      Data;            // Data held in this node...
+  std::vector<ConcreteTreeNode*> Children;        // This nodes children, if any
+  ConcreteTreeNode              *Parent;          // Parent of this node...
+  Payload                        Data;            // Data held in this node...
 
 protected:
-  void setChildren(const vector<ConcreteTreeNode*> &children) {
+  void setChildren(const std::vector<ConcreteTreeNode*> &children) {
     Children = children;
   }
 public:
   inline Tree(ConcreteTreeNode *parent) : Parent(parent) {}
-  inline Tree(const vector<ConcreteTreeNode*> &children, ConcreteTreeNode *par)
-    : Children(children), Parent(par) {}
+  inline Tree(const std::vector<ConcreteTreeNode*> &children,
+              ConcreteTreeNode *par) : Children(children), Parent(par) {}
 
-  inline Tree(const vector<ConcreteTreeNode*> &children, ConcreteTreeNode *par,
-	      const Payload &data) 
+  inline Tree(const std::vector<ConcreteTreeNode*> &children,
+              ConcreteTreeNode *par, const Payload &data) 
     : Children(children), Parent(parent), Data(data) {}
 
   // Tree dtor - Free all children