- Eliminate SymbolTable::ParentSymTab, ST::localLookup, and
authorChris Lattner <sabre@nondot.org>
Tue, 15 Oct 2002 21:26:29 +0000 (21:26 +0000)
committerChris Lattner <sabre@nondot.org>
Tue, 15 Oct 2002 21:26:29 +0000 (21:26 +0000)
    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

include/llvm/Function.h
include/llvm/SymbolTable.h
lib/VMCore/Function.cpp
lib/VMCore/Module.cpp
lib/VMCore/SymbolTable.cpp

index 87e6bad48a330608c252493690a1d16fe16159af..bb2c3ca99672336cbdf442a032a294e360fc1ce7 100644 (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>;
 
index 8762b4b5819d741864e9544e4e282fe490fb4b88..7e7cb51f20ae10ff9ea525cd966c83dd3bc7bfb7 100644 (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!");
index d03a72a81ab88364aa0c390e8d3bdc44d6e1958c..5edd9ae2a6913e77218aa573327fbc92ae8b752a 100644 (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;
 }
 
index 4bd3a884b308674aecc7237dc3c4a6bb1b710652..397b5e28341d5cae70373ff37d2c2297978392d9 100644 (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;
 }
 
index 6d09c7d5669803f6bbde739236faf0314bcf0efe..069f7111019abcb3d0c5f253edb0aead3d95140b 100644 (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();
-  }
 }