[lldb] Do not narrow GetIndexOfChildWithName return type to int (#165453)

Modify the python wrapper to return uint32_t,
which prevents incorrect child name-to-index mapping and avoids
performing redundant operations on non-existent SBValues.
This commit is contained in:
Ebuka Ezike authored and GitHub committed 2025-10-29 18:22:54 +00:00
1 parent ba769e125b
commit d87c80bd46
6 files changed
+11 -9

No files matched your search

@@ -1939,7 +1939,7 @@ lldb::ValueObjectSP ScriptInterpreterPythonImpl::GetChildAtIndex(
return ret_val;
}
llvm::Expected<int> ScriptInterpreterPythonImpl::GetIndexOfChildWithName(
llvm::Expected<uint32_t> ScriptInterpreterPythonImpl::GetIndexOfChildWithName(
const StructuredData::ObjectSP &implementor_sp, const char *child_name) {
if (!implementor_sp)
return llvm::createStringError("Type has no child named '%s'", child_name);
@@ -1951,7 +1951,7 @@ llvm::Expected<int> ScriptInterpreterPythonImpl::GetIndexOfChildWithName(
if (!implementor)
return llvm::createStringError("Type has no child named '%s'", child_name);
int ret_val = INT32_MAX;
uint32_t ret_val = UINT32_MAX;
{
Locker py_lock(this,
@@ -1960,7 +1960,7 @@ llvm::Expected<int> ScriptInterpreterPythonImpl::GetIndexOfChildWithName(
child_name);
}
if (ret_val == INT32_MAX)
if (ret_val == UINT32_MAX)
return llvm::createStringError("Type has no child named '%s'", child_name);
return ret_val;
}