-//===-- SymbolTable.cpp - Implement the SymbolTable class -------------------=//
+//===-- 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.
//
#include "llvm/Module.h"
#include "Support/StringExtras.h"
#include <algorithm>
+using namespace llvm;
#define DEBUG_SYMBOL_TABLE 0
#define DEBUG_ABSTYPE 0
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;
}
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);