[Lldb-commits] [lldb] [DRAFT][lldb] Upgrade CompilerType::GetIndexOfFieldWithName to return llvm::Expected (PR #135963)

Charles Zablit via lldb-commits lldb-commits at lists.llvm.org
Wed Apr 16 08:32:17 PDT 2025


https://github.com/charles-zablit updated https://github.com/llvm/llvm-project/pull/135963

>From 6dd67fe4ad03f0ec0623717715b8cfcc9537ab3f Mon Sep 17 00:00:00 2001
From: Charles Zablit <zablitcharles at gmail.com>
Date: Wed, 16 Apr 2025 11:28:54 +0100
Subject: [PATCH] [lldb] Remove unused API
 CompilerType::GetIndexOfFieldWithName

---
 lldb/include/lldb/Symbol/CompilerType.h       |  6 ------
 lldb/source/Symbol/CompilerType.cpp           | 19 -----------------
 .../Platform/PlatformSiginfoTest.cpp          | 21 -------------------
 3 files changed, 46 deletions(-)

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..a1f55bdd926db 100644
--- a/lldb/unittests/Platform/PlatformSiginfoTest.cpp
+++ b/lldb/unittests/Platform/PlatformSiginfoTest.cpp
@@ -50,27 +50,6 @@ class PlatformSiginfoTest : public ::testing::Test {
 
   typedef std::tuple<const char *, uint64_t, uint64_t> field_tuple;
 
-  void ExpectField(const CompilerType &siginfo_type, field_tuple field) {
-    const char *path;
-    uint64_t offset, size;
-    std::tie(path, offset, size) = field;
-
-    SCOPED_TRACE(path);
-    CompilerType field_type = siginfo_type;
-    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);
-      total_offset += bit_offset;
-    }
-
-    EXPECT_EQ(total_offset, offset * 8);
-    EXPECT_EQ(llvm::expectedToOptional(field_type.GetByteSize(nullptr)),
-              std::optional<uint64_t>(size));
-  }
-
   void ExpectFields(const CompilerType &container,
                     std::initializer_list<field_tuple> fields) {
     for (auto x : fields)



More information about the lldb-commits mailing list