From 399bf57e26b197bbe89379d821c6e564745622e3 Mon Sep 17 00:00:00 2001 From: Charles Zablit Date: Thu, 17 Apr 2025 12:55:18 +0100 Subject: [PATCH 1/2] [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). --- lldb/include/lldb/Symbol/CompilerType.h | 6 ------ lldb/source/Symbol/CompilerType.cpp | 19 ------------------- .../Platform/PlatformSiginfoTest.cpp | 8 +++++--- 3 files changed, 5 insertions(+), 28 deletions(-) diff --git a/lldb/include/lldb/Symbol/CompilerType.h b/lldb/include/lldb/Symbol/CompilerType.h index 1185ef3aef479..b12bb6f35d938 100644 --- a/lldb/include/lldb/Symbol/CompilerType.h +++ b/lldb/include/lldb/Symbol/CompilerType.h @@ -464,12 +464,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 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 4eed615ad7bb3..16ac6d34712fe 100644 --- a/lldb/source/Symbol/CompilerType.cpp +++ b/lldb/source/Symbol/CompilerType.cpp @@ -941,25 +941,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::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 2726357e65e57..256917b5dd99d 100644 --- a/lldb/unittests/Platform/PlatformSiginfoTest.cpp +++ b/lldb/unittests/Platform/PlatformSiginfoTest.cpp @@ -61,9 +61,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; } From 0daf20fafaebe35e4827fcdaa7cd043d9779e934 Mon Sep 17 00:00:00 2001 From: Charles Zablit Date: Fri, 9 May 2025 11:31:22 +0100 Subject: [PATCH 2/2] fix build error --- lldb/unittests/Platform/PlatformSiginfoTest.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lldb/unittests/Platform/PlatformSiginfoTest.cpp b/lldb/unittests/Platform/PlatformSiginfoTest.cpp index 256917b5dd99d..3d2cf7b974268 100644 --- a/lldb/unittests/Platform/PlatformSiginfoTest.cpp +++ b/lldb/unittests/Platform/PlatformSiginfoTest.cpp @@ -62,8 +62,9 @@ class PlatformSiginfoTest : public ::testing::Test { for (auto field_name : llvm::split(path, '.')) { uint64_t bit_offset; std::string name; + lldb_private::ExecutionContext exe_ctx{}; field_type = field_type.GetFieldAtIndex( - field_type.GetIndexOfChildWithName(field_name, false), name, + field_type.GetIndexOfChildWithName(field_name, &exe_ctx, false), name, &bit_offset, nullptr, nullptr); ASSERT_TRUE(field_type); total_offset += bit_offset;