[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)
@@ -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
[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] [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] Upgrade ExtractIndexFromString to use llvm::Expected (PR #138297)
https://github.com/charles-zablit created https://github.com/llvm/llvm-project/pull/138297 This PR is in continuation of https://github.com/llvm/llvm-project/pull/136693. It upgrades `ExtractIndexFromString` to use `llvm::Expected`. Rate limit ยท GitHub body { background-color: #f6f8fa; color: #24292e; font-family: -apple-system,BlinkMacSystemFont,Segoe UI,Helvetica,Arial,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol; font-size: 14px; line-height: 1.5; margin: 0; } .container { margin: 50px auto; max-width: 600px; text-align: center; padding: 0 24px; } a { color: #0366d6; text-decoration: none; } a:hover { text-decoration: underline; } h1 { line-height: 60px; font-size: 48px; font-weight: 300; margin: 0px; text-shadow: 0 1px 0 #fff; } p { color: rgba(0, 0, 0, 0.5); margin: 20px 0 40px; } ul { list-style: none; margin: 25px 0; padding: 0; } li { display: table-cell; font-weight: bold; width: 1%; } .logo { display: inline-block; margin-top: 35px; } .logo-img-2x { display: none; } @media only screen and (-webkit-min-device-pixel-ratio: 2), only screen and ( min--moz-device-pixel-ratio: 2), only screen and ( -o-min-device-pixel-ratio: 2/1), only screen and (min-device-pixel-ratio: 2), only screen and (min-resolution: 192dpi), only screen and (min-resolution: 2dppx) { .logo-img-1x { display: none; } .logo-img-2x { display: inline-block; } } #suggestions { margin-top: 35px; color: #ccc; } #suggestions a { color: #66; font-weight: 200; font-size: 14px; margin: 0 10px; } Whoa there! You have exceeded a secondary rate limit. Please wait a few minutes before you try again; in some cases this may take up to an hour. https://support.github.com/contact";>Contact Support โ https://githubstatus.com";>GitHub Status โ https://twitter.com/githubstatus";>@githubstatus ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [clang] [lldb] [windows] fix flaky linker error when building LLDB (PR #138249)
https://github.com/charles-zablit updated https://github.com/llvm/llvm-project/pull/138249 Rate limit ยท GitHub body { background-color: #f6f8fa; color: #24292e; font-family: -apple-system,BlinkMacSystemFont,Segoe UI,Helvetica,Arial,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol; font-size: 14px; line-height: 1.5; margin: 0; } .container { margin: 50px auto; max-width: 600px; text-align: center; padding: 0 24px; } a { color: #0366d6; text-decoration: none; } a:hover { text-decoration: underline; } h1 { line-height: 60px; font-size: 48px; font-weight: 300; margin: 0px; text-shadow: 0 1px 0 #fff; } p { color: rgba(0, 0, 0, 0.5); margin: 20px 0 40px; } ul { list-style: none; margin: 25px 0; padding: 0; } li { display: table-cell; font-weight: bold; width: 1%; } .logo { display: inline-block; margin-top: 35px; } .logo-img-2x { display: none; } @media only screen and (-webkit-min-device-pixel-ratio: 2), only screen and ( min--moz-device-pixel-ratio: 2), only screen and ( -o-min-device-pixel-ratio: 2/1), only screen and (min-device-pixel-ratio: 2), only screen and (min-resolution: 192dpi), only screen and (min-resolution: 2dppx) { .logo-img-1x { display: none; } .logo-img-2x { display: inline-block; } } #suggestions { margin-top: 35px; color: #ccc; } #suggestions a { color: #66; font-weight: 200; font-size: 14px; margin: 0 10px; } Whoa there! You have exceeded a secondary rate limit. Please wait a few minutes before you try again; in some cases this may take up to an hour. https://support.github.com/contact";>Contact Support โ https://githubstatus.com";>GitHub Status โ https://twitter.com/githubstatus";>@githubstatus ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [clang] [lldb] [windows] fix flaky linker error when building LLDB (PR #138249)
https://github.com/charles-zablit closed https://github.com/llvm/llvm-project/pull/138249 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Upgrade ExtractIndexFromString to use llvm::Expected (PR #138297)
@@ -270,10 +270,14 @@ class VectorTypeSyntheticFrontEnd : public SyntheticChildrenFrontEnd { } llvm::Expected GetIndexOfChildWithName(ConstString name) override { -const char *item_name = name.GetCString(); -uint32_t idx = ExtractIndexFromString(item_name); -if (idx == UINT32_MAX || -(idx < UINT32_MAX && idx >= CalculateNumChildrenIgnoringErrors())) +auto idx_or_err = ExtractIndexFromString(name.AsCString()); +if (!idx_or_err) { + llvm::consumeError(idx_or_err.takeError()); + return llvm::createStringError("Type has no child named '%s'", charles-zablit wrote: I ended up switching to `std::optional` following the different discussions. The error message are not very descriptive, and not finding an index did not mean there was an error, but rather that the name was not found in the string. https://github.com/llvm/llvm-project/pull/138297 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Upgrade ExtractIndexFromString to use llvm::Expected (PR #138297)
https://github.com/charles-zablit updated https://github.com/llvm/llvm-project/pull/138297 Rate limit ยท GitHub body { background-color: #f6f8fa; color: #24292e; font-family: -apple-system,BlinkMacSystemFont,Segoe UI,Helvetica,Arial,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol; font-size: 14px; line-height: 1.5; margin: 0; } .container { margin: 50px auto; max-width: 600px; text-align: center; padding: 0 24px; } a { color: #0366d6; text-decoration: none; } a:hover { text-decoration: underline; } h1 { line-height: 60px; font-size: 48px; font-weight: 300; margin: 0px; text-shadow: 0 1px 0 #fff; } p { color: rgba(0, 0, 0, 0.5); margin: 20px 0 40px; } ul { list-style: none; margin: 25px 0; padding: 0; } li { display: table-cell; font-weight: bold; width: 1%; } .logo { display: inline-block; margin-top: 35px; } .logo-img-2x { display: none; } @media only screen and (-webkit-min-device-pixel-ratio: 2), only screen and ( min--moz-device-pixel-ratio: 2), only screen and ( -o-min-device-pixel-ratio: 2/1), only screen and (min-device-pixel-ratio: 2), only screen and (min-resolution: 192dpi), only screen and (min-resolution: 2dppx) { .logo-img-1x { display: none; } .logo-img-2x { display: inline-block; } } #suggestions { margin-top: 35px; color: #ccc; } #suggestions a { color: #66; font-weight: 200; font-size: 14px; margin: 0 10px; } Whoa there! You have exceeded a secondary rate limit. Please wait a few minutes before you try again; in some cases this may take up to an hour. https://support.github.com/contact";>Contact Support โ https://githubstatus.com";>GitHub Status โ https://twitter.com/githubstatus";>@githubstatus ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Upgrade ExtractIndexFromString to use llvm::Expected (PR #138297)
https://github.com/charles-zablit updated https://github.com/llvm/llvm-project/pull/138297 >From 8f62523c8ccece4a1c11af51ccf320b19b2ed013 Mon Sep 17 00:00:00 2001 From: Charles Zablit Date: Fri, 2 May 2025 16:37:09 +0100 Subject: [PATCH 1/2] [lldb] Upgrade ExtractIndexFromString to use llvm::Expected --- .../lldb/DataFormatters/FormattersHelpers.h | 2 +- .../DataFormatters/FormattersHelpers.cpp | 11 ++-- lldb/source/DataFormatters/VectorType.cpp | 12 ++-- .../Language/CPlusPlus/GenericBitset.cpp | 8 ++- .../Language/CPlusPlus/GenericOptional.cpp| 8 ++- .../CPlusPlus/LibCxxInitializerList.cpp | 7 ++- .../Plugins/Language/CPlusPlus/LibCxxList.cpp | 8 ++- .../Plugins/Language/CPlusPlus/LibCxxMap.cpp | 7 ++- .../Language/CPlusPlus/LibCxxProxyArray.cpp | 7 ++- .../Language/CPlusPlus/LibCxxSliceArray.cpp | 8 ++- .../Plugins/Language/CPlusPlus/LibCxxSpan.cpp | 7 ++- .../Language/CPlusPlus/LibCxxTuple.cpp| 8 ++- .../Language/CPlusPlus/LibCxxUnorderedMap.cpp | 7 ++- .../Language/CPlusPlus/LibCxxValarray.cpp | 7 ++- .../Language/CPlusPlus/LibCxxVariant.cpp | 8 ++- .../Language/CPlusPlus/LibCxxVector.cpp | 19 +++--- .../Language/CPlusPlus/LibStdcppTuple.cpp | 7 ++- lldb/source/Plugins/Language/ObjC/NSArray.cpp | 24 --- .../Plugins/Language/ObjC/NSDictionary.cpp| 62 --- .../Plugins/Language/ObjC/NSIndexPath.cpp | 12 ++-- lldb/source/Plugins/Language/ObjC/NSSet.cpp | 36 +++ 21 files changed, 174 insertions(+), 101 deletions(-) diff --git a/lldb/include/lldb/DataFormatters/FormattersHelpers.h b/lldb/include/lldb/DataFormatters/FormattersHelpers.h index a98042fd40f93..82aae705e2a59 100644 --- a/lldb/include/lldb/DataFormatters/FormattersHelpers.h +++ b/lldb/include/lldb/DataFormatters/FormattersHelpers.h @@ -53,7 +53,7 @@ void AddFilter(TypeCategoryImpl::SharedPointer category_sp, llvm::StringRef type_name, ScriptedSyntheticChildren::Flags flags, bool regex = false); -size_t ExtractIndexFromString(const char *item_name); +llvm::Expected ExtractIndexFromString(const char *item_name); Address GetArrayAddressOrPointerValue(ValueObject &valobj); diff --git a/lldb/source/DataFormatters/FormattersHelpers.cpp b/lldb/source/DataFormatters/FormattersHelpers.cpp index 085ed3d0a2f29..5e29794c291be 100644 --- a/lldb/source/DataFormatters/FormattersHelpers.cpp +++ b/lldb/source/DataFormatters/FormattersHelpers.cpp @@ -97,18 +97,19 @@ void lldb_private::formatters::AddFilter( category_sp->AddTypeFilter(type_name, match_type, filter_sp); } -size_t lldb_private::formatters::ExtractIndexFromString(const char *item_name) { +llvm::Expected +lldb_private::formatters::ExtractIndexFromString(const char *item_name) { if (!item_name || !*item_name) -return UINT32_MAX; +return llvm::createStringError("String has no item named '%s'", item_name); if (*item_name != '[') -return UINT32_MAX; +return llvm::createStringError("String has no item named '%s'", item_name); item_name++; char *endptr = nullptr; unsigned long int idx = ::strtoul(item_name, &endptr, 0); if (idx == 0 && endptr == item_name) -return UINT32_MAX; +return llvm::createStringError("String has no item named '%s'", item_name); if (idx == ULONG_MAX) -return UINT32_MAX; +return llvm::createStringError("String has no item named '%s'", item_name); return idx; } diff --git a/lldb/source/DataFormatters/VectorType.cpp b/lldb/source/DataFormatters/VectorType.cpp index eab2612d1e941..3fa616b9d9b14 100644 --- a/lldb/source/DataFormatters/VectorType.cpp +++ b/lldb/source/DataFormatters/VectorType.cpp @@ -270,10 +270,14 @@ class VectorTypeSyntheticFrontEnd : public SyntheticChildrenFrontEnd { } llvm::Expected GetIndexOfChildWithName(ConstString name) override { -const char *item_name = name.GetCString(); -uint32_t idx = ExtractIndexFromString(item_name); -if (idx == UINT32_MAX || -(idx < UINT32_MAX && idx >= CalculateNumChildrenIgnoringErrors())) +auto idx_or_err = ExtractIndexFromString(name.AsCString()); +if (!idx_or_err) { + llvm::consumeError(idx_or_err.takeError()); + return llvm::createStringError("Type has no child named '%s'", + name.AsCString()); +} +uint32_t idx = *idx_or_err; +if (idx >= CalculateNumChildrenIgnoringErrors()) return llvm::createStringError("Type has no child named '%s'", name.AsCString()); return idx; diff --git a/lldb/source/Plugins/Language/CPlusPlus/GenericBitset.cpp b/lldb/source/Plugins/Language/CPlusPlus/GenericBitset.cpp index 234471d5ba518..ebcac0a48bd30 100644 --- a/lldb/source/Plugins/Language/CPlusPlus/GenericBitset.cpp +++ b/lldb/source/Plugins/Language/CPlusPlus/GenericBitset.cpp @@ -29,11 +29,13 @@ class GenericBitsetFrontEnd : public SyntheticChildrenFrontEnd { Gener
[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
[Lldb-commits] [lldb] [windows] fix flaky linker error when building LLDB (PR #138249)
https://github.com/charles-zablit created https://github.com/llvm/llvm-project/pull/138249 When building LLDB on Windows with `build.ps1`, the following linker error happens, especially after rebuilding incrementally. The error sometimes goes away after deleting CMakeCache.txt, but that's not reliable. ``` [1/4][ 25%][39.728s] Linking CXX shared library bin\liblldb.dll FAILED: bin/liblldb.dll lib/liblldb.lib C:\WINDOWS\system32\cmd.exe /C "cd . && "C:\Program Files\Microsoft Visual Studio\2022\Community\Common7\IDE\CommonExtensions\Microsoft\CMake\CMake\bin\cmake.exe" -E vs_link_dll --intdir=tools\lldb\source\API\CMakeFiles\liblldb.dir --rc=C:\PROGRA~2\WI3CF2~1\10\bin\100261~1.0\arm64\rc.exe --mt=C:\PROGRA~2\WI3CF2~1\10\bin\100261~1.0\arm64\mt.exe --manifests -- C:\PROGRA~1\MICROS~2\2022\COMMUN~1\VC\Tools\MSVC\1443~1.348\bin\HOSTAR~1\arm64\link.exe /nologo @CMakeFiles\liblldb.rsp /out:bin\liblldb.dll /implib:lib\liblldb.lib /pdb:bin\liblldb.pdb /dll /version:19.1 /machine:ARM64 /INCREMENTAL:NO && cd ." LINK: command "C:\PROGRA~1\MICROS~2\2022\COMMUN~1\VC\Tools\MSVC\1443~1.348\bin\HOSTAR~1\arm64\link.exe /nologo @CMakeFiles\liblldb.rsp /out:bin\liblldb.dll /implib:lib\liblldb.lib /pdb:bin\liblldb.pdb /dll /version:19.1 /machine:ARM64 /INCREMENTAL:NO /MANIFEST:EMBED,ID=2" failed (exit code 1120) with the following output: Creating library lib\liblldb.lib and object lib\liblldb.exp swiftrt.obj : error LNK2019: unresolved external symbol __imp_swift_addNewDSOImage referenced in function "void __cdecl swift_image_constructor(void)" (?swift_image_constructor@@YAXXZ) bin\liblldb.dll : fatal error LNK1120: 1 unresolved externals ninja: build stopped: subcommand failed. ``` This PR fixes this build error. >From 4884f915925804c5bde54ac80a4c3dc2e9128146 Mon Sep 17 00:00:00 2001 From: Charles Zablit Date: Fri, 2 May 2025 11:51:51 +0100 Subject: [PATCH] [windows] fix flaky linker error when building LLDB --- lldb/source/API/CMakeLists.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/lldb/source/API/CMakeLists.txt b/lldb/source/API/CMakeLists.txt index 3bc569608e458..715aa4344f37c 100644 --- a/lldb/source/API/CMakeLists.txt +++ b/lldb/source/API/CMakeLists.txt @@ -142,6 +142,7 @@ add_lldb_library(liblldb SHARED ${option_framework} lldbValueObject lldbVersion ${LLDB_ALL_PLUGINS} +swiftCore LINK_COMPONENTS Support ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [clang] [lldb] [windows] fix flaky linker error when building LLDB (PR #138249)
https://github.com/charles-zablit edited https://github.com/llvm/llvm-project/pull/138249 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [clang] [lldb] [windows] fix flaky linker error when building LLDB (PR #138249)
@@ -142,6 +142,7 @@ add_lldb_library(liblldb SHARED ${option_framework} lldbValueObject lldbVersion ${LLDB_ALL_PLUGINS} +swiftCore charles-zablit wrote: You are correct, sorry about that. I opened the PR here: https://github.com/llvm/llvm-project/pull/138297 https://github.com/llvm/llvm-project/pull/138249 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits