diff options
-rw-r--r-- | include/llvm/SymbolTable.h | 6 | ||||
-rw-r--r-- | lib/VMCore/SymbolTable.cpp | 5 |
2 files changed, 7 insertions, 4 deletions
diff --git a/include/llvm/SymbolTable.h b/include/llvm/SymbolTable.h index f457255f3b..42f15aa626 100644 --- a/include/llvm/SymbolTable.h +++ b/include/llvm/SymbolTable.h @@ -36,7 +36,7 @@ public: typedef VarMap::iterator type_iterator; typedef VarMap::const_iterator type_const_iterator; - inline SymbolTable() : InternallyInconsistent(false) {} + inline SymbolTable() : InternallyInconsistent(false), LastUnique(0) {} ~SymbolTable(); // lookup - Returns null on failure... @@ -109,6 +109,10 @@ private: // bool InternallyInconsistent; + // LastUnique - This value is used to retain the last unique value used + // by getUniqueName to generate unique names. + unsigned long LastUnique; + inline super::value_type operator[](const Type *Ty) { assert(0 && "Should not use this operator to access symbol table!"); return super::value_type(); diff --git a/lib/VMCore/SymbolTable.cpp b/lib/VMCore/SymbolTable.cpp index a6b9a0007b..9452cdfec4 100644 --- a/lib/VMCore/SymbolTable.cpp +++ b/lib/VMCore/SymbolTable.cpp @@ -61,11 +61,10 @@ std::string SymbolTable::getUniqueName(const Type *Ty, 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; } |