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/IPO/ConstantMerge.cpp b/lib/Transforms/IPO/ConstantMerge.cpp
index 70e3437..ff2442d 100644
--- a/lib/Transforms/IPO/ConstantMerge.cpp
+++ b/lib/Transforms/IPO/ConstantMerge.cpp
@@ -23,7 +23,7 @@
 //
 static inline 
 bool mergeDuplicateConstants(Module *M, unsigned &ConstantNo,
-                             map<Constant*, GlobalVariable*> &CMap) {
+                             std::map<Constant*, GlobalVariable*> &CMap) {
   Module::GlobalListType &GList = M->getGlobalList();
   if (GList.size() <= ConstantNo) return false;   // No new constants
   bool MadeChanges = false;
@@ -35,10 +35,10 @@
       Constant *Init = GV->getInitializer();
 
       // Check to see if the initializer is already known...
-      map<Constant*, GlobalVariable*>::iterator I = CMap.find(Init);
+      std::map<Constant*, GlobalVariable*>::iterator I = CMap.find(Init);
 
       if (I == CMap.end()) {    // Nope, add it to the map
-        CMap.insert(make_pair(Init, GV));
+        CMap.insert(std::make_pair(Init, GV));
       } else {                  // Yup, this is a duplicate!
         // Make all uses of the duplicate constant use the cannonical version...
         GV->replaceAllUsesWith(I->second);
@@ -59,7 +59,7 @@
 // deal with passes.
 //
 bool ConstantMerge::mergeDuplicateConstants(Module *M) {
-  map<Constant*, GlobalVariable*> Constants;
+  std::map<Constant*, GlobalVariable*> Constants;
   unsigned LastConstantSeen = 0;
   return ::mergeDuplicateConstants(M, LastConstantSeen, Constants);
 }
diff --git a/lib/Transforms/IPO/DeadTypeElimination.cpp b/lib/Transforms/IPO/DeadTypeElimination.cpp
index ec4c3fd..d5e9ea0 100644
--- a/lib/Transforms/IPO/DeadTypeElimination.cpp
+++ b/lib/Transforms/IPO/DeadTypeElimination.cpp
@@ -23,6 +23,10 @@
 #include "llvm/iTerminators.h"
 #include "llvm/iOther.h"
 #include <algorithm>
+#include <iostream>
+using std::vector;
+using std::string;
+using std::cerr;
 
 static const Type *PtrSByte = 0;    // 'sbyte*' type
 
@@ -78,7 +82,7 @@
   SymbolTable *ST = M->getSymbolTable();
   if (!ST) return false;
 
-  map<string, vector<Method*> > Methods;
+  std::map<string, vector<Method*> > Methods;
 
   // Loop over the entries in the symbol table. If an entry is a method pointer,
   // then add it to the Methods map.  We do a two pass algorithm here to avoid
@@ -86,7 +90,7 @@
   //
   for (SymbolTable::iterator I = ST->begin(), E = ST->end(); I != E; ++I)
     if (const PointerType *PT = dyn_cast<PointerType>(I->first))
-      if (const MethodType *MT = dyn_cast<MethodType>(PT->getElementType())) {
+      if (isa<MethodType>(PT->getElementType())) {
         SymbolTable::VarMap &Plane = I->second;
         for (SymbolTable::type_iterator PI = Plane.begin(), PE = Plane.end();
              PI != PE; ++PI) {
@@ -101,7 +105,7 @@
   // Now we have a list of all methods with a particular name.  If there is more
   // than one entry in a list, merge the methods together.
   //
-  for (map<string, vector<Method*> >::iterator I = Methods.begin(), 
+  for (std::map<string, vector<Method*> >::iterator I = Methods.begin(), 
          E = Methods.end(); I != E; ++I) {
     vector<Method*> &Methods = I->second;
     Method *Implementation = 0;     // Find the implementation
@@ -145,7 +149,7 @@
         cerr << "Warning: Found methods types that are not compatible:\n";
         for (unsigned i = 0; i < Methods.size(); ++i) {
           cerr << "\t" << Methods[i]->getType()->getDescription() << " %"
-               << Methods[i]->getName() << endl;
+               << Methods[i]->getName() << "\n";
         }
         cerr << "  No linkage of methods named '" << Methods[0]->getName()
              << "' performed!\n";
@@ -185,7 +189,7 @@
                   ++i;
                 }
               } else {
-                cerr << "Cannot convert use of method: " << U << endl;
+                cerr << "Cannot convert use of method: " << U << "\n";
                 ++i;
               }
             }
@@ -201,7 +205,7 @@
 // ShouldNukSymtabEntry - Return true if this module level symbol table entry
 // should be eliminated.
 //
-static inline bool ShouldNukeSymtabEntry(const pair<string, Value*> &E) {
+static inline bool ShouldNukeSymtabEntry(const std::pair<string, Value*> &E) {
   // Nuke all names for primitive types!
   if (cast<Type>(E.second)->isPrimitiveType()) return true;
 
@@ -357,8 +361,8 @@
       Value *Src = CI->getOperand(0);
 
       // Move the cast instruction to the current insert position...
-      --InsertPos;            // New position for cast to go...
-      swap(*InsertPos, *I);   // Cast goes down, PHI goes up
+      --InsertPos;                 // New position for cast to go...
+      std::swap(*InsertPos, *I);   // Cast goes down, PHI goes up
 
       if (isa<PHINode>(Src) &&                                // Handle case #1
           cast<PHINode>(Src)->getParent() == BB) {
@@ -561,7 +565,7 @@
 
   if (M->hasSymbolTable()) {
     SymbolTable *ST = M->getSymbolTable();
-    const set<const Type *> &UsedTypes = FUT.getTypes();
+    const std::set<const Type *> &UsedTypes = FUT.getTypes();
 
     // Check the symbol table for superfluous type entries that aren't used in
     // the program
diff --git a/lib/Transforms/IPO/GlobalDCE.cpp b/lib/Transforms/IPO/GlobalDCE.cpp
index 7395bab..dacd329 100644
--- a/lib/Transforms/IPO/GlobalDCE.cpp
+++ b/lib/Transforms/IPO/GlobalDCE.cpp
@@ -18,14 +18,14 @@
   // Calculate which methods are reachable from the external methods in the call
   // graph.
   //
-  set<cfg::CallGraphNode*> ReachableNodes(df_begin(&CallGraph),
-					  df_end(&CallGraph));
+  std::set<cfg::CallGraphNode*> ReachableNodes(df_begin(&CallGraph),
+                                               df_end(&CallGraph));
 
   // Loop over the methods in the module twice.  The first time is used to drop
   // references that methods have to each other before they are deleted.  The
   // second pass removes the methods that need to be removed.
   //
-  vector<cfg::CallGraphNode*> MethodsToDelete;   // Track unused methods
+  std::vector<cfg::CallGraphNode*> MethodsToDelete;   // Track unused methods
   for (Module::iterator I = M->begin(), E = M->end(); I != E; ++I) {
     cfg::CallGraphNode *N = CallGraph[*I];
     if (!ReachableNodes.count(N)) {              // Not reachable??
@@ -45,7 +45,7 @@
   // Unreachables methods have been found and should have no references to them,
   // delete them now.
   //
-  for (vector<cfg::CallGraphNode*>::iterator I = MethodsToDelete.begin(),
+  for (std::vector<cfg::CallGraphNode*>::iterator I = MethodsToDelete.begin(),
 	 E = MethodsToDelete.end(); I != E; ++I)
     delete CallGraph.removeMethodFromModule(*I);
 
diff --git a/lib/Transforms/IPO/InlineSimple.cpp b/lib/Transforms/IPO/InlineSimple.cpp
index 40b98bd..9d86c86 100644
--- a/lib/Transforms/IPO/InlineSimple.cpp
+++ b/lib/Transforms/IPO/InlineSimple.cpp
@@ -27,6 +27,8 @@
 #include "llvm/iOther.h"
 #include <algorithm>
 #include <map>
+#include <iostream>
+using std::cerr;
 
 #include "llvm/Assembly/Writer.h"
 
@@ -36,7 +38,7 @@
 // current values into those specified by ValueMap.
 //
 static inline void RemapInstruction(Instruction *I, 
-				    map<const Value *, Value*> &ValueMap) {
+				    std::map<const Value *, Value*> &ValueMap) {
 
   for (unsigned op = 0, E = I->getNumOperands(); op != E; ++op) {
     const Value *Op = I->getOperand(op);
@@ -45,8 +47,8 @@
       continue;  // Globals and constants don't get relocated
 
     if (!V) {
-      cerr << "Val = " << endl << Op << "Addr = " << (void*)Op << endl;
-      cerr << "Inst = " << I;
+      cerr << "Val = \n" << Op << "Addr = " << (void*)Op;
+      cerr << "\nInst = " << I;
     }
     assert(V && "Referenced value not in value map!");
     I->setOperand(op, V);
@@ -72,10 +74,9 @@
   const Method *CalledMeth = CI->getCalledMethod();
   if (CalledMeth == 0 ||   // Can't inline external method or indirect call!
       CalledMeth->isExternal()) return false;
-  Method *CurrentMeth = CI->getParent()->getParent();
 
   //cerr << "Inlining " << CalledMeth->getName() << " into " 
-  //     << CurrentMeth->getName() << endl;
+  //     << CurrentMeth->getName() << "\n";
 
   BasicBlock *OrigBB = CI->getParent();
 
@@ -111,7 +112,7 @@
   // code's values.  This includes all of: Method arguments, instruction values,
   // constant pool entries, and basic blocks.
   //
-  map<const Value *, Value*> ValueMap;
+  std::map<const Value *, Value*> ValueMap;
 
   // Add the method arguments to the mapping: (start counting at 1 to skip the
   // method reference itself)
diff --git a/lib/Transforms/IPO/MutateStructTypes.cpp b/lib/Transforms/IPO/MutateStructTypes.cpp
index c91c00c..df2b67e 100644
--- a/lib/Transforms/IPO/MutateStructTypes.cpp
+++ b/lib/Transforms/IPO/MutateStructTypes.cpp
@@ -21,6 +21,9 @@
 #include "llvm/iTerminators.h"
 #include "llvm/iOther.h"
 #include <algorithm>
+using std::map;
+using std::make_pair;
+using std::vector;
 
 // To enable debugging, uncomment this...
 //#define DEBUG_MST(x) x
@@ -37,7 +40,7 @@
 struct ValuePlaceHolder : public Instruction {
   ValuePlaceHolder(const Type *Ty) : Instruction(Ty, UserOp1, "") {}
 
-  virtual Instruction *clone() const { abort(); }
+  virtual Instruction *clone() const { abort(); return 0; }
   virtual const char *getOpcodeName() const { return "placeholder"; }
 };
 
@@ -291,8 +294,8 @@
 // of the methods and global variables that we no longer need.
 bool MutateStructTypes::doPassFinalization(Module *M) {
   // The first half of the methods in the module have to go.
-  unsigned NumMethods = M->size();
-  unsigned NumGVars   = M->gsize();
+  //unsigned NumMethods = M->size();
+  //unsigned NumGVars   = M->gsize();
 
   // Prepare for deletion of globals by dropping their interdependencies...
   for(Module::iterator I = M->begin(); I != M->end(); ++I) {
@@ -436,12 +439,11 @@
           AdjustIndices(cast<CompositeType>(PTy), Indices);
         }
 
-        if (const LoadInst *LI = dyn_cast<LoadInst>(I)) {
+        if (isa<LoadInst>(I)) {
           NewI = new LoadInst(NewPtr, Indices);
-        } else if (const StoreInst *SI = dyn_cast<StoreInst>(I)) {
+        } else if (isa<StoreInst>(I)) {
           NewI = new StoreInst(ConvertValue(I->getOperand(0)), NewPtr, Indices);
-        } else if (const GetElementPtrInst *GEP =
-                   dyn_cast<GetElementPtrInst>(I)) {
+        } else if (isa<GetElementPtrInst>(I)) {
           NewI = new GetElementPtrInst(NewPtr, Indices);
         } else {
           assert(0 && "Unknown memory access inst!!!");
diff --git a/lib/Transforms/IPO/SimpleStructMutation.cpp b/lib/Transforms/IPO/SimpleStructMutation.cpp
index d938545..d0b8bb2 100644
--- a/lib/Transforms/IPO/SimpleStructMutation.cpp
+++ b/lib/Transforms/IPO/SimpleStructMutation.cpp
@@ -12,9 +12,14 @@
 #include "llvm/Analysis/FindUnsafePointerTypes.h"
 #include "TransformInternals.h"
 #include <algorithm>
+#include <iostream>
+using std::vector;
+using std::set;
+using std::pair;
 
 #include "llvm/Assembly/Writer.h"
 
+
 // PruneTypes - Given a type Ty, make sure that neither it, or one of its
 // subtypes, occur in TypesToModify.
 //
@@ -26,7 +31,7 @@
   // If the element is in TypesToModify, remove it now...
   if (const StructType *ST = dyn_cast<StructType>(Ty)) {
     TypesToModify.erase(ST);  // This doesn't fail if the element isn't present
-    cerr << "Unable to swap type: " << ST << endl;
+    std::cerr << "Unable to swap type: " << ST << "\n";
   }
 
   // Remove all types that this type contains as well... do not remove types
@@ -69,7 +74,8 @@
 
     // Build mapping from index to size
     for (unsigned i = 0; i < NumElements; ++i)
-      ElList.push_back(make_pair(i, TD.getTypeSize(ST->getElementTypes()[i])));
+      ElList.push_back(
+              std::make_pair(i, TD.getTypeSize(ST->getElementTypes()[i])));
 
     sort(ElList.begin(), ElList.end(), ptr_fun(FirstLess));
 
@@ -118,14 +124,14 @@
   set<const Type*> ProcessedTypes;
   for (set<PointerType*>::const_iterator I = UnsafePTys.begin(),
          E = UnsafePTys.end(); I != E; ++I) {
-    //cerr << "Pruning type: " << *I << endl;
+    //cerr << "Pruning type: " << *I << "\n";
     PruneTypes(*I, TypesToModify, ProcessedTypes);
   }
 
 
   // Build up a set of structure types that we are going to modify, and
   // information describing how to modify them.
-  map<const StructType*, vector<int> > Transforms;
+  std::map<const StructType*, vector<int> > Transforms;
 
   for (set<const StructType*>::iterator I = TypesToModify.begin(),
          E = TypesToModify.end(); I != E; ++I) {