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

Fangrui Song via lldb-commits lldb-commits at lists.llvm.org
Fri Jun 5 19:52:51 PDT 2026


https://github.com/MaskRay created https://github.com/llvm/llvm-project/pull/201990

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


>From c69e320998e8a459f7ce598434fd05a2536ce4d3 Mon Sep 17 00:00:00 2001
From: Fangrui Song <i at maskray.me>
Date: Fri, 5 Jun 2026 19:08:14 -0700
Subject: [PATCH] [lldb] Remove unused DenseMapInfo::getEmptyKey

After #201281 DenseMapInfo<T>::getEmptyKey() is no longer used by
DenseMap. Remove the unused getEmptyKey definitions and dead sentinel
uses.
---
 lldb/include/lldb/Core/Highlighter.h                |  3 ---
 lldb/include/lldb/Host/HostThread.h                 |  4 ----
 lldb/include/lldb/Symbol/SymbolContext.h            | 13 -------------
 lldb/include/lldb/Utility/ConstString.h             |  4 ----
 lldb/include/lldb/Utility/FileSpec.h                |  3 ---
 lldb/include/lldb/Utility/UUID.h                    |  3 ---
 .../LanguageRuntime/ObjC/ObjCLanguageRuntime.h      |  1 -
 .../Plugins/Process/gdb-remote/ProcessGDBRemote.h   |  2 --
 .../Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp    |  3 +--
 9 files changed, 1 insertion(+), 35 deletions(-)

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..b1750c69e798f 100644
--- a/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.h
+++ b/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.h
@@ -497,8 +497,6 @@ class ProcessGDBRemote : public Process,
   // 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