[llvm] [MachO] Replace getStruct with getStructOrErr (PR #95810)

James Henderson via llvm-commits llvm-commits at lists.llvm.org
Tue Jun 18 00:28:12 PDT 2024


================
@@ -118,7 +104,10 @@ static const char *getPtr(const MachOObjectFile &O, size_t Offset,
 static MachO::nlist_base
 getSymbolTableEntryBase(const MachOObjectFile &O, DataRefImpl DRI) {
   const char *P = reinterpret_cast<const char *>(DRI.p);
-  return getStruct<MachO::nlist_base>(O, P);
+  auto NListOrErr = getStructOrErr<MachO::nlist_base>(O, P);
+  if (!NListOrErr)
+    report_fatal_error(NListOrErr.takeError());
----------------
jh7370 wrote:

Please add a FIXME here to indicate that this is still not ideal: the error should be propagated up the stack, to be reported using the tool's error reporting mechanism.

The same comment applies to every other place you've changed where there's a `report_fatal_error` call now.

https://github.com/llvm/llvm-project/pull/95810


More information about the llvm-commits mailing list