[Lldb-commits] [lldb] 7e89fb5 - [lldb] Fix logic bugs in BytecodeSyntheticChildren (#227483)
via lldb-commits
lldb-commits at lists.llvm.org
Wed Sep 30 09:46:40 PDT 2026
Author: Dave Lee
Date: 2026-09-30T09:46:33-07:00
New Revision: 7e89fb5d646ef2d4b18520a8300818b5b94ef587
URL: https://github.com/llvm/llvm-project/commit/7e89fb5d646ef2d4b18520a8300818b5b94ef587
DIFF: https://github.com/llvm/llvm-project/commit/7e89fb5d646ef2d4b18520a8300818b5b94ef587.diff
LOG: [lldb] Fix logic bugs in BytecodeSyntheticChildren (#227483)
Fix a pair of bugs in `BytecodeSyntheticChildren`.
1. Fix conditions that should compare with `>= 0` (not `> 0`)
2. Fix an inverted conditional when checking if a formatter implements
`@get_child_index`
Assisted-by: claude
Added:
Modified:
lldb/source/DataFormatters/TypeSynthetic.cpp
Removed:
################################################################################
diff --git a/lldb/source/DataFormatters/TypeSynthetic.cpp b/lldb/source/DataFormatters/TypeSynthetic.cpp
index c144717cadbf9..16401049f93b8 100644
--- a/lldb/source/DataFormatters/TypeSynthetic.cpp
+++ b/lldb/source/DataFormatters/TypeSynthetic.cpp
@@ -368,14 +368,14 @@ BytecodeSyntheticChildren::FrontEnd::CalculateNumChildren() {
if (*u <= UINT32_MAX)
return *u;
if (auto *i = std::get_if<int64_t>(&top)) {
- if (*i > 0 && *i <= UINT32_MAX)
+ if (*i >= 0 && *i <= UINT32_MAX)
return *i;
return UINT32_MAX;
}
if (auto *ap = std::get_if<llvm::APSInt>(&top)) {
if (ap->isRepresentableByInt64()) {
int64_t v = ap->getExtValue();
- if (v > 0 && v <= UINT32_MAX)
+ if (v >= 0 && v <= UINT32_MAX)
return static_cast<uint32_t>(v);
}
return UINT32_MAX;
@@ -416,8 +416,8 @@ BytecodeSyntheticChildren::FrontEnd::GetChildAtIndex(uint32_t idx) {
llvm::Expected<size_t>
BytecodeSyntheticChildren::FrontEnd::GetIndexOfChildWithName(ConstString name) {
- if (m_impl.get_child_index)
- return -1;
+ if (!m_impl.get_child_index)
+ return llvm::createStringErrorV("type has no child named '{0}'", name);
FormatterBytecode::ControlStack control = {
m_impl.get_child_index->getBuffer()};
@@ -439,14 +439,14 @@ BytecodeSyntheticChildren::FrontEnd::GetIndexOfChildWithName(ConstString name) {
if (*u <= SIZE_MAX)
return *u;
if (auto *i = std::get_if<int64_t>(&top)) {
- if (*i > 0 && static_cast<uint64_t>(*i) <= SIZE_MAX)
+ if (*i >= 0 && static_cast<uint64_t>(*i) <= SIZE_MAX)
return *i;
return SIZE_MAX;
}
if (auto *ap = std::get_if<llvm::APSInt>(&top)) {
if (ap->isRepresentableByInt64()) {
int64_t v = ap->getExtValue();
- if (v > 0 && static_cast<uint64_t>(v) <= SIZE_MAX)
+ if (v >= 0 && static_cast<uint64_t>(v) <= SIZE_MAX)
return static_cast<size_t>(v);
}
return SIZE_MAX;
More information about the lldb-commits
mailing list