Skip to content

Commit bf75a76

Browse files
fixup! upgrade Swift plugin to use llvm::Expected for GetIndexOfChildWithName
1 parent 392cbd1 commit bf75a76

File tree

4 files changed

+8
-8
lines changed

4 files changed

+8
-8
lines changed

lldb/source/Plugins/Language/Swift/FoundationValueTypes.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -635,14 +635,13 @@ class URLComponentsSyntheticChildrenFrontEnd
635635
m_synth_frontend_up->Update();
636636

637637
#define COMPONENT(Name, PrettyName, ID) \
638-
auto index_or_err = \
639-
synthetic_children->GetIndexOfChildWithName(s_FuncPtr_name); \
638+
auto index_or_err = m_synth_frontend_up->GetIndexOfChildWithName(g__##Name); \
640639
if (!index_or_err) { \
641640
LLDB_LOG_ERROR(GetLog(LLDBLog::DataFormatters), index_or_err.takeError(), \
642641
"{0}"); \
643642
return ChildCacheState::eRefetch; \
644643
} \
645-
m_##Name = m_synth_frontend_up->GetChildAtIndex(index_or_err).get(); \
644+
m_##Name = m_synth_frontend_up->GetChildAtIndex(*index_or_err).get(); \
646645
if (m_##Name) \
647646
m_##Name->SetName(GetNameFor##Name());
648647
#include "URLComponents.def"

lldb/source/Plugins/Language/Swift/SwiftArray.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -515,8 +515,7 @@ llvm::Expected<size_t> lldb_private::formatters::swift::ArraySyntheticFrontEnd::
515515
name.AsCString());
516516
const char *item_name = name.GetCString();
517517
uint32_t idx = ExtractIndexFromString(item_name);
518-
if ((idx == UINT32_MAX) ||
519-
(idx < UINT32_MAX && idx >= CalculateNumChildrenIgnoringErrors()))
518+
if (idx == UINT32_MAX || idx >= CalculateNumChildrenIgnoringErrors())
520519
return llvm::createStringError("Type has no child named '%s'",
521520
name.AsCString());
522521
return idx;

lldb/source/Plugins/Language/Swift/SwiftFormatters.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1536,7 +1536,10 @@ lldb_private::formatters::swift::EnumSyntheticFrontEnd::Update() {
15361536
m_exe_ctx_ref = m_backend.GetExecutionContextRef();
15371537
m_element_name.SetCString(m_backend.GetValueAsCString());
15381538
auto index_or_err = m_backend.GetIndexOfChildWithName(m_element_name);
1539-
m_child_index = !index_or_err : UINT32_MAX : *index_or_err;
1539+
if (!index_or_err)
1540+
llvm::consumeError(index_or_err.takeError());
1541+
else
1542+
m_child_index = *index_or_err;
15401543
return ChildCacheState::eRefetch;
15411544
}
15421545

lldb/source/Plugins/Language/Swift/SwiftHashedContainer.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -738,8 +738,7 @@ HashedSyntheticChildrenFrontEnd::GetIndexOfChildWithName(ConstString name) {
738738
name.AsCString());
739739
const char *item_name = name.GetCString();
740740
uint32_t idx = ExtractIndexFromString(item_name);
741-
if ((idx == UINT32_MAX) ||
742-
(idx < UINT32_MAX && idx >= CalculateNumChildrenIgnoringErrors()))
741+
if (idx == UINT32_MAX || idx >= CalculateNumChildrenIgnoringErrors())
743742
return llvm::createStringError("Type has no child named '%s'",
744743
name.AsCString());
745744
return idx;

0 commit comments

Comments
 (0)