If a name conflict occurs when inserting a value, rename it.
authorChris Lattner <sabre@nondot.org>
Mon, 26 Nov 2001 17:01:18 +0000 (17:01 +0000)
committerChris Lattner <sabre@nondot.org>
Mon, 26 Nov 2001 17:01:18 +0000 (17:01 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@1346 91177308-0d34-0410-b5e6-96231b3b80d8

lib/VMCore/SymbolTable.cpp

index 8d6df2c787e56f2d348f91d88d4b40ec22b35ba7..b8da428a2cb404f7c62bd827d46528c7079b48a3 100644 (file)
@@ -133,9 +133,14 @@ Value *SymbolTable::removeEntry(iterator Plane, type_iterator Entry) {
 // name...
 //
 void SymbolTable::insertEntry(const string &Name, const Type *VTy, Value *V) {
-  // TODO: The typeverifier should catch this when its implemented
-  assert(lookup(VTy, Name) == 0 && 
-        "SymbolTable::insertEntry - Name already in symbol table!");
+  // Check to see if there is a naming conflict.  If so, rename this value!
+  if (lookup(VTy, Name)) {
+    string UniqueName = getUniqueName(VTy, Name);
+    InternallyInconsistent = true;
+    V->setName(UniqueName, this);
+    InternallyInconsistent = false;
+    return;
+  }
 
 #if DEBUG_SYMBOL_TABLE
   cerr << this << " Inserting definition: " << Name << ": "