[Lldb-commits] [lldb] [DRAFT][lldb] Upgrade CompilerType::GetIndexOfFieldWithName to return llvm::Expected (PR #135963)
charles-zablit wrote: > Is this API used for anything outside of that `PlatformSigInfoTest`? It > doesn't seem to be used anywhere (including the apple fork). Should we just > remove this API? It's not used anywhere apart from the `PlatformSigInfoTest`. It's also inside the `lldb_private` namespace so I agree, I think it's best to remove it. https://github.com/llvm/llvm-project/pull/135963 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [DRAFT][lldb] Upgrade CompilerType::GetIndexOfFieldWithName to return llvm::Expected (PR #135963)
https://github.com/charles-zablit created https://github.com/llvm/llvm-project/pull/135963 This patch updates the `CompilerType::GetIndexOfFieldWithName` API to use `llvm::Expected` if no index is found instead of `UINT32_MAX`. >From aaf9c4ec3e68d78d963cdac3d3f08dc207d49cad Mon Sep 17 00:00:00 2001 From: Charles Zablit Date: Wed, 16 Apr 2025 11:28:54 +0100 Subject: [PATCH] [lldb] Upgrade CompilerType::GetIndexOfFieldWithName to return llvm::Expected --- lldb/include/lldb/Symbol/CompilerType.h | 11 ++- lldb/source/Symbol/CompilerType.cpp | 4 ++-- lldb/unittests/Platform/PlatformSiginfoTest.cpp | 7 --- 3 files changed, 12 insertions(+), 10 deletions(-) diff --git a/lldb/include/lldb/Symbol/CompilerType.h b/lldb/include/lldb/Symbol/CompilerType.h index 41a1676dabd76..79998922cfc93 100644 --- a/lldb/include/lldb/Symbol/CompilerType.h +++ b/lldb/include/lldb/Symbol/CompilerType.h @@ -433,11 +433,12 @@ 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 + 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, diff --git a/lldb/source/Symbol/CompilerType.cpp b/lldb/source/Symbol/CompilerType.cpp index 22fdd24fc7cd5..0a36b390a645c 100644 --- a/lldb/source/Symbol/CompilerType.cpp +++ b/lldb/source/Symbol/CompilerType.cpp @@ -893,7 +893,7 @@ CompilerDecl CompilerType::GetStaticFieldWithName(llvm::StringRef name) const { return CompilerDecl(); } -uint32_t CompilerType::GetIndexOfFieldWithName( +llvm::Expected 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 { @@ -909,7 +909,7 @@ uint32_t CompilerType::GetIndexOfFieldWithName( return index; } } - return UINT32_MAX; + return llvm::createStringError("Invalid name: Cannot find index"); } llvm::Expected CompilerType::GetChildCompilerTypeAtIndex( diff --git a/lldb/unittests/Platform/PlatformSiginfoTest.cpp b/lldb/unittests/Platform/PlatformSiginfoTest.cpp index 4b2c93a68a94a..e48d8ea667ad8 100644 --- a/lldb/unittests/Platform/PlatformSiginfoTest.cpp +++ b/lldb/unittests/Platform/PlatformSiginfoTest.cpp @@ -60,9 +60,10 @@ 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); + ASSERT(llvm::expectedToOptional( + field_type.GetIndexOfFieldWithName(field_name.str().c_str(), +&field_type, &bit_offset)) + .has_value()); total_offset += bit_offset; } ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [DRAFT][lldb] Upgrade CompilerType::GetIndexOfFieldWithName to return llvm::Expected (PR #135963)
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 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 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::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 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(size)); - } - void ExpectFields(const CompilerType &container, std::initializer_list fields) { for (auto x : fields) ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [DRAFT][lldb] Upgrade CompilerType::GetIndexOfFieldWithName to return llvm::Expected (PR #135963)
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 Date: Wed, 16 Apr 2025 11:28:54 +0100 Subject: [PATCH 1/2] [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 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::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 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(size)); - } - void ExpectFields(const CompilerType &container, std::initializer_list fields) { for (auto x : fields) >From 77faa748f436cd28ea95854296c476a1be04e5d3 Mon Sep 17 00:00:00 2001 From: Charles Zablit Date: Wed, 16 Apr 2025 19:04:56 +0100 Subject: [PATCH 2/2] fixup! [lldb] Remove unused API CompilerType::GetIndexOfFieldWithName --- lldb/unittests/Platform/CMakeLists.txt| 1 - .../Platform/PlatformSiginfoTest.cpp | 288 -- 2 files changed, 289 deletions(-) delete mode 100644 lldb/unittests/Platform/PlatformSiginfoTest.cpp diff --git a/lldb/unittests/Platform/CMakeLists.txt b/lldb/unittests/Platform/CMakeLists.txt index 5c0ef5ca6ef22..7d57f633d89c3 100644 --- a/lldb/unittests/Platform/CMakeLists.txt +++ b/lldb/unittests/Platform/CMakeLists.txt @@ -2,7 +2,6 @@ add_lldb_unittest(LLDBPlatformTests PlatformAppleSimulatorTest.cpp PlatformDarwinTest.cpp PlatformMacOSXTest.cpp - PlatformSiginfoTest.cpp PlatformTest.cpp LINK_LIBS diff --git a/lldb/unittests/Platform/PlatformSiginfoTest.cpp b/lldb/unittests/Platform/PlatformSiginfoTest.cpp deleted file mode 100644 index a1f55bdd926db..0 --- a/lldb/
[Lldb-commits] [lldb] [lldb] Remove CompilerType::GetIndexOfFieldWithName (PR #135963)
charles-zablit wrote: > I think the test can just do this: > > ``` > uint64_t bit_offset; > std::string name; > field_type = field_type.GetFieldAtIndex( > field_type.GetIndexOfChildWithName(field_name, > /*omit_empty_base_classes=*/false), > name, &bit_offset, nullptr, nullptr); > ASSERT_TRUE(field_type); > ``` Tested this locally and the tests pass, I have updated the commit. > Instead of using `CompilerType::GetIndexOfFieldWithName` (though I haven't > actually tried to compile/run this) > > Don't have a strong opinion on whether to remove or extend the API. > Personally I prefer removing it just because we already have so many > similarly named APIs across CompilerType/TypeSystemClang that do things > slightly differently, that it would be nice to get rid of at least one of > them. Ended up removing the API and used your suggestion to define the test without the API. Thanks! https://github.com/llvm/llvm-project/pull/135963 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Remove CompilerType::GetIndexOfFieldWithName (PR #135963)
charles-zablit wrote: Sorry I forgot to run `clang-format` I will configure a pre-commit hook. https://github.com/llvm/llvm-project/pull/135963 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Remove CompilerType::GetIndexOfFieldWithName (PR #135963)
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 Date: Wed, 16 Apr 2025 11:28:54 +0100 Subject: [PATCH 1/3] [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 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::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 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(size)); - } - void ExpectFields(const CompilerType &container, std::initializer_list fields) { for (auto x : fields) >From 77faa748f436cd28ea95854296c476a1be04e5d3 Mon Sep 17 00:00:00 2001 From: Charles Zablit Date: Wed, 16 Apr 2025 19:04:56 +0100 Subject: [PATCH 2/3] fixup! [lldb] Remove unused API CompilerType::GetIndexOfFieldWithName --- lldb/unittests/Platform/CMakeLists.txt| 1 - .../Platform/PlatformSiginfoTest.cpp | 288 -- 2 files changed, 289 deletions(-) delete mode 100644 lldb/unittests/Platform/PlatformSiginfoTest.cpp diff --git a/lldb/unittests/Platform/CMakeLists.txt b/lldb/unittests/Platform/CMakeLists.txt index 5c0ef5ca6ef22..7d57f633d89c3 100644 --- a/lldb/unittests/Platform/CMakeLists.txt +++ b/lldb/unittests/Platform/CMakeLists.txt @@ -2,7 +2,6 @@ add_lldb_unittest(LLDBPlatformTests PlatformAppleSimulatorTest.cpp PlatformDarwinTest.cpp PlatformMacOSXTest.cpp - PlatformSiginfoTest.cpp PlatformTest.cpp LINK_LIBS diff --git a/lldb/unittests/Platform/PlatformSiginfoTest.cpp b/lldb/unittests/Platform/PlatformSiginfoTest.cpp deleted file mode 100644 index a1f55bdd926db..0 --- a/lldb/
[Lldb-commits] [lldb] [lldb] Remove CompilerType::GetIndexOfFieldWithName (PR #135963)
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 Date: Wed, 16 Apr 2025 11:28:54 +0100 Subject: [PATCH 1/3] [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 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::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 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(size)); - } - void ExpectFields(const CompilerType &container, std::initializer_list fields) { for (auto x : fields) >From 77faa748f436cd28ea95854296c476a1be04e5d3 Mon Sep 17 00:00:00 2001 From: Charles Zablit Date: Wed, 16 Apr 2025 19:04:56 +0100 Subject: [PATCH 2/3] fixup! [lldb] Remove unused API CompilerType::GetIndexOfFieldWithName --- lldb/unittests/Platform/CMakeLists.txt| 1 - .../Platform/PlatformSiginfoTest.cpp | 288 -- 2 files changed, 289 deletions(-) delete mode 100644 lldb/unittests/Platform/PlatformSiginfoTest.cpp diff --git a/lldb/unittests/Platform/CMakeLists.txt b/lldb/unittests/Platform/CMakeLists.txt index 5c0ef5ca6ef22..7d57f633d89c3 100644 --- a/lldb/unittests/Platform/CMakeLists.txt +++ b/lldb/unittests/Platform/CMakeLists.txt @@ -2,7 +2,6 @@ add_lldb_unittest(LLDBPlatformTests PlatformAppleSimulatorTest.cpp PlatformDarwinTest.cpp PlatformMacOSXTest.cpp - PlatformSiginfoTest.cpp PlatformTest.cpp LINK_LIBS diff --git a/lldb/unittests/Platform/PlatformSiginfoTest.cpp b/lldb/unittests/Platform/PlatformSiginfoTest.cpp deleted file mode 100644 index a1f55bdd926db..0 --- a/lldb/
[Lldb-commits] [lldb] [lldb] Remove CompilerType::GetIndexOfFieldWithName (PR #135963)
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 Date: Wed, 16 Apr 2025 11:28:54 +0100 Subject: [PATCH 1/4] [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 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::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 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(size)); - } - void ExpectFields(const CompilerType &container, std::initializer_list fields) { for (auto x : fields) >From 77faa748f436cd28ea95854296c476a1be04e5d3 Mon Sep 17 00:00:00 2001 From: Charles Zablit Date: Wed, 16 Apr 2025 19:04:56 +0100 Subject: [PATCH 2/4] fixup! [lldb] Remove unused API CompilerType::GetIndexOfFieldWithName --- lldb/unittests/Platform/CMakeLists.txt| 1 - .../Platform/PlatformSiginfoTest.cpp | 288 -- 2 files changed, 289 deletions(-) delete mode 100644 lldb/unittests/Platform/PlatformSiginfoTest.cpp diff --git a/lldb/unittests/Platform/CMakeLists.txt b/lldb/unittests/Platform/CMakeLists.txt index 5c0ef5ca6ef22..7d57f633d89c3 100644 --- a/lldb/unittests/Platform/CMakeLists.txt +++ b/lldb/unittests/Platform/CMakeLists.txt @@ -2,7 +2,6 @@ add_lldb_unittest(LLDBPlatformTests PlatformAppleSimulatorTest.cpp PlatformDarwinTest.cpp PlatformMacOSXTest.cpp - PlatformSiginfoTest.cpp PlatformTest.cpp LINK_LIBS diff --git a/lldb/unittests/Platform/PlatformSiginfoTest.cpp b/lldb/unittests/Platform/PlatformSiginfoTest.cpp deleted file mode 100644 index a1f55bdd926db..0 --- a/lldb/
[Lldb-commits] [lldb] [lldb] Remove CompilerType::GetIndexOfFieldWithName (PR #135963)
https://github.com/charles-zablit edited https://github.com/llvm/llvm-project/pull/135963 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Remove CompilerType::GetIndexOfFieldWithName (PR #135963)
charles-zablit wrote: > We probably shouldnt be removing the test. Is there some way to test whatever > we used to test without the API? I see 2 options: 1. Move the body of `CompilerType::GetIndexOfFieldWithName` into the test directly. This way, we remove the API but keep the test. 2. Keep the API, use `llvm::Expected` and keep the test. I feel like `1` would be `hiding` the API, and I would therefore prefer `2`. https://github.com/llvm/llvm-project/pull/135963 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Upgrade CompilerType::GetIndexOfFieldWithName to return llvm::Expected (PR #135963)
https://github.com/charles-zablit edited https://github.com/llvm/llvm-project/pull/135963 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [DRAFT][lldb] Upgrade CompilerType::GetIndexOfFieldWithName to return llvm::Expected (PR #135963)
charles-zablit wrote: > It's worth mentioning that the LLVM convention (as opposed to what is done in > the swift fork) is to avoid force-pushing. Thanks! I will avoid that for the future PRs 👍 https://github.com/llvm/llvm-project/pull/135963 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Remove CompilerType::GetIndexOfFieldWithName (PR #135963)
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 Date: Wed, 16 Apr 2025 11:28:54 +0100 Subject: [PATCH 1/3] [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 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::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 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(size)); - } - void ExpectFields(const CompilerType &container, std::initializer_list fields) { for (auto x : fields) >From 77faa748f436cd28ea95854296c476a1be04e5d3 Mon Sep 17 00:00:00 2001 From: Charles Zablit Date: Wed, 16 Apr 2025 19:04:56 +0100 Subject: [PATCH 2/3] fixup! [lldb] Remove unused API CompilerType::GetIndexOfFieldWithName --- lldb/unittests/Platform/CMakeLists.txt| 1 - .../Platform/PlatformSiginfoTest.cpp | 288 -- 2 files changed, 289 deletions(-) delete mode 100644 lldb/unittests/Platform/PlatformSiginfoTest.cpp diff --git a/lldb/unittests/Platform/CMakeLists.txt b/lldb/unittests/Platform/CMakeLists.txt index 5c0ef5ca6ef22..7d57f633d89c3 100644 --- a/lldb/unittests/Platform/CMakeLists.txt +++ b/lldb/unittests/Platform/CMakeLists.txt @@ -2,7 +2,6 @@ add_lldb_unittest(LLDBPlatformTests PlatformAppleSimulatorTest.cpp PlatformDarwinTest.cpp PlatformMacOSXTest.cpp - PlatformSiginfoTest.cpp PlatformTest.cpp LINK_LIBS diff --git a/lldb/unittests/Platform/PlatformSiginfoTest.cpp b/lldb/unittests/Platform/PlatformSiginfoTest.cpp deleted file mode 100644 index a1f55bdd926db..0 --- a/lldb/
[Lldb-commits] [lldb] [lldb] Upgrade `GetIndexOfChildWithName` to use `llvm::Expected` (PR #136693)
https://github.com/charles-zablit created https://github.com/llvm/llvm-project/pull/136693 This patch replaces the use of `UINT32_MAX` as the error return value of `GetIndexOfChildWithName` with `llvm::Expected`. >From 143140ca46927e87019dcc818702785ebdb15540 Mon Sep 17 00:00:00 2001 From: Charles Zablit Date: Tue, 22 Apr 2025 12:09:02 +0100 Subject: [PATCH] [lldb] Upgrade GetIndexOfChildWithName to use llvm::Expected --- lldb/include/lldb/API/SBValue.h | 2 + .../lldb/DataFormatters/TypeSynthetic.h | 11 ++-- .../lldb/DataFormatters/VectorIterator.h | 2 +- .../lldb/Interpreter/ScriptInterpreter.h | 5 +- lldb/include/lldb/Symbol/CompilerType.h | 5 +- lldb/include/lldb/Symbol/TypeSystem.h | 7 ++- lldb/include/lldb/ValueObject/ValueObject.h | 2 +- .../lldb/ValueObject/ValueObjectRegister.h| 2 +- .../ValueObject/ValueObjectSyntheticFilter.h | 2 +- lldb/source/API/SBValue.cpp | 10 +++- .../DataFormatters/FormatterBytecode.cpp | 9 ++- lldb/source/DataFormatters/TypeSynthetic.cpp | 9 +-- lldb/source/DataFormatters/VectorType.cpp | 5 +- .../Language/CPlusPlus/BlockPointer.cpp | 16 -- .../Plugins/Language/CPlusPlus/Coroutines.cpp | 9 ++- .../Plugins/Language/CPlusPlus/Coroutines.h | 2 +- .../Language/CPlusPlus/GenericBitset.cpp | 2 +- .../Language/CPlusPlus/GenericOptional.cpp| 2 +- .../Plugins/Language/CPlusPlus/LibCxx.cpp | 14 +++-- .../Plugins/Language/CPlusPlus/LibCxx.h | 4 +- .../Language/CPlusPlus/LibCxxAtomic.cpp | 11 +++- .../CPlusPlus/LibCxxInitializerList.cpp | 5 +- .../Plugins/Language/CPlusPlus/LibCxxList.cpp | 2 +- .../Plugins/Language/CPlusPlus/LibCxxMap.cpp | 12 ++-- .../Language/CPlusPlus/LibCxxProxyArray.cpp | 5 +- .../Language/CPlusPlus/LibCxxQueue.cpp| 9 ++- .../CPlusPlus/LibCxxRangesRefView.cpp | 2 +- .../Language/CPlusPlus/LibCxxSliceArray.cpp | 8 ++- .../Plugins/Language/CPlusPlus/LibCxxSpan.cpp | 9 +-- .../Language/CPlusPlus/LibCxxTuple.cpp| 2 +- .../Language/CPlusPlus/LibCxxUnorderedMap.cpp | 13 +++-- .../Language/CPlusPlus/LibCxxValarray.cpp | 8 ++- .../Language/CPlusPlus/LibCxxVariant.cpp | 9 ++- .../Language/CPlusPlus/LibCxxVector.cpp | 16 -- .../Plugins/Language/CPlusPlus/LibStdcpp.cpp | 25 .../Language/CPlusPlus/LibStdcppTuple.cpp | 6 +- .../CPlusPlus/LibStdcppUniquePointer.cpp | 9 +-- lldb/source/Plugins/Language/ObjC/Cocoa.cpp | 5 +- lldb/source/Plugins/Language/ObjC/NSArray.cpp | 23 .../Plugins/Language/ObjC/NSDictionary.cpp| 57 +++ lldb/source/Plugins/Language/ObjC/NSError.cpp | 5 +- .../Plugins/Language/ObjC/NSException.cpp | 5 +- .../Plugins/Language/ObjC/NSIndexPath.cpp | 5 +- lldb/source/Plugins/Language/ObjC/NSSet.cpp | 25 .../Python/ScriptInterpreterPython.cpp| 16 -- .../Python/ScriptInterpreterPythonImpl.h | 5 +- .../TypeSystem/Clang/TypeSystemClang.cpp | 2 +- .../TypeSystem/Clang/TypeSystemClang.h| 7 ++- lldb/source/Symbol/CompilerType.cpp | 5 +- lldb/source/ValueObject/ValueObject.cpp | 3 +- .../ValueObject/ValueObjectRegister.cpp | 6 +- .../ValueObjectSyntheticFilter.cpp| 37 ++-- 52 files changed, 286 insertions(+), 191 deletions(-) diff --git a/lldb/include/lldb/API/SBValue.h b/lldb/include/lldb/API/SBValue.h index 75d20a4378f09..69c50ab038e5b 100644 --- a/lldb/include/lldb/API/SBValue.h +++ b/lldb/include/lldb/API/SBValue.h @@ -13,6 +13,8 @@ #include "lldb/API/SBDefines.h" #include "lldb/API/SBType.h" +#include "lldb/Core/Value.h" + class ValueImpl; class ValueLocker; diff --git a/lldb/include/lldb/DataFormatters/TypeSynthetic.h b/lldb/include/lldb/DataFormatters/TypeSynthetic.h index 14e516964f250..a132c63a93b08 100644 --- a/lldb/include/lldb/DataFormatters/TypeSynthetic.h +++ b/lldb/include/lldb/DataFormatters/TypeSynthetic.h @@ -51,7 +51,7 @@ class SyntheticChildrenFrontEnd { virtual lldb::ValueObjectSP GetChildAtIndex(uint32_t idx) = 0; - virtual size_t GetIndexOfChildWithName(ConstString name) = 0; + virtual llvm::Expected GetIndexOfChildWithName(ConstString name) = 0; /// This function is assumed to always succeed and if it fails, the front-end /// should know to deal with it in the correct way (most probably, by refusing @@ -117,8 +117,9 @@ class SyntheticValueProviderFrontEnd : public SyntheticChildrenFrontEnd { lldb::ValueObjectSP GetChildAtIndex(uint32_t idx) override { return nullptr; } - size_t GetIndexOfChildWithName(ConstString name) override { -return UINT32_MAX; + llvm::Expected GetIndexOfChildWithName(ConstString name) override { +return llvm::createStringError("Cannot find index of child '%s'", + name.AsCString()); } lldb::ChildCacheState Update() override { @@ -343
[Lldb-commits] [lldb] [lldb] Upgrade `GetIndexOfChildWithName` to use `llvm::Expected` (PR #136693)
@@ -218,10 +218,11 @@ bool ScriptedSyntheticChildren::FrontEnd::MightHaveChildren() { return m_interpreter->MightHaveChildrenSynthProviderInstance(m_wrapper_sp); } -size_t ScriptedSyntheticChildren::FrontEnd::GetIndexOfChildWithName( -ConstString name) { +llvm::Expected +ScriptedSyntheticChildren::FrontEnd::GetIndexOfChildWithName(ConstString name) { if (!m_wrapper_sp || m_interpreter == nullptr) -return UINT32_MAX; +return llvm::createStringError("Cannot find index of child '%s'", + name.AsCString()); charles-zablit wrote: I ended up editing the message everywhere it was used, adding `'classname'` at the beginning of each. https://github.com/llvm/llvm-project/pull/136693 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Upgrade `GetIndexOfChildWithName` to use `llvm::Expected` (PR #136693)
@@ -172,8 +173,15 @@ bool lldb_private::formatters::BlockPointerSummaryProvider( static const ConstString s_FuncPtr_name("__FuncPtr"); - lldb::ValueObjectSP child_sp = synthetic_children->GetChildAtIndex( - synthetic_children->GetIndexOfChildWithName(s_FuncPtr_name)); + auto index_or_err = + synthetic_children->GetIndexOfChildWithName(s_FuncPtr_name); + + if (!index_or_err) { +return false; charles-zablit wrote: Fixed, thanks! The tests were indeed passing. https://github.com/llvm/llvm-project/pull/136693 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Upgrade `GetIndexOfChildWithName` to use `llvm::Expected` (PR #136693)
@@ -199,10 +199,12 @@ lldb_private::formatters::StdlibCoroutineHandleSyntheticFrontEnd::Update() { return lldb::ChildCacheState::eRefetch; } -size_t StdlibCoroutineHandleSyntheticFrontEnd::GetIndexOfChildWithName( +llvm::Expected +StdlibCoroutineHandleSyntheticFrontEnd::GetIndexOfChildWithName( ConstString name) { if (!m_resume_ptr_sp || !m_destroy_ptr_sp) -return UINT32_MAX; +return llvm::createStringError("Cannot find index of child '%s'", charles-zablit wrote: Fixed, thanks! https://github.com/llvm/llvm-project/pull/136693 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Upgrade `GetIndexOfChildWithName` to use `llvm::Expected` (PR #136693)
@@ -456,7 +460,7 @@ ExtractLibcxxStringInfo(ValueObject &valobj) { if (!l) return {}; - StringLayout layout = l->GetIndexOfChildWithName("__data_") == 0 + StringLayout layout = l->GetIndexOfChildWithName("__data_").get() == 0 charles-zablit wrote: Fixed, thanks! The tests were not failing either here... https://github.com/llvm/llvm-project/pull/136693 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Upgrade `GetIndexOfChildWithName` to use `llvm::Expected` (PR #136693)
@@ -488,10 +488,12 @@ lldb_private::formatters::LibCxxMapIteratorSyntheticFrontEnd::GetChildAtIndex( return m_pair_sp->GetChildAtIndex(idx); } -size_t lldb_private::formatters::LibCxxMapIteratorSyntheticFrontEnd:: +llvm::Expected +lldb_private::formatters::LibCxxMapIteratorSyntheticFrontEnd:: GetIndexOfChildWithName(ConstString name) { if (!m_pair_sp) -return UINT32_MAX; +return llvm::createStringError("Cannot find index of child '%s'", + name.AsCString()); charles-zablit wrote: Fixed, thanks! https://github.com/llvm/llvm-project/pull/136693 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Upgrade `GetIndexOfChildWithName` to use `llvm::Expected` (PR #136693)
@@ -173,7 +173,8 @@ lldb_private::formatters::LibcxxStdProxyArraySyntheticFrontEnd::Update() { return ChildCacheState::eRefetch; } -size_t lldb_private::formatters::LibcxxStdProxyArraySyntheticFrontEnd:: +llvm::Expected +lldb_private::formatters::LibcxxStdProxyArraySyntheticFrontEnd:: GetIndexOfChildWithName(ConstString name) { if (!m_base) return std::numeric_limits::max(); charles-zablit wrote: Fixed, thanks! https://github.com/llvm/llvm-project/pull/136693 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Upgrade `GetIndexOfChildWithName` to use `llvm::Expected` (PR #136693)
@@ -319,40 +319,41 @@ ValueObjectSynthetic::GetChildMemberWithName(llvm::StringRef name, bool can_create) { UpdateValueIfNeeded(); - uint32_t index = GetIndexOfChildWithName(name); + auto index_or_err = GetIndexOfChildWithName(name); - if (index == UINT32_MAX) + if (!index_or_err) charles-zablit wrote: Fixed, thanks! https://github.com/llvm/llvm-project/pull/136693 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Upgrade `GetIndexOfChildWithName` to use `llvm::Expected` (PR #136693)
@@ -152,7 +152,8 @@ lldb_private::formatters::LibcxxStdVectorSyntheticFrontEnd::Update() { return lldb::ChildCacheState::eRefetch; } -size_t lldb_private::formatters::LibcxxStdVectorSyntheticFrontEnd:: +llvm::Expected +lldb_private::formatters::LibcxxStdVectorSyntheticFrontEnd:: GetIndexOfChildWithName(ConstString name) { if (!m_start || !m_finish) return UINT32_MAX; charles-zablit wrote: Fixed, thanks! https://github.com/llvm/llvm-project/pull/136693 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Upgrade `GetIndexOfChildWithName` to use `llvm::Expected` (PR #136693)
@@ -14,6 +14,7 @@ #include "llvm/Support/Format.h" #include "llvm/Support/FormatProviders.h" #include "llvm/Support/FormatVariadicDetails.h" +#include charles-zablit wrote: Fixed, thanks! https://github.com/llvm/llvm-project/pull/136693 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Upgrade `GetIndexOfChildWithName` to use `llvm::Expected` (PR #136693)
@@ -456,9 +464,13 @@ ExtractLibcxxStringInfo(ValueObject &valobj) { if (!l) return {}; - StringLayout layout = l->GetIndexOfChildWithName("__data_") == 0 -? StringLayout::DSC -: StringLayout::CSD; + auto index_or_err = l->GetIndexOfChildWithName("__data_"); + if (!index_or_err) +LLDB_LOG_ERROR(GetLog(LLDBLog::Types), index_or_err.takeError(), "{0}"); + return {}; charles-zablit wrote: Yes, it was actually the root cause of some test failures as well... https://github.com/llvm/llvm-project/pull/136693 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Upgrade `GetIndexOfChildWithName` to use `llvm::Expected` (PR #136693)
@@ -28,7 +28,7 @@ class GenericBitsetFrontEnd : public SyntheticChildrenFrontEnd { GenericBitsetFrontEnd(ValueObject &valobj, StdLib stdlib); - size_t GetIndexOfChildWithName(ConstString name) override { + llvm::Expected GetIndexOfChildWithName(ConstString name) override { return formatters::ExtractIndexFromString(name.GetCString()); } charles-zablit wrote: I plan on doing this in a separate patch. For now, I have added code which checks if `lldb_private::formatters::ExtractIndexFromString` returns `UINT32_MAX`. https://github.com/llvm/llvm-project/pull/136693 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Upgrade `GetIndexOfChildWithName` to use `llvm::Expected` (PR #136693)
@@ -1202,13 +1225,16 @@ lldb_private::formatters::Foundation1100:: m_data_64 = nullptr; } -size_t -lldb_private::formatters::Foundation1100:: - NSDictionaryMSyntheticFrontEnd::GetIndexOfChildWithName(ConstString name) { +llvm::Expected lldb_private::formatters::Foundation1100:: +NSDictionaryMSyntheticFrontEnd::GetIndexOfChildWithName(ConstString name) { const char *item_name = name.GetCString(); uint32_t idx = ExtractIndexFromString(item_name); - if (idx < UINT32_MAX && idx >= CalculateNumChildrenIgnoringErrors()) -return UINT32_MAX; + if (idx == UINT32_MAX || + (idx < UINT32_MAX && idx >= CalculateNumChildrenIgnoringErrors())) charles-zablit wrote: Added it to the list of things to do in separate PRs in this PR's description. https://github.com/llvm/llvm-project/pull/136693 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Upgrade `GetIndexOfChildWithName` to use `llvm::Expected` (PR #136693)
@@ -28,7 +28,7 @@ class GenericBitsetFrontEnd : public SyntheticChildrenFrontEnd { GenericBitsetFrontEnd(ValueObject &valobj, StdLib stdlib); - size_t GetIndexOfChildWithName(ConstString name) override { + llvm::Expected GetIndexOfChildWithName(ConstString name) override { return formatters::ExtractIndexFromString(name.GetCString()); } charles-zablit wrote: Added to the list of tasks to do in another PR, in this PR's description. https://github.com/llvm/llvm-project/pull/136693 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Upgrade `GetIndexOfChildWithName` to use `llvm::Expected` (PR #136693)
https://github.com/charles-zablit edited https://github.com/llvm/llvm-project/pull/136693 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits