[Lldb-commits] [lldb] [lldb] Upgrade ExtractIndexFromString to use llvm::Expected (PR #138297)
Charles Zablit via lldb-commits
lldb-commits at lists.llvm.org
Tue May 6 05:00:04 PDT 2025
================
@@ -270,10 +270,14 @@ class VectorTypeSyntheticFrontEnd : public SyntheticChildrenFrontEnd {
}
llvm::Expected<size_t> GetIndexOfChildWithName(ConstString name) override {
- const char *item_name = name.GetCString();
- uint32_t idx = ExtractIndexFromString(item_name);
- if (idx == UINT32_MAX ||
- (idx < UINT32_MAX && idx >= CalculateNumChildrenIgnoringErrors()))
+ auto idx_or_err = ExtractIndexFromString(name.AsCString());
+ if (!idx_or_err) {
+ llvm::consumeError(idx_or_err.takeError());
+ return llvm::createStringError("Type has no child named '%s'",
----------------
charles-zablit wrote:
I ended up switching to `std::optional` following the different discussions. The error message are not very descriptive, and not finding an index did not mean there was an error, but rather that the name was not found in the string.
https://github.com/llvm/llvm-project/pull/138297
More information about the lldb-commits
mailing list