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/lib/Analysis/Expressions.cpp b/lib/Analysis/Expressions.cpp
index a35e37a..e94c796 100644
--- a/lib/Analysis/Expressions.cpp
+++ b/lib/Analysis/Expressions.cpp
@@ -11,6 +11,7 @@
 #include "llvm/Optimizations/ConstantHandling.h"
 #include "llvm/Method.h"
 #include "llvm/BasicBlock.h"
+#include <iostream>
 
 using namespace opt;  // Get all the constant handling stuff
 using namespace analysis;
@@ -178,7 +179,7 @@
 static ExprType handleAddition(ExprType Left, ExprType Right, Value *V) {
   const Type *Ty = V->getType();
   if (Left.ExprTy > Right.ExprTy)
-    swap(Left, Right);   // Make left be simpler than right
+    std::swap(Left, Right);   // Make left be simpler than right
 
   switch (Left.ExprTy) {
   case ExprType::Constant:
@@ -229,7 +230,7 @@
   case Value::TypeVal:   case Value::BasicBlockVal:
   case Value::MethodVal: case Value::ModuleVal: default:
     //assert(0 && "Unexpected expression type to classify!");
-    cerr << "Bizarre thing to expr classify: " << Expr << endl;
+    std::cerr << "Bizarre thing to expr classify: " << Expr << "\n";
     return Expr;
   case Value::GlobalVariableVal:        // Global Variable & Method argument:
   case Value::MethodArgumentVal:        // nothing known, return variable itself
@@ -280,7 +281,7 @@
     ExprType Left (ClassifyExpression(I->getOperand(0)));
     ExprType Right(ClassifyExpression(I->getOperand(1)));
     if (Left.ExprTy > Right.ExprTy)
-      swap(Left, Right);   // Make left be simpler than right
+      std::swap(Left, Right);   // Make left be simpler than right
 
     if (Left.ExprTy != ExprType::Constant)  // RHS must be > constant
       return I;         // Quadratic eqn! :(
diff --git a/lib/Analysis/IPA/CallGraph.cpp b/lib/Analysis/IPA/CallGraph.cpp
index d77064c..e48cf7f 100644
--- a/lib/Analysis/IPA/CallGraph.cpp
+++ b/lib/Analysis/IPA/CallGraph.cpp
@@ -29,7 +29,7 @@
   assert(M->getParent() == Mod && "Method not in current module!");
   CallGraphNode *New = new CallGraphNode(M);
 
-  MethodMap.insert(pair<const Method*, CallGraphNode*>(M, New));
+  MethodMap.insert(std::make_pair(M, New));
   return New;
 }
 
@@ -71,7 +71,7 @@
 }
 
 
-void cfg::WriteToOutput(const CallGraphNode *CGN, ostream &o) {
+void cfg::WriteToOutput(const CallGraphNode *CGN, std::ostream &o) {
   if (CGN->getMethod())
     o << "Call graph node for method: '" << CGN->getMethod()->getName() <<"'\n";
   else
@@ -79,10 +79,10 @@
 
   for (unsigned i = 0; i < CGN->size(); ++i)
     o << "  Calls method '" << (*CGN)[i]->getMethod()->getName() << "'\n";
-  o << endl;
+  o << "\n";
 }
 
-void cfg::WriteToOutput(const CallGraph &CG, ostream &o) {
+void cfg::WriteToOutput(const CallGraph &CG, std::ostream &o) {
   WriteToOutput(CG.getRoot(), o);
   for (CallGraph::const_iterator I = CG.begin(), E = CG.end(); I != E; ++I)
     o << I->second;
diff --git a/lib/Analysis/IPA/FindUnsafePointerTypes.cpp b/lib/Analysis/IPA/FindUnsafePointerTypes.cpp
index 50fb8ea..1058e6e 100644
--- a/lib/Analysis/IPA/FindUnsafePointerTypes.cpp
+++ b/lib/Analysis/IPA/FindUnsafePointerTypes.cpp
@@ -60,7 +60,7 @@
         UnsafeTypes.insert((PointerType*)ITy);
 
         if (PrintFailures) {
-          CachedWriter CW(M->getParent(), cerr);
+          CachedWriter CW(M->getParent(), std::cerr);
           CW << "FindUnsafePointerTypes: Type '" << ITy
              << "' marked unsafe in '" << Meth->getName() << "' by:\n" << Inst;
         }
@@ -74,7 +74,7 @@
 // printResults - Loop over the results of the analysis, printing out unsafe
 // types.
 //
-void FindUnsafePointerTypes::printResults(const Module *M, ostream &o) {
+void FindUnsafePointerTypes::printResults(const Module *M, std::ostream &o) {
   if (UnsafeTypes.empty()) {
     o << "SafePointerAccess Analysis: No unsafe types found!\n";
     return;
@@ -84,9 +84,9 @@
 
   CW << "SafePointerAccess Analysis: Found these unsafe types:\n";
   unsigned Counter = 1;
-  for (set<PointerType*>::const_iterator I = getUnsafeTypes().begin(), 
+  for (std::set<PointerType*>::const_iterator I = getUnsafeTypes().begin(), 
          E = getUnsafeTypes().end(); I != E; ++I, ++Counter) {
     
-    CW << " #" << Counter << ". " << (Value*)*I << endl;
+    CW << " #" << Counter << ". " << (Value*)*I << "\n";
   }
 }
diff --git a/lib/Analysis/IPA/FindUsedTypes.cpp b/lib/Analysis/IPA/FindUsedTypes.cpp
index 6f8049a..1d98983 100644
--- a/lib/Analysis/IPA/FindUsedTypes.cpp
+++ b/lib/Analysis/IPA/FindUsedTypes.cpp
@@ -78,15 +78,15 @@
 // passed in, then the types are printed symbolically if possible, using the
 // symbol table from the module.
 //
-void FindUsedTypes::printTypes(ostream &o, const Module *M = 0) const {
+void FindUsedTypes::printTypes(std::ostream &o, const Module *M = 0) const {
   o << "Types in use by this module:\n";
   if (M) {
     CachedWriter CW(M, o);
-    for (set<const Type *>::const_iterator I = UsedTypes.begin(),
+    for (std::set<const Type *>::const_iterator I = UsedTypes.begin(),
            E = UsedTypes.end(); I != E; ++I)
-      CW << "  " << *I << endl;
+      CW << "  " << *I << "\n";
   } else
-    for (set<const Type *>::const_iterator I = UsedTypes.begin(),
+    for (std::set<const Type *>::const_iterator I = UsedTypes.begin(),
            E = UsedTypes.end(); I != E; ++I)
-      o << "  " << *I << endl;
+      o << "  " << *I << "\n";
 }
diff --git a/lib/Analysis/InductionVariable.cpp b/lib/Analysis/InductionVariable.cpp
index d88c9cf..045c932 100644
--- a/lib/Analysis/InductionVariable.cpp
+++ b/lib/Analysis/InductionVariable.cpp
@@ -88,7 +88,7 @@
     ExprType E2 = analysis::ClassifyExpression(V2);
 
     if (E1.ExprTy > E2.ExprTy)        // Make E1 be the simpler expression
-      swap(E1, E2);
+      std::swap(E1, E2);
     
     // E1 must be a constant incoming value, and E2 must be a linear expression
     // with respect to the PHI node.
@@ -109,7 +109,7 @@
     // Make sure that V1 is the incoming value, and V2 is from the backedge of
     // the loop.
     if (L->contains(Phi->getIncomingBlock(0)))     // Wrong order.  Swap now.
-      swap(V1, V2);
+      std::swap(V1, V2);
     
     Start = V1;     // We know that Start has to be loop invariant...
     Step = 0;
diff --git a/lib/Analysis/IntervalPartition.cpp b/lib/Analysis/IntervalPartition.cpp
index 8616cb7..fff8d22 100644
--- a/lib/Analysis/IntervalPartition.cpp
+++ b/lib/Analysis/IntervalPartition.cpp
@@ -9,6 +9,7 @@
 #include "Support/STLExtras.h"
 
 using namespace cfg;
+using std::make_pair;
 
 //===----------------------------------------------------------------------===//
 // IntervalPartition Implementation
diff --git a/lib/Analysis/LiveVar/BBLiveVar.cpp b/lib/Analysis/LiveVar/BBLiveVar.cpp
index d7e036b..0ecf96c 100644
--- a/lib/Analysis/LiveVar/BBLiveVar.cpp
+++ b/lib/Analysis/LiveVar/BBLiveVar.cpp
@@ -1,8 +1,13 @@
 #include "llvm/Analysis/LiveVar/BBLiveVar.h"
 #include "llvm/Analysis/LiveVar/MethodLiveVarInfo.h"
 #include "llvm/CodeGen/MachineInstr.h"
+
+/// BROKEN: Should not include sparc stuff directly into here
 #include "../../Target/Sparc/SparcInternals.h"  //  Only for PHI defn
 
+using std::cerr;
+using std::endl;
+using std::pair;
 
 //-----------------------------------------------------------------------------
 // Constructor
@@ -39,7 +44,7 @@
     if( DEBUG_LV > 1) {                            // debug msg
       cerr << " *Iterating over machine instr ";
       MInst->dump();
-      cerr << endl;
+      cerr << "\n";
     }
 
     // iterate over  MI operands to find defs
@@ -85,9 +90,9 @@
 	  if( DEBUG_LV > 1) {   // debug msg of level 2
 	    cerr << "   - phi operand "; 
 	    printValue( ArgVal ); 
-	    cerr  << " came from BB "; 
+	    cerr << " came from BB "; 
 	    printValue( PhiArgMap[ ArgVal ]); 
-	    cerr<<endl;
+	    cerr << "\n";
 	  }
 
 	} // if( IsPhi )
@@ -123,7 +128,7 @@
   InSetChanged = true; 
 
   if( DEBUG_LV > 1) {   
-    cerr << "  +Def: "; printValue( Op ); cerr << endl;
+    cerr << "  +Def: "; printValue( Op ); cerr << "\n";
   }
 }
 
diff --git a/lib/Analysis/LiveVar/BBLiveVar.h b/lib/Analysis/LiveVar/BBLiveVar.h
index 6d7d4eb..9ce56a8 100644
--- a/lib/Analysis/LiveVar/BBLiveVar.h
+++ b/lib/Analysis/LiveVar/BBLiveVar.h
@@ -28,7 +28,7 @@
 
                                 // map that contains phi args->BB they came
                                 // set by calcDefUseSets & used by setPropagate
-  hash_map<const Value *, const BasicBlock *, hashFuncValue> PhiArgMap;  
+  std::hash_map<const Value *, const BasicBlock *> PhiArgMap;  
 
   // method to propogate an InSet to OutSet of a predecessor
   bool setPropagate( LiveVarSet *const OutSetOfPred, 
diff --git a/lib/Analysis/LiveVar/FunctionLiveVarInfo.cpp b/lib/Analysis/LiveVar/FunctionLiveVarInfo.cpp
index 636359d..5de35ff 100644
--- a/lib/Analysis/LiveVar/FunctionLiveVarInfo.cpp
+++ b/lib/Analysis/LiveVar/FunctionLiveVarInfo.cpp
@@ -12,15 +12,15 @@
 #include "llvm/Analysis/LiveVar/MethodLiveVarInfo.h"
 #include "llvm/CodeGen/MachineInstr.h"
 #include "Support/PostOrderIterator.h"
-
+#include <iostream>
+using std::cout;
+using std::endl;
 
 //************************** Constructor/Destructor ***************************
 
 
-MethodLiveVarInfo::MethodLiveVarInfo(const Method *const M) : Meth(M),  
-							      BB2BBLVMap()
-{ 
-  assert(! M->isExternal() );           // cannot be a prototype decleration
+MethodLiveVarInfo::MethodLiveVarInfo(const Method *const M) : Meth(M) {
+  assert(!M->isExternal() && "Cannot be a prototype declaration");
   HasAnalyzed = false;                  // still we haven't called analyze()
 }
 
@@ -55,8 +55,6 @@
     if( (*MI).first )              // delete all LiveVarSets in  MInst2LVSetBI
       delete (*MI).second;
    }
-
-
 }
 
 
diff --git a/lib/Analysis/LiveVar/ValueSet.cpp b/lib/Analysis/LiveVar/ValueSet.cpp
index 6806d1c..d176d9e 100644
--- a/lib/Analysis/LiveVar/ValueSet.cpp
+++ b/lib/Analysis/LiveVar/ValueSet.cpp
@@ -1,11 +1,14 @@
 
 #include "llvm/Analysis/LiveVar/ValueSet.h"
 #include "llvm/ConstantVals.h"
-
+#include <iostream>
+using std::cerr;
+using std::endl;
+using std::pair;
+using std::hash_set;
 
 void printValue( const Value *const v)  // func to print a Value 
 {
-  
   if (v->hasName())
     cerr << v << "(" << ((*v).getName()) << ") ";
   else if (Constant *C = dyn_cast<Constant>(v))
@@ -16,17 +19,13 @@
 
 
 //---------------- Method implementations --------------------------
-
-
-ValueSet:: ValueSet() : hash_set<const Value *,  hashFuncValue> () { }
-
                                              // for performing two set unions
 bool ValueSet::setUnion( const ValueSet *const set1) {   
   const_iterator set1it;
   pair<iterator, bool> result;
   bool changed = false;
 
-  for( set1it = set1->begin() ; set1it != set1->end(); set1it++) {  
+  for( set1it = set1->begin() ; set1it != set1->end(); ++set1it) {  
                                              // for all all elements in set1
     result = insert( *set1it );              // insert to this set
       if( result.second == true) changed = true;
@@ -41,7 +40,7 @@
 			      const ValueSet *const set2) { 
 
   const_iterator set1it, set2it;
-  for( set1it = set1->begin() ; set1it != set1->end(); set1it++) {  
+  for( set1it = set1->begin() ; set1it != set1->end(); ++set1it) {  
                                              // for all elements in set1
     iterator set2it = set2->find( *set1it ); // find wether the elem is in set2
     if( set2it == set2->end() )              // if the element is not in set2
@@ -53,7 +52,7 @@
                                         // for performing set subtraction
 void ValueSet::setSubtract( const ValueSet *const set1) { 
   const_iterator set1it;
-  for( set1it = set1->begin() ; set1it != set1->end(); set1it++)  
+  for( set1it = set1->begin() ; set1it != set1->end(); ++set1it)  
                                         // for all elements in set1
     erase( *set1it );                   // erase that element from this set
 }
@@ -62,7 +61,5 @@
 
 
 void ValueSet::printSet()  const {     // for printing a live variable set
-      const_iterator it;
-      for( it = begin() ; it != end(); it++) 
-	printValue( *it );
+  for_each(begin(), end(), printValue);
 }
diff --git a/lib/Analysis/LoopDepth.cpp b/lib/Analysis/LoopDepth.cpp
index ed96bd4..994b7cd 100644
--- a/lib/Analysis/LoopDepth.cpp
+++ b/lib/Analysis/LoopDepth.cpp
@@ -22,8 +22,6 @@
 }
 
 LoopDepthCalculator::LoopDepthCalculator(Method *M) {
-  //map<const BasicBlock*, unsigned> LoopDepth;
-
   cfg::IntervalPartition *IP = new cfg::IntervalPartition(M);
   while (!IP->isDegeneratePartition()) {
     for_each(IP->begin(), IP->end(), 
@@ -34,7 +32,7 @@
     //
     cfg::IntervalPartition *NewIP = new cfg::IntervalPartition(*IP, true);
     if (NewIP->size() == IP->size()) {
-      cerr << "IRREDUCIBLE GRAPH FOUND!!!\n";
+      assert(0 && "IRREDUCIBLE GRAPH FOUND!!!\n");
       // TODO: fix irreducible graph
       return;
     }
diff --git a/lib/Analysis/LoopInfo.cpp b/lib/Analysis/LoopInfo.cpp
index 40a195b..ed91ca8 100644
--- a/lib/Analysis/LoopInfo.cpp
+++ b/lib/Analysis/LoopInfo.cpp
@@ -33,7 +33,7 @@
 					  const DominatorSet &DS) {
   if (BBMap.find(BB) != BBMap.end()) return 0;   // Havn't processed this node?
 
-  vector<const BasicBlock *> TodoStack;
+  std::vector<const BasicBlock *> TodoStack;
 
   // Scan the predecessors of BB, checking to see if BB dominates any of
   // them.
@@ -64,7 +64,7 @@
   // loop can be found for them.  Also check subsidary basic blocks to see if
   // they start subloops of their own.
   //
-  for (vector<const BasicBlock*>::reverse_iterator I = L->Blocks.rbegin(),
+  for (std::vector<const BasicBlock*>::reverse_iterator I = L->Blocks.rbegin(),
 	 E = L->Blocks.rend(); I != E; ++I) {
 
     // Check to see if this block starts a new loop
@@ -74,7 +74,7 @@
     }
   
     if (BBMap.find(*I) == BBMap.end())
-      BBMap.insert(make_pair(*I, L));
+      BBMap.insert(std::make_pair(*I, L));
   }
 
   return L;
diff --git a/lib/Analysis/ModuleAnalyzer.cpp b/lib/Analysis/ModuleAnalyzer.cpp
index 129fb3b..dc07512 100644
--- a/lib/Analysis/ModuleAnalyzer.cpp
+++ b/lib/Analysis/ModuleAnalyzer.cpp
@@ -13,6 +13,8 @@
 #include "llvm/DerivedTypes.h"
 #include "Support/STLExtras.h"
 #include <map>
+#include <iostream>
+using std::set;
 
 // processModule - Driver function to call all of my subclasses virtual methods.
 //
@@ -59,8 +61,8 @@
     break;
 
   default:
-    cerr << "ModuleAnalyzer::handleType, type unknown: '" 
-	 << T->getName() << "'\n";
+    std::cerr << "ModuleAnalyzer::handleType, type unknown: '" 
+              << T->getName() << "'\n";
     break;
   }
 
diff --git a/lib/Analysis/PostDominators.cpp b/lib/Analysis/PostDominators.cpp
index 2ed02db..2e4f6e4 100644
--- a/lib/Analysis/PostDominators.cpp
+++ b/lib/Analysis/PostDominators.cpp
@@ -10,6 +10,8 @@
 #include "Support/DepthFirstIterator.h"
 #include "Support/STLExtras.h"
 #include <algorithm>
+using std::set;
+
 
 //===----------------------------------------------------------------------===//
 //  Helper Template
diff --git a/lib/Analysis/Writer.cpp b/lib/Analysis/Writer.cpp
index 3d9134f..1e873bf 100644
--- a/lib/Analysis/Writer.cpp
+++ b/lib/Analysis/Writer.cpp
@@ -12,6 +12,10 @@
 #include "llvm/Analysis/InductionVariable.h"
 #include <iterator>
 #include <algorithm>
+using std::ostream;
+using std::set;
+using std::vector;
+using std::string;
 
 //===----------------------------------------------------------------------===//
 //  Interval Printing Routines
@@ -23,19 +27,19 @@
   
   // Print out all of the basic blocks in the interval...
   copy(I->Nodes.begin(), I->Nodes.end(), 
-       ostream_iterator<BasicBlock*>(o, "\n"));
+       std::ostream_iterator<BasicBlock*>(o, "\n"));
 
   o << "Interval Predecessors:\n";
   copy(I->Predecessors.begin(), I->Predecessors.end(), 
-       ostream_iterator<BasicBlock*>(o, "\n"));
+       std::ostream_iterator<BasicBlock*>(o, "\n"));
   
   o << "Interval Successors:\n";
   copy(I->Successors.begin(), I->Successors.end(), 
-       ostream_iterator<BasicBlock*>(o, "\n"));
+       std::ostream_iterator<BasicBlock*>(o, "\n"));
 }
 
 void cfg::WriteToOutput(const IntervalPartition &IP, ostream &o) {
-  copy(IP.begin(), IP.end(), ostream_iterator<const Interval *>(o, "\n"));
+  copy(IP.begin(), IP.end(), std::ostream_iterator<const Interval *>(o, "\n"));
 }
 
 
@@ -45,7 +49,7 @@
 //===----------------------------------------------------------------------===//
 
 ostream &operator<<(ostream &o, const set<const BasicBlock*> &BBs) {
-  copy(BBs.begin(), BBs.end(), ostream_iterator<const BasicBlock*>(o, "\n"));
+  copy(BBs.begin(),BBs.end(), std::ostream_iterator<const BasicBlock*>(o,"\n"));
   return o;
 }
 
@@ -53,7 +57,7 @@
   for (DominatorSet::const_iterator I = DS.begin(), E = DS.end(); I != E; ++I) {
     o << "=============================--------------------------------\n"
       << "\nDominator Set For Basic Block\n" << I->first
-      << "-------------------------------\n" << I->second << endl;
+      << "-------------------------------\n" << I->second << "\n";
   }
 }
 
@@ -63,7 +67,7 @@
        I != E; ++I) {
     o << "=============================--------------------------------\n"
       << "\nImmediate Dominator For Basic Block\n" << I->first
-      << "is: \n" << I->second << endl;
+      << "is: \n" << I->second << "\n";
   }
 }
 
@@ -93,7 +97,7 @@
        I != E; ++I) {
     o << "=============================--------------------------------\n"
       << "\nDominance Frontier For Basic Block\n" << I->first
-      << "is: \n" << I->second << endl;
+      << "is: \n" << I->second << "\n";
   }
 }
 
@@ -109,15 +113,15 @@
     if (i) o << ",";
     WriteAsOperand(o, (const Value*)L->getBlocks()[i]);
   }
-  o << endl;
+  o << "\n";
 
   copy(L->getSubLoops().begin(), L->getSubLoops().end(),
-       ostream_iterator<const Loop*>(o, "\n"));
+       std::ostream_iterator<const Loop*>(o, "\n"));
 }
 
 void cfg::WriteToOutput(const LoopInfo &LI, ostream &o) {
   copy(LI.getTopLevelLoops().begin(), LI.getTopLevelLoops().end(),
-       ostream_iterator<const Loop*>(o, "\n"));
+       std::ostream_iterator<const Loop*>(o, "\n"));
 }
 
 
@@ -138,11 +142,11 @@
     WriteAsOperand(o, (const Value*)IV.Phi);
     o << ":\n" << (const Value*)IV.Phi;
   } else {
-    o << endl;
+    o << "\n";
   }
   if (IV.InductionType == InductionVariable::Unknown) return;
 
   o << "  Start ="; WriteAsOperand(o, IV.Start);
   o << "  Step =" ; WriteAsOperand(o, IV.Step);
-  o << endl;
+  o << "\n";
 }