summaryrefslogtreecommitdiff
path: root/lldb/source/Plugins/Language/ObjC/NSException.cpp
diff options
context:
space:
mode:
authorCharles Zablit <c_zablit@apple.com>2025-04-30 12:44:19 +0200
committerGitHub <noreply@github.com>2025-04-30 11:44:19 +0100
commitb3d130279f5c59a82d48d4647bef626ac4e202cf (patch)
tree0da0af37fec618f40d3b0b5a7a593d554308fdd8 /lldb/source/Plugins/Language/ObjC/NSException.cpp
parent92195f6fc873cd27a5aa0852252dfe44ccdc6ea0 (diff)
[lldb] Upgrade `GetIndexOfChildWithName` to use `llvm::Expected` (#136693)
This patch replaces the use of `UINT32_MAX` as the error return value of `GetIndexOfChildWithName` with `llvm::Expected`. # Tasks to do in another PR 1. Replace `CalculateNumChildrenIgnoringErrors` with `CalculateNumChildren`. See [this comment](https://github.com/llvm/llvm-project/pull/136693#discussion_r2056319358). 2. Update `lldb_private::formatters::ExtractIndexFromString` to use `llvm::Expected`. See [this comment](https://github.com/llvm/llvm-project/pull/136693#discussion_r2054217536). 3. Create a new class which carries both user and internal errors. See [this comment](https://github.com/llvm/llvm-project/pull/136693#discussion_r2056439608).
Diffstat (limited to 'lldb/source/Plugins/Language/ObjC/NSException.cpp')
-rw-r--r--lldb/source/Plugins/Language/ObjC/NSException.cpp5
1 files changed, 3 insertions, 2 deletions
diff --git a/lldb/source/Plugins/Language/ObjC/NSException.cpp b/lldb/source/Plugins/Language/ObjC/NSException.cpp
index 67f3f1779e14..e27c7e0e97be 100644
--- a/lldb/source/Plugins/Language/ObjC/NSException.cpp
+++ b/lldb/source/Plugins/Language/ObjC/NSException.cpp
@@ -148,7 +148,7 @@ public:
: lldb::ChildCacheState::eRefetch;
}
- size_t GetIndexOfChildWithName(ConstString name) override {
+ llvm::Expected<size_t> GetIndexOfChildWithName(ConstString name) override {
// NSException has 4 members:
// NSString *name;
// NSString *reason;
@@ -162,7 +162,8 @@ public:
if (name == g_reason) return 1;
if (name == g_userInfo) return 2;
if (name == g_reserved) return 3;
- return UINT32_MAX;
+ return llvm::createStringError("Type has no child named '%s'",
+ name.AsCString());
}
private: