- Eliminate SymbolTable::ParentSymTab, ST::localLookup, and

Function::ParentSymTab.  These aren't needed at all.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@4186 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Chris Lattner 2002-10-15 21:26:29 +00:00
parent 1b7de965dd
commit 0dad6e9c95
5 changed files with 7 additions and 40 deletions

View File

@ -57,7 +57,7 @@ private:
BasicBlockListType BasicBlocks; // The basic blocks
ArgumentListType ArgumentList; // The formal arguments
SymbolTable *SymTab, *ParentSymTab;
SymbolTable *SymTab;
friend class SymbolTableListTraits<Function, Module, Module>;

View File

@ -25,33 +25,16 @@ class SymbolTable : public AbstractTypeUser,
public:
typedef std::map<const std::string, Value *> VarMap;
typedef std::map<const Type *, VarMap> super;
private:
SymbolTable *ParentSymTab;
friend class Function;
inline void setParentSymTab(SymbolTable *P) { ParentSymTab = P; }
public:
typedef VarMap::iterator type_iterator;
typedef VarMap::const_iterator type_const_iterator;
inline SymbolTable(SymbolTable *P = 0) {
ParentSymTab = P;
InternallyInconsistent = false;
}
inline SymbolTable() : InternallyInconsistent(false) {}
~SymbolTable();
SymbolTable *getParentSymTab() { return ParentSymTab; }
// lookup - Returns null on failure...
Value *lookup(const Type *Ty, const std::string &name);
// localLookup - Look in this symbol table without falling back on parent,
// if non-existing. Returns null on failure...
//
Value *localLookup(const Type *Ty, const std::string &name);
// insert - Add named definition to the symbol table...
inline void insert(Value *N) {
assert(N->hasName() && "Value must be named to go into symbol table!");

View File

@ -84,7 +84,7 @@ Function::Function(const FunctionType *Ty, bool isInternal,
BasicBlocks.setParent(this);
ArgumentList.setItemParent(this);
ArgumentList.setParent(this);
ParentSymTab = SymTab = 0;
SymTab = 0;
// Create the arguments vector, all arguments start out unnamed.
for (unsigned i = 0, e = Ty->getNumParams(); i != e; ++i) {
@ -127,10 +127,6 @@ void Function::setParent(Module *parent) {
Parent = parent;
if (getParent())
LeakDetector::removeGarbageObject(this);
// Relink symbol tables together...
ParentSymTab = Parent ? Parent->getSymbolTableSure() : 0;
if (SymTab) SymTab->setParentSymTab(ParentSymTab);
}
const FunctionType *Function::getFunctionType() const {
@ -142,7 +138,7 @@ const Type *Function::getReturnType() const {
}
SymbolTable *Function::getSymbolTableSure() {
if (!SymTab) SymTab = new SymbolTable(ParentSymTab);
if (!SymTab) SymTab = new SymbolTable();
return SymTab;
}

View File

@ -75,7 +75,7 @@ void Module::dump() const {
}
SymbolTable *Module::getSymbolTableSure() {
if (!SymTab) SymTab = new SymbolTable(0);
if (!SymTab) SymTab = new SymbolTable();
return SymTab;
}

View File

@ -72,7 +72,7 @@ string SymbolTable::getUniqueName(const Type *Ty, const string &BaseName) {
// lookup - Returns null on failure...
Value *SymbolTable::localLookup(const Type *Ty, const string &Name) {
Value *SymbolTable::lookup(const Type *Ty, const string &Name) {
iterator I = find(Ty);
if (I != end()) { // We have symbols in that plane...
type_iterator J = I->second.find(Name);
@ -83,13 +83,6 @@ Value *SymbolTable::localLookup(const Type *Ty, const string &Name) {
return 0;
}
// lookup - Returns null on failure...
Value *SymbolTable::lookup(const Type *Ty, const string &Name) {
Value *LV = localLookup(Ty, Name);
if (LV) return LV;
return ParentSymTab ? ParentSymTab->lookup(Ty, Name) : 0;
}
void SymbolTable::remove(Value *N) {
assert(N->hasName() && "Value doesn't have name!");
if (InternallyInconsistent) return;
@ -154,7 +147,7 @@ Value *SymbolTable::removeEntry(iterator Plane, type_iterator Entry) {
void SymbolTable::insertEntry(const string &Name, const Type *VTy, Value *V) {
// Check to see if there is a naming conflict. If so, rename this value!
if (localLookup(VTy, Name)) {
if (lookup(VTy, Name)) {
string UniqueName = getUniqueName(VTy, Name);
assert(InternallyInconsistent == false && "Infinite loop inserting entry!");
InternallyInconsistent = true;
@ -339,9 +332,4 @@ static void DumpPlane(const pair<const Type *, map<const string, Value *> >&P) {
void SymbolTable::dump() const {
std::cout << "Symbol table dump:\n";
for_each(begin(), end(), DumpPlane);
if (ParentSymTab) {
std::cout << "Parent ";
ParentSymTab->dump();
}
}