Print variable's display name in dwarf DIE.
[oota-llvm.git] / lib / VMCore / TypeSymbolTable.cpp
index 6cc1055ebce20d307d0cc9b21c485c8fcebaa253..475d71949ff566b76029899fb05f33fba9ae7691 100644 (file)
@@ -2,8 +2,8 @@
 //
 //                     The LLVM Compiler Infrastructure
 //
-// This file was developed by Reid Spencer. It is distributed under the 
-// University of Illinois Open Source License. See LICENSE.TXT for details.
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
 //
 //===----------------------------------------------------------------------===//
 //
@@ -47,17 +47,6 @@ Type* TypeSymbolTable::lookup(const std::string& Name) const {
   return 0;
 }
 
-// Erase a specific type from the symbol table
-bool TypeSymbolTable::remove(Type *N) {
-  for (iterator TI = tmap.begin(), TE = tmap.end(); TI != TE; ++TI) {
-    if (TI->second == N) {
-      this->remove(TI);
-      return true;
-    }
-  }
-  return false;
-}
-
 // remove - Remove a type from the symbol table...
 Type* TypeSymbolTable::remove(iterator Entry) {
   assert(Entry != tmap.end() && "Invalid entry to remove!");
@@ -75,7 +64,9 @@ Type* TypeSymbolTable::remove(iterator Entry) {
   // list...
   if (Result->isAbstract()) {
 #if DEBUG_ABSTYPE
-    cerr << "Removing abstract type from symtab" << Result->getDescription()<<"\n";
+    cerr << "Removing abstract type from symtab"
+         << Result->getDescription()
+         << "\n";
 #endif
     cast<DerivedType>(Result)->removeAbstractTypeUser(this);
   }
@@ -88,19 +79,30 @@ Type* TypeSymbolTable::remove(iterator Entry) {
 void TypeSymbolTable::insert(const std::string& Name, const Type* T) {
   assert(T && "Can't insert null type into symbol table!");
 
-  // Check to see if there is a naming conflict.  If so, rename this type!
-  std::string UniqueName = Name;
-  if (lookup(Name))
-    UniqueName = getUniqueName(Name);
-
+  if (tmap.insert(make_pair(Name, T)).second) {
+    // Type inserted fine with no conflict.
+    
 #if DEBUG_SYMBOL_TABLE
-  dump();
-  cerr << " Inserting type: " << UniqueName << ": "
-       << T->getDescription() << "\n";
+    dump();
+    cerr << " Inserted type: " << Name << ": " << T->getDescription() << "\n";
+#endif
+  } else {
+    // If there is a name conflict...
+    
+    // Check to see if there is a naming conflict.  If so, rename this type!
+    std::string UniqueName = Name;
+    if (lookup(Name))
+      UniqueName = getUniqueName(Name);
+    
+#if DEBUG_SYMBOL_TABLE
+    dump();
+    cerr << " Inserting type: " << UniqueName << ": "
+        << T->getDescription() << "\n";
 #endif
 
-  // Insert the tmap entry
-  tmap.insert(make_pair(UniqueName, T));
+    // Insert the tmap entry
+    tmap.insert(make_pair(UniqueName, T));
+  }
 
   // If we are adding an abstract type, add the symbol table to it's use list.
   if (T->isAbstract()) {
@@ -111,17 +113,6 @@ void TypeSymbolTable::insert(const std::string& Name, const Type* T) {
   }
 }
 
-// Strip the symbol table of its names.
-bool TypeSymbolTable::strip() {
-  bool RemovedSymbol = false;
-  for (iterator TI = tmap.begin(); TI != tmap.end(); ) {
-    remove(TI++);
-    RemovedSymbol = true;
-  }
-
-  return RemovedSymbol;
-}
-
 // This function is called when one of the types in the type plane are refined
 void TypeSymbolTable::refineAbstractType(const DerivedType *OldType,
                                          const Type *NewType) {