[Lldb-commits] [lldb] [lldb] Fix logic bugs in BytecodeSyntheticChildren (PR #227483)
via lldb-commits
lldb-commits at lists.llvm.org
Tue Sep 29 14:46:11 PDT 2026
llvmorg-github-actions[bot] wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-lldb
Author: Dave Lee (kastiglione)
<details>
<summary>Changes</summary>
---
Full diff: https://github.com/llvm/llvm-project/pull/227483.diff
1 Files Affected:
- (modified) lldb/source/DataFormatters/TypeSynthetic.cpp (+6-6)
``````````diff
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;
``````````
</details>
https://github.com/llvm/llvm-project/pull/227483
More information about the lldb-commits
mailing list