[Lldb-commits] [lldb] f135ce6 - [lldb] Remove CompilerType::GetIndexOfFieldWithName (#135963)

via lldb-commits lldb-commits at lists.llvm.org
Thu Apr 17 04:55:22 PDT 2025


Author: Charles Zablit
Date: 2025-04-17T12:55:18+01:00
New Revision: f135ce6a9329124f1e508fcad2eedf5326a668fa

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

LOG: [lldb] Remove CompilerType::GetIndexOfFieldWithName (#135963)

This patch removes the unused `CompilerType::GetIndexOfFieldWithName` API (it wasn't used apart from in a single testcase). Given we have so many similarly named APIs already, it's best not to maintain this API that's not really used (and isnt tested).

Added: 
    

Modified: 
    lldb/include/lldb/Symbol/CompilerType.h
    lldb/source/Symbol/CompilerType.cpp
    lldb/unittests/Platform/PlatformSiginfoTest.cpp

Removed: 
    


################################################################################
diff  --git a/lldb/include/lldb/Symbol/CompilerType.h b/lldb/include/lldb/Symbol/CompilerType.h
index 41a1676dabd76..3561bc70887e6 100644
--- a/lldb/include/lldb/Symbol/CompilerType.h
+++ b/lldb/include/lldb/Symbol/CompilerType.h
@@ -433,12 +433,6 @@ class CompilerType {
 
   CompilerDecl GetStaticFieldWithName(llvm::StringRef name) const;
 
-  uint32_t GetIndexOfFieldWithName(const char *name,
-                                   CompilerType *field_compiler_type = nullptr,
-                                   uint64_t *bit_offset_ptr = nullptr,
-                                   uint32_t *bitfield_bit_size_ptr = nullptr,
-                                   bool *is_bitfield_ptr = nullptr) const;
-
   llvm::Expected<CompilerType> GetChildCompilerTypeAtIndex(
       ExecutionContext *exe_ctx, size_t idx, bool transparent_pointers,
       bool omit_empty_base_classes, bool ignore_array_bounds,

diff  --git a/lldb/source/Symbol/CompilerType.cpp b/lldb/source/Symbol/CompilerType.cpp
index 22fdd24fc7cd5..8e89d006d08d3 100644
--- a/lldb/source/Symbol/CompilerType.cpp
+++ b/lldb/source/Symbol/CompilerType.cpp
@@ -893,25 +893,6 @@ CompilerDecl CompilerType::GetStaticFieldWithName(llvm::StringRef name) const {
   return CompilerDecl();
 }
 
-uint32_t CompilerType::GetIndexOfFieldWithName(
-    const char *name, CompilerType *field_compiler_type_ptr,
-    uint64_t *bit_offset_ptr, uint32_t *bitfield_bit_size_ptr,
-    bool *is_bitfield_ptr) const {
-  unsigned count = GetNumFields();
-  std::string field_name;
-  for (unsigned index = 0; index < count; index++) {
-    CompilerType field_compiler_type(
-        GetFieldAtIndex(index, field_name, bit_offset_ptr,
-                        bitfield_bit_size_ptr, is_bitfield_ptr));
-    if (strcmp(field_name.c_str(), name) == 0) {
-      if (field_compiler_type_ptr)
-        *field_compiler_type_ptr = field_compiler_type;
-      return index;
-    }
-  }
-  return UINT32_MAX;
-}
-
 llvm::Expected<CompilerType> CompilerType::GetChildCompilerTypeAtIndex(
     ExecutionContext *exe_ctx, size_t idx, bool transparent_pointers,
     bool omit_empty_base_classes, bool ignore_array_bounds,

diff  --git a/lldb/unittests/Platform/PlatformSiginfoTest.cpp b/lldb/unittests/Platform/PlatformSiginfoTest.cpp
index 4b2c93a68a94a..b9f1fe4bbaadf 100644
--- a/lldb/unittests/Platform/PlatformSiginfoTest.cpp
+++ b/lldb/unittests/Platform/PlatformSiginfoTest.cpp
@@ -60,9 +60,11 @@ class PlatformSiginfoTest : public ::testing::Test {
     uint64_t total_offset = 0;
     for (auto field_name : llvm::split(path, '.')) {
       uint64_t bit_offset;
-      ASSERT_NE(field_type.GetIndexOfFieldWithName(field_name.str().c_str(),
-                                                   &field_type, &bit_offset),
-                UINT32_MAX);
+      std::string name;
+      field_type = field_type.GetFieldAtIndex(
+          field_type.GetIndexOfChildWithName(field_name, false), name,
+          &bit_offset, nullptr, nullptr);
+      ASSERT_TRUE(field_type);
       total_offset += bit_offset;
     }
 


        


More information about the lldb-commits mailing list