[Lldb-commits] [lldb] [lldb] Upgrade `GetIndexOfChildWithName` to use `llvm::Expected` (PR #136693)

Michael Buch via lldb-commits lldb-commits at lists.llvm.org
Thu Apr 24 04:43:30 PDT 2025


================
@@ -103,9 +103,20 @@ lldb_private::formatters::LibcxxInitializerListSyntheticFrontEnd::Update() {
 llvm::Expected<size_t>
 lldb_private::formatters::LibcxxInitializerListSyntheticFrontEnd::
     GetIndexOfChildWithName(ConstString name) {
-  if (!m_start)
-    return UINT32_MAX;
-  return ExtractIndexFromString(name.GetCString());
+  if (!m_start) {
+    return llvm::createStringError(
+        "'SyntheticChildrenFrontend::LibcxxInitializerListSyntheticFrontEnd' "
+        "cannot find index of child '%s': Invalid start pointer.",
+        name.AsCString());
+  }
+  size_t idx = ExtractIndexFromString(name.GetCString());
+  if (idx == UINT32_MAX) {
+    return llvm::createStringError(
+        "'SyntheticChildrenFrontend::LibcxxInitializerListSyntheticFrontEnd' "
----------------
Michael137 wrote:

```suggestion
        "'LibcxxInitializerListSyntheticFrontEnd' "
```
(and above too)

https://github.com/llvm/llvm-project/pull/136693


More information about the lldb-commits mailing list