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

James Henderson via llvm-commits llvm-commits at lists.llvm.org
Tue Jun 25 01:05:09 PDT 2024


================
@@ -1924,8 +1968,11 @@ MachOObjectFile::getSymbolSection(DataRefImpl Symb) const {
 }
 
 unsigned MachOObjectFile::getSymbolSectionID(SymbolRef Sym) const {
-  MachO::nlist_base Entry =
-      getSymbolTableEntryBase(*this, Sym.getRawDataRefImpl());
+    auto EntryOrErr = getSymbolTableEntryBase(*this, Sym.getRawDataRefImpl());
+  if (!EntryOrErr)
+    report_fatal_error(EntryOrErr.takeError());
----------------
jh7370 wrote:

As noted before, please add a FIXME to these cases, to indicate that this is still suboptimal. You don't need to propagate the error all the way up the stack in the same PR - that can be tackled on another occasion.

Same goes for below instances of `report_fatal_error` that you've added.

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


More information about the llvm-commits mailing list