Remove obsolete method
[oota-llvm.git] / lib / VMCore / SymbolTable.cpp
index 6812f699d5fefe259e05143b088337cbce276412..be1459e70b713261f7f84284a079635a72a0ede2 100644 (file)
@@ -1,4 +1,11 @@
 //===-- SymbolTable.cpp - Implement the SymbolTable class -----------------===//
+// 
+//                     The LLVM Compiler Infrastructure
+//
+// This file was developed by the LLVM research group and is distributed under
+// the University of Illinois Open Source License. See LICENSE.TXT for details.
+// 
+//===----------------------------------------------------------------------===//
 //
 // This file implements the SymbolTable class for the VMCore library.
 //
@@ -9,6 +16,7 @@
 #include "llvm/Module.h"
 #include "Support/StringExtras.h"
 #include <algorithm>
+using namespace llvm;
 
 #define DEBUG_SYMBOL_TABLE 0
 #define DEBUG_ABSTYPE 0
@@ -54,21 +62,20 @@ std::string SymbolTable::getUniqueName(const Type *Ty,
   if (I == end()) return BaseName;
 
   std::string TryName = BaseName;
-  unsigned Counter = 0;
   type_iterator End = I->second.end();
 
-  while (I->second.find(TryName) != End)     // Loop until we find unoccupied
-    TryName = BaseName + utostr(++Counter);  // Name in the symbol table
+  while (I->second.find(TryName) != End)       // Loop until we find a free
+    TryName = BaseName + utostr(++LastUnique); // name in the symbol table
   return TryName;
 }
 
 
 
 // lookup - Returns null on failure...
-Value *SymbolTable::lookup(const Type *Ty, const std::string &Name) {
-  iterator I = find(Ty);
+Value *SymbolTable::lookup(const Type *Ty, const std::string &Name) const {
+  const_iterator I = find(Ty);
   if (I != end()) {                      // We have symbols in that plane...
-    type_iterator J = I->second.find(Name);
+    type_const_iterator J = I->second.find(Name);
     if (J != I->second.end())            // and the name is in our hash table...
       return J->second;
   }
@@ -263,6 +270,13 @@ void SymbolTable::refineAbstractType(const DerivedType *OldType,
           else
             M->getGlobalList().remove(cast<GlobalVariable>(NewGV));
           delete NewGV;
+        } else {
+          // If they are not global values, they must be just random values who
+          // happen to conflict now that types have been resolved.  If this is
+          // the case, reinsert the value into the new plane, allowing it to get
+          // renamed.
+          assert(V.second->getType() == NewType &&"Type resolution is broken!");
+          insert(V.second);
         }
       } else {
         insertEntry(V.first, NewType, V.second);