[Lldb-commits] [lldb] 371dacd - [lldb] Remove unused DenseMapInfo::getEmptyKey (#201990)

via lldb-commits lldb-commits at lists.llvm.org
Sat Jun 6 12:53:56 PDT 2026


Author: Fangrui Song
Date: 2026-06-06T12:53:51-07:00
New Revision: 371dacd08ea3f58b8d615bc25a726c81cbabcb99

URL: https://github.com/llvm/llvm-project/commit/371dacd08ea3f58b8d615bc25a726c81cbabcb99
DIFF: https://github.com/llvm/llvm-project/commit/371dacd08ea3f58b8d615bc25a726c81cbabcb99.diff

LOG: [lldb] Remove unused DenseMapInfo::getEmptyKey (#201990)

After #201281 DenseMapInfo<T>::getEmptyKey() is no longer used by
DenseMap. Remove the unused getEmptyKey definitions and dead sentinel
uses.

Added: 
    

Modified: 
    lldb/include/lldb/Core/Highlighter.h
    lldb/include/lldb/Host/HostThread.h
    lldb/include/lldb/Symbol/SymbolContext.h
    lldb/include/lldb/Utility/ConstString.h
    lldb/include/lldb/Utility/FileSpec.h
    lldb/include/lldb/Utility/UUID.h
    lldb/source/Plugins/LanguageRuntime/ObjC/ObjCLanguageRuntime.h
    lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.h
    lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp

Removed: 
    


################################################################################
diff  --git a/lldb/include/lldb/Core/Highlighter.h b/lldb/include/lldb/Core/Highlighter.h
index 5384309088b8d..db3c02a017ab0 100644
--- a/lldb/include/lldb/Core/Highlighter.h
+++ b/lldb/include/lldb/Core/Highlighter.h
@@ -156,9 +156,6 @@ namespace llvm {
 /// DenseMapInfo implementation.
 /// \{
 template <> struct DenseMapInfo<lldb::LanguageType> {
-  static inline lldb::LanguageType getEmptyKey() {
-    return lldb::eNumLanguageTypes;
-  }
   static unsigned getHashValue(lldb::LanguageType language_type) {
     return static_cast<unsigned>(language_type);
   }

diff  --git a/lldb/include/lldb/Host/HostThread.h b/lldb/include/lldb/Host/HostThread.h
index e3c103ead1f2d..ba219a3b5c6a6 100644
--- a/lldb/include/lldb/Host/HostThread.h
+++ b/lldb/include/lldb/Host/HostThread.h
@@ -54,10 +54,6 @@ class HostThread {
 
 namespace llvm {
 template <> struct DenseMapInfo<lldb_private::HostThread> {
-  static inline lldb_private::HostThread getEmptyKey() {
-    return lldb_private::HostThread(
-        DenseMapInfo<lldb::thread_t>::getEmptyKey());
-  }
   static unsigned getHashValue(const lldb_private::HostThread &val);
   static bool isEqual(const lldb_private::HostThread &lhs,
                       const lldb_private::HostThread &rhs);

diff  --git a/lldb/include/lldb/Symbol/SymbolContext.h b/lldb/include/lldb/Symbol/SymbolContext.h
index 786ebe39b0ce8..313b2829a49e9 100644
--- a/lldb/include/lldb/Symbol/SymbolContext.h
+++ b/lldb/include/lldb/Symbol/SymbolContext.h
@@ -517,12 +517,6 @@ namespace llvm {
 /// DenseMapInfo implementation.
 /// \{
 template <> struct DenseMapInfo<lldb_private::SymbolContext> {
-  static inline lldb_private::SymbolContext getEmptyKey() {
-    lldb_private::SymbolContext sc;
-    sc.function = DenseMapInfo<lldb_private::Function *>::getEmptyKey();
-    return sc;
-  }
-
   static unsigned getHashValue(const lldb_private::SymbolContext &sc) {
     // Hash all fields EXCEPT symbol, since
     // CompareConsideringPossiblyNullSymbol ignores it.
@@ -541,13 +535,6 @@ template <> struct DenseMapInfo<lldb_private::SymbolContext> {
 
   static bool isEqual(const lldb_private::SymbolContext &lhs,
                       const lldb_private::SymbolContext &rhs) {
-    // Check for empty keys first, since these are invalid pointers we
-    // don't want to accidentally dereference them in
-    // CompareConsideringPossiblyNullSymbol.
-    if (lhs.function == DenseMapInfo<lldb_private::Function *>::getEmptyKey() ||
-        rhs.function == DenseMapInfo<lldb_private::Function *>::getEmptyKey())
-      return lhs.function == rhs.function;
-
     return lldb_private::SymbolContext::CompareConsideringPossiblyNullSymbol(
         lhs, rhs);
   }

diff  --git a/lldb/include/lldb/Utility/ConstString.h b/lldb/include/lldb/Utility/ConstString.h
index 04008371d1910..3d312d95b45ee 100644
--- a/lldb/include/lldb/Utility/ConstString.h
+++ b/lldb/include/lldb/Utility/ConstString.h
@@ -427,10 +427,6 @@ template <> struct format_provider<lldb_private::ConstString> {
 /// DenseMapInfo implementation.
 /// \{
 template <> struct DenseMapInfo<lldb_private::ConstString> {
-  static inline lldb_private::ConstString getEmptyKey() {
-    return lldb_private::ConstString::FromStringPoolPointer(
-        DenseMapInfo<const char *>::getEmptyKey());
-  }
   static unsigned getHashValue(lldb_private::ConstString val) {
     return DenseMapInfo<const char *>::getHashValue(val.m_string);
   }

diff  --git a/lldb/include/lldb/Utility/FileSpec.h b/lldb/include/lldb/Utility/FileSpec.h
index 56257e0dd91f1..e6a5b113c2131 100644
--- a/lldb/include/lldb/Utility/FileSpec.h
+++ b/lldb/include/lldb/Utility/FileSpec.h
@@ -470,9 +470,6 @@ template <> struct format_provider<lldb_private::FileSpec> {
 /// DenseMapInfo implementation.
 /// \{
 template <> struct DenseMapInfo<lldb_private::FileSpec> {
-  static inline lldb_private::FileSpec getEmptyKey() {
-    return lldb_private::FileSpec();
-  }
   static unsigned getHashValue(lldb_private::FileSpec file_spec) {
     return llvm::hash_combine(
         DenseMapInfo<lldb_private::ConstString>::getHashValue(

diff  --git a/lldb/include/lldb/Utility/UUID.h b/lldb/include/lldb/Utility/UUID.h
index 9f449ef2a8511..232650a08784d 100644
--- a/lldb/include/lldb/Utility/UUID.h
+++ b/lldb/include/lldb/Utility/UUID.h
@@ -121,9 +121,6 @@ namespace llvm {
 /// DenseMapInfo implementation.
 /// \{
 template <> struct DenseMapInfo<lldb_private::UUID> {
-  static inline lldb_private::UUID getEmptyKey() {
-    return lldb_private::UUID();
-  }
   static unsigned getHashValue(lldb_private::UUID uuid) {
     return DenseMapInfo<llvm::ArrayRef<uint8_t>>::getHashValue(uuid.GetBytes());
   }

diff  --git a/lldb/source/Plugins/LanguageRuntime/ObjC/ObjCLanguageRuntime.h b/lldb/source/Plugins/LanguageRuntime/ObjC/ObjCLanguageRuntime.h
index fc19da0ac0f98..ba6a4cbff9b4c 100644
--- a/lldb/source/Plugins/LanguageRuntime/ObjC/ObjCLanguageRuntime.h
+++ b/lldb/source/Plugins/LanguageRuntime/ObjC/ObjCLanguageRuntime.h
@@ -425,7 +425,6 @@ class ObjCLanguageRuntime : public LanguageRuntime {
 
   /// Keys are already djbHash values, so use identity as the hash function.
   struct IdentityHashKeyInfo {
-    static constexpr uint32_t getEmptyKey() { return ~0U; }
     static unsigned getHashValue(uint32_t Val) { return Val; }
     static bool isEqual(uint32_t LHS, uint32_t RHS) { return LHS == RHS; }
   };

diff  --git a/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.h b/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.h
index c6d67b3aa5350..2c3dfa9afe286 100644
--- a/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.h
+++ b/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.h
@@ -493,12 +493,9 @@ class ProcessGDBRemote : public Process,
   // KeyInfo for the cached module spec DenseMap.
   // The invariant is that all real keys will have the file and architecture
   // set.
-  // The empty key has an empty file and an empty arch.
   // The comparison and hash functions take the file name and architecture
   // triple into account.
   struct ModuleCacheInfo {
-    static ModuleCacheKey getEmptyKey() { return ModuleCacheKey(); }
-
     static unsigned getHashValue(const ModuleCacheKey &key) {
       return llvm::hash_combine(key.first, key.second);
     }

diff  --git a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
index 3b22cfcec633d..217bba8d16dc3 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
@@ -1124,8 +1124,7 @@ SymbolFileDWARF::GetTypeUnitSupportFiles(DWARFTypeUnit &tu) {
   static SupportFileList empty_list;
 
   dw_offset_t offset = tu.GetLineTableOffset();
-  if (offset == DW_INVALID_OFFSET ||
-      offset == llvm::DenseMapInfo<dw_offset_t>::getEmptyKey())
+  if (offset == DW_INVALID_OFFSET)
     return nullptr;
 
   // Many type units can share a line table, so parse the support file list


        


More information about the lldb-commits mailing list