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/Transforms/Scalar/ADCE.cpp b/lib/Transforms/Scalar/ADCE.cpp
index a38dbc5..45a57a2 100644
--- a/lib/Transforms/Scalar/ADCE.cpp
+++ b/lib/Transforms/Scalar/ADCE.cpp
@@ -17,6 +17,8 @@
 #include "Support/DepthFirstIterator.h"
 #include <set>
 #include <algorithm>
+#include <iostream>
+using std::cerr;
 
 #define DEBUG_ADCE 1
 
@@ -28,8 +30,8 @@
 //
 class ADCE {
   Method *M;                            // The method that we are working on...
-  vector<Instruction*>   WorkList;      // Instructions that just became live
-  set<Instruction*>      LiveSet;       // The set of live instructions
+  std::vector<Instruction*> WorkList;   // Instructions that just became live
+  std::set<Instruction*>    LiveSet;    // The set of live instructions
   bool MadeChanges;
 
   //===--------------------------------------------------------------------===//
@@ -66,8 +68,8 @@
   // fixupCFG - Walk the CFG in depth first order, eliminating references to 
   // dead blocks.
   //
-  BasicBlock *fixupCFG(BasicBlock *Head, set<BasicBlock*> &VisitedBlocks,
-		       const set<BasicBlock*> &AliveBlocks);
+  BasicBlock *fixupCFG(BasicBlock *Head, std::set<BasicBlock*> &VisitedBlocks,
+		       const std::set<BasicBlock*> &AliveBlocks);
 };
 
 
@@ -121,7 +123,7 @@
   // AliveBlocks - Set of basic blocks that we know have instructions that are
   // alive in them...
   //
-  set<BasicBlock*> AliveBlocks;
+  std::set<BasicBlock*> AliveBlocks;
 
   // Process the work list of instructions that just became live... if they
   // became live, then that means that all of their operands are neccesary as
@@ -169,7 +171,7 @@
   // After the worklist is processed, recursively walk the CFG in depth first
   // order, patching up references to dead blocks...
   //
-  set<BasicBlock*> VisitedBlocks;
+  std::set<BasicBlock*> VisitedBlocks;
   BasicBlock *EntryBlock = fixupCFG(M->front(), VisitedBlocks, AliveBlocks);
   if (EntryBlock && EntryBlock != M->front()) {
     if (isa<PHINode>(EntryBlock->front())) {
@@ -194,7 +196,7 @@
     } else {
       // We need to move the new entry block to be the first bb of the method.
       Method::iterator EBI = find(M->begin(), M->end(), EntryBlock);
-      swap(*EBI, *M->begin());  // Exchange old location with start of method
+      std::swap(*EBI, *M->begin());// Exchange old location with start of method
       MadeChanges = true;
     }
   }
@@ -242,8 +244,8 @@
 //        been in the alive set).
 //   3. Return the nonnull child, or 0 if no non-null children.
 //
-BasicBlock *ADCE::fixupCFG(BasicBlock *BB, set<BasicBlock*> &VisitedBlocks,
-			   const set<BasicBlock*> &AliveBlocks) {
+BasicBlock *ADCE::fixupCFG(BasicBlock *BB, std::set<BasicBlock*> &VisitedBlocks,
+			   const std::set<BasicBlock*> &AliveBlocks) {
   if (VisitedBlocks.count(BB)) return 0;   // Revisiting a node? No update.
   VisitedBlocks.insert(BB);                // We have now visited this node!
 
diff --git a/lib/Transforms/Scalar/ConstantProp.cpp b/lib/Transforms/Scalar/ConstantProp.cpp
index c267d95..a961bad 100644
--- a/lib/Transforms/Scalar/ConstantProp.cpp
+++ b/lib/Transforms/Scalar/ConstantProp.cpp
@@ -159,7 +159,7 @@
 bool opt::ConstantPropogation::doConstantPropogation(BasicBlock *BB,
 						     BasicBlock::iterator &II) {
   Instruction *Inst = *II;
-  if (BinaryOperator *BInst = dyn_cast<BinaryOperator>(Inst)) {
+  if (isa<BinaryOperator>(Inst)) {
     Constant *D1 = dyn_cast<Constant>(Inst->getOperand(0));
     Constant *D2 = dyn_cast<Constant>(Inst->getOperand(1));
 
diff --git a/lib/Transforms/Scalar/DCE.cpp b/lib/Transforms/Scalar/DCE.cpp
index 6c4e3d2..eadf7b1 100644
--- a/lib/Transforms/Scalar/DCE.cpp
+++ b/lib/Transforms/Scalar/DCE.cpp
@@ -117,7 +117,7 @@
   // If there is more than one predecessor, and there are PHI nodes in
   // the successor, then we need to add incoming edges for the PHI nodes
   //
-  const vector<BasicBlock*> BBPreds(BB->pred_begin(), BB->pred_end());
+  const std::vector<BasicBlock*> BBPreds(BB->pred_begin(), BB->pred_end());
 
   // Check to see if one of the predecessors of BB is already a predecessor of
   // Succ.  If so, we cannot do the transformation!
@@ -134,7 +134,7 @@
     Value *OldVal = PN->removeIncomingValue(BB);
     assert(OldVal && "No entry in PHI for Pred BB!");
 
-    for (vector<BasicBlock*>::const_iterator PredI = BBPreds.begin(), 
+    for (std::vector<BasicBlock*>::const_iterator PredI = BBPreds.begin(), 
 	   End = BBPreds.end(); PredI != End; ++PredI) {
       // Add an incoming value for each of the new incoming values...
       PN->addIncoming(OldVal, *PredI);
diff --git a/lib/Transforms/Scalar/IndVarSimplify.cpp b/lib/Transforms/Scalar/IndVarSimplify.cpp
index d03b4f3..35844ca 100644
--- a/lib/Transforms/Scalar/IndVarSimplify.cpp
+++ b/lib/Transforms/Scalar/IndVarSimplify.cpp
@@ -35,7 +35,7 @@
   // Transform all subloops before this loop...
   bool Changed = reduce_apply_bool(Loop->getSubLoops().begin(),
                                    Loop->getSubLoops().end(),
-                                   std::bind1st(ptr_fun(TransformLoop), Loops));
+                              std::bind1st(std::ptr_fun(TransformLoop), Loops));
   // Get the header node for this loop.  All of the phi nodes that could be
   // induction variables must live in this basic block.
   BasicBlock *Header = (BasicBlock*)Loop->getBlocks().front();
@@ -44,7 +44,7 @@
   // induction variables that they represent... stuffing the induction variable
   // info into a vector...
   //
-  vector<InductionVariable> IndVars;    // Induction variables for block
+  std::vector<InductionVariable> IndVars;    // Induction variables for block
   for (BasicBlock::iterator I = Header->begin(); 
        PHINode *PN = dyn_cast<PHINode>(*I); ++I)
     IndVars.push_back(InductionVariable(PN, Loops));
@@ -133,7 +133,7 @@
       Instruction *Val = IterCount;
       if (!isa<ConstantInt>(IV->Step) ||   // If the step != 1
           !cast<ConstantInt>(IV->Step)->equalsInt(1)) {
-        string Name;   // Create a scale by the step value...
+        std::string Name;   // Create a scale by the step value...
         if (IV->Phi->hasName()) Name = IV->Phi->getName()+"-scale";
 
         // If the types are not compatible, insert a cast now...
@@ -148,7 +148,7 @@
 
       if (!isa<Constant>(IV->Start) ||   // If the start != 0
           !cast<Constant>(IV->Start)->isNullValue()) {
-        string Name;   // Create a offset by the start value...
+        std::string Name;   // Create a offset by the start value...
         if (IV->Phi->hasName()) Name = IV->Phi->getName()+"-offset";
 
         // If the types are not compatible, insert a cast now...
@@ -170,7 +170,7 @@
       IV->Phi->replaceAllUsesWith(Val);
 
       // Move the PHI name to it's new equivalent value...
-      string OldName = IV->Phi->getName();
+      std::string OldName = IV->Phi->getName();
       IV->Phi->setName("");
       Val->setName(OldName);
 
diff --git a/lib/Transforms/Scalar/InductionVars.cpp b/lib/Transforms/Scalar/InductionVars.cpp
index d4b7bc5..93ab189 100644
--- a/lib/Transforms/Scalar/InductionVars.cpp
+++ b/lib/Transforms/Scalar/InductionVars.cpp
@@ -27,6 +27,8 @@
 #include "llvm/iPHINode.h"
 #include "Support/STLExtras.h"
 #include <algorithm>
+#include <iostream>
+using std::cerr;
 
 #include "llvm/Analysis/LoopDepth.h"
 
@@ -176,7 +178,7 @@
 // present induction variables (instead of always using uint)
 //
 static PHINode *InjectSimpleInductionVariable(cfg::Interval *Int) {
-  string PHIName, AddName;
+  std::string PHIName, AddName;
 
   BasicBlock *Header = Int->getHeaderNode();
   Method *M = Header->getParent();
@@ -205,7 +207,7 @@
   assert(++PI == Header->pred_end() && "Header node should have 2 preds!");
 
   // Make Pred1 be the loop entrance predecessor, Pred2 be the Loop predecessor
-  if (Int->contains(Pred1)) swap(Pred1, Pred2);
+  if (Int->contains(Pred1)) std::swap(Pred1, Pred2);
 
   assert(!Int->contains(Pred1) && "Pred1 should be loop entrance!");
   assert( Int->contains(Pred2) && "Pred2 should be looping edge!");
@@ -250,7 +252,7 @@
 static bool ProcessInterval(cfg::Interval *Int) {
   if (!Int->isLoop()) return false;  // Not a loop?  Ignore it!
 
-  vector<PHINode *> InductionVars;
+  std::vector<PHINode *> InductionVars;
 
   BasicBlock *Header = Int->getHeaderNode();
   // Loop over all of the PHI nodes in the interval header...
@@ -278,7 +280,7 @@
       if (isLoopInvariant(Int, V2)) {
 	// They *are* loop invariant.  Exchange BB1/BB2 and V1/V2 so that
 	// V1 is always the loop invariant computation.
-	swap(V1, V2); swap(BB1, BB2);
+	std::swap(V1, V2); std::swap(BB1, BB2);
       } else {
 	// Neither value is loop invariant.  Must not be an induction variable.
 	// This case can happen if there is an unreachable loop in the CFG that
@@ -292,7 +294,7 @@
     // anything about BB2/V2.  Check now to see if V2 is a linear induction
     // variable.
     //
-    cerr << "Found loop invariant computation: " << V1 << endl;
+    cerr << "Found loop invariant computation: " << V1 << "\n";
     
     if (!isLinearInductionVariable(Int, V2, PN))
       continue;         // No, it is not a linear ind var, ignore the PHI node.
@@ -308,7 +310,7 @@
   if (InductionVars.empty()) return false;
 
   // Search to see if there is already a "simple" induction variable.
-  vector<PHINode*>::iterator It = 
+  std::vector<PHINode*>::iterator It = 
     find_if(InductionVars.begin(), InductionVars.end(), isSimpleInductionVar);
   
   PHINode *PrimaryIndVar;
@@ -329,7 +331,7 @@
 	   "How could Primary IndVar not be in the header!?!!?");
 
     if (i != Header->begin())
-      iter_swap(i, Header->begin());
+      std::iter_swap(i, Header->begin());
   }
 
   // Now we know that there is a simple induction variable PrimaryIndVar.
@@ -364,7 +366,7 @@
   // variables in intervals that represent loops.
   //
   return reduce_apply(IP.begin(), IP.end(), bitwise_or<bool>(), false,
-		      ptr_fun(ProcessInterval));
+		      std::ptr_fun(ProcessInterval));
 }
 
 // DoInductionVariableCannonicalize - Simplify induction variables in loops.
diff --git a/lib/Transforms/Scalar/InstructionCombining.cpp b/lib/Transforms/Scalar/InstructionCombining.cpp
index 87f8ed1..795418f 100644
--- a/lib/Transforms/Scalar/InstructionCombining.cpp
+++ b/lib/Transforms/Scalar/InstructionCombining.cpp
@@ -76,7 +76,7 @@
     dyn_cast<GetElementPtrInst>(MAI->getPointerOperand());
   if (!Src) return 0;
 
-  vector<Value *> Indices;
+  std::vector<Value *> Indices;
   
   // Only special case we have to watch out for is pointer arithmetic on the
   // 0th index of MAI. 
@@ -128,7 +128,7 @@
 
 bool InstructionCombining::doit(Method *M) {
   // Start the worklist out with all of the instructions in the method in it.
-  vector<Instruction*> WorkList(M->inst_begin(), M->inst_end());
+  std::vector<Instruction*> WorkList(M->inst_begin(), M->inst_end());
 
   while (!WorkList.empty()) {
     Instruction *I = WorkList.back();  // Get an instruction from the worklist
diff --git a/lib/Transforms/Scalar/SCCP.cpp b/lib/Transforms/Scalar/SCCP.cpp
index 26a52d6..68be844 100644
--- a/lib/Transforms/Scalar/SCCP.cpp
+++ b/lib/Transforms/Scalar/SCCP.cpp
@@ -30,6 +30,8 @@
 #include <algorithm>
 #include <map>
 #include <set>
+#include <iostream>
+using std::cerr;
 
 // InstVal class - This class represents the different lattice values that an 
 // instruction may occupy.  It is a simple class with value semantics.  The
@@ -84,13 +86,13 @@
 // It's public interface consists of a constructor and a doSCCP() method.
 //
 class SCCP {
-  Method *M;                            // The method that we are working on...
+  Method *M;                             // The method that we are working on...
 
-  set<BasicBlock*>       BBExecutable;  // The basic blocks that are executable
-  map<Value*, InstVal>   ValueState;    // The state each value is in...
+  std::set<BasicBlock*>     BBExecutable;// The basic blocks that are executable
+  std::map<Value*, InstVal> ValueState;  // The state each value is in...
 
-  vector<Instruction*>   InstWorkList;  // The instruction work list
-  vector<BasicBlock*>    BBWorkList;    // The BasicBlock work list
+  std::vector<Instruction*> InstWorkList;// The instruction work list
+  std::vector<BasicBlock*>  BBWorkList;  // The BasicBlock work list
 
   //===--------------------------------------------------------------------===//
   // The public interface for this class
@@ -144,7 +146,7 @@
   // Instruction object, then use this accessor to get its value from the map.
   //
   inline InstVal &getValueState(Value *V) {
-    map<Value*, InstVal>::iterator I = ValueState.find(V);
+    std::map<Value*, InstVal>::iterator I = ValueState.find(V);
     if (I != ValueState.end()) return I->second;  // Common case, in the map
       
     if (Constant *CPV = dyn_cast<Constant>(V)) {  // Constants are constant
diff --git a/lib/Transforms/Scalar/SymbolStripping.cpp b/lib/Transforms/Scalar/SymbolStripping.cpp
index bb4f01c..417376b 100644
--- a/lib/Transforms/Scalar/SymbolStripping.cpp
+++ b/lib/Transforms/Scalar/SymbolStripping.cpp
@@ -24,7 +24,7 @@
   bool RemovedSymbol = false;
 
   for (SymbolTable::iterator I = SymTab->begin(); I != SymTab->end(); ++I) {
-    map<const string, Value *> &Plane = I->second;
+    std::map<const std::string, Value *> &Plane = I->second;
     
     SymbolTable::type_iterator B;
     while ((B = Plane.begin()) != Plane.end()) {   // Found nonempty type plane!