[lld] r231618 - Resolver: Fix incorrect DenseMap mapping info.

Rui Ueyama ruiu at google.com
Sun Mar 8 19:00:54 PDT 2015


Author: ruiu
Date: Sun Mar  8 21:00:54 2015
New Revision: 231618

URL: http://llvm.org/viewvc/llvm-project?rev=231618&view=rev
Log:
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.

Modified:
    lld/trunk/include/lld/Core/SymbolTable.h

Modified: lld/trunk/include/lld/Core/SymbolTable.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/include/lld/Core/SymbolTable.h?rev=231618&r1=231617&r2=231618&view=diff
==============================================================================
--- lld/trunk/include/lld/Core/SymbolTable.h (original)
+++ lld/trunk/include/lld/Core/SymbolTable.h Sun Mar  8 21:00:54 2015
@@ -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<StringRef, const Atom *,
                                            StringRefMappingInfo> NameToAtom;





More information about the llvm-commits mailing list