[llvm] [DebugInfo] Separate error generation from reporting in DWARFHeaderUnit::extract (PR #68242)

James Henderson via llvm-commits llvm-commits at lists.llvm.org
Tue Oct 17 00:20:16 PDT 2023


================
@@ -89,9 +89,12 @@ void fixupIndexV4(DWARFContext &C, DWARFUnitIndex &Index) {
     DWARFDataExtractor Data(DObj, S, C.isLittleEndian(), 0);
     while (Data.isValidOffset(Offset)) {
       DWARFUnitHeader Header;
-      if (!Header.extract(C, Data, &Offset, DWARFSectionKind::DW_SECT_INFO)) {
+      if (Error ExtractionErr = Header.extract(
+              C, Data, &Offset, DWARFSectionKind::DW_SECT_INFO)) {
         logAllUnhandledErrors(
-            createError("Failed to parse CU header in DWP file"), errs());
+            joinErrors(createError("Failed to parse CU header in DWP file"),
+                       std::move(ExtractionErr)),
+            errs());
----------------
jh7370 wrote:

I think you don't want to use `joinErrors` here. This will result in two separate errors that are reported individually, rather than one error with an outer and an inner context. A better way would be to create a new `Error` that concatenates the necessary messages. We use this trick in llvm-readobj, for example. See https://github.com/llvm/llvm-project/blob/bfcd05317d0fbe90474eda13a4dbf33c2cee4130/llvm/tools/llvm-readobj/ELFDumper.cpp#L486.

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


More information about the llvm-commits mailing list