[Lldb-commits] [lldb] [lldb] Upgrade ExtractIndexFromString to use llvm::Expected (PR #138297)
Adrian Prantl via lldb-commits
lldb-commits at lists.llvm.org
Fri May 2 15:07:24 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'",
----------------
adrian-prantl wrote:
See my comment above. I would probably just return optional from ExtractIndexFromString, since the error message isn't that useful. But if it were useful, I wanted to point out that we also have llvm::joinErrors()
https://github.com/llvm/llvm-project/pull/138297
More information about the lldb-commits
mailing list