From 4cefbd8b7209d1b82c4c811ecd6421f516b93107 Mon Sep 17 00:00:00 2001 From: Rui Ueyama Date: Mon, 9 Mar 2015 02:00:54 +0000 Subject: [PATCH] Resolver: Fix incorrect DenseMap mapping info. Previously, getEmptyKey and getTombstoneKey return the same value in the sense of isEqual defined by the same class, although they need to be distinct values. This could confuse DenseMap. We didn't see any issue by this wrong code because we don't delete elements from the symbol table. We only add or replace elements. But this is a bug and needs to be fixed anyway. llvm-svn: 231618 --- lld/include/lld/Core/SymbolTable.h | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/lld/include/lld/Core/SymbolTable.h b/lld/include/lld/Core/SymbolTable.h index f218c6e..683ed65 100644 --- a/lld/include/lld/Core/SymbolTable.h +++ b/lld/include/lld/Core/SymbolTable.h @@ -82,11 +82,13 @@ private: struct StringRefMappingInfo { static StringRef getEmptyKey() { return StringRef(); } - static StringRef getTombstoneKey() { return StringRef(" ", 0); } + static StringRef getTombstoneKey() { return StringRef(" ", 1); } static unsigned getHashValue(StringRef const val) { - return llvm::HashString(val); } - static bool isEqual(StringRef const lhs, - StringRef const rhs) { return lhs.equals(rhs); } + return llvm::HashString(val); + } + static bool isEqual(StringRef const lhs, StringRef const rhs) { + return lhs.equals(rhs); + } }; typedef llvm::DenseMap NameToAtom; -- 2.7.4