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

Alex Langford via llvm-commits llvm-commits at lists.llvm.org
Wed Oct 4 12:33:46 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());
----------------
bulbazord wrote:

Yes, the errors will be grouped together in this case. As you said, we would previously report the inner error through the DWARFContext and then the caller would report an error "Failed to parse CU header in DWP file". This does slightly change behavior such that "Failed to parse CU header in DWP file" will get reported first with the inner error message following afterwards.

I'll see if there are any existing tests that are suitable to extend or copy. If not, I may need help producing one. 😅 

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


More information about the llvm-commits mailing list