================
@@ -165,12 +172,12 @@ 
SystemRuntimeMacOSX::GetQueueNameFromThreadQAddress(addr_t dispatch_qaddr) {
 lldb::addr_t SystemRuntimeMacOSX::GetLibdispatchQueueAddressFromThreadQAddress(
     addr_t dispatch_qaddr) {
   addr_t libdispatch_queue_t_address = LLDB_INVALID_ADDRESS;
-  Status error;
-  libdispatch_queue_t_address =
-      m_process->ReadPointerFromMemory(dispatch_qaddr, error);
-  if (!error.Success()) {
-    libdispatch_queue_t_address = LLDB_INVALID_ADDRESS;
-  }
+  llvm::Expected<lldb::addr_t> libdispatch_queue_t_address_or_err =
+      m_process->ReadPointerFromMemory(dispatch_qaddr);
+  if (libdispatch_queue_t_address_or_err)
+    libdispatch_queue_t_address = *libdispatch_queue_t_address_or_err;
+  else
+    llvm::consumeError(libdispatch_queue_t_address_or_err.takeError());
----------------
felipepiovezan wrote:

Another good example where the suffixed variables are unnecessary and just 
complicate the code.
The current version just obfuscates the error return value.

```suggestion
  llvm::Expected<lldb::addr_t> libdispatch_queue_t_address =  
m_process->ReadPointerFromMemory(dispatch_qaddr);
  if (libdispatch_queue_t_address)
    return *libdispatch_queue_t_address;
  llvm::consumeError(libdispatch_queue_t_address_or_err.takeError());
  return LLDB_INVALID_ADDRESS;
```

https://github.com/llvm/llvm-project/pull/216389
_______________________________________________
lldb-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits

Reply via email to