[PATCH] D149121: [DWARF][MC] improve the error message when DwarfLineStrSection is null.

Esme Yi via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Apr 24 22:14:42 PDT 2023


Esme created this revision.
Esme added reviewers: shchenz, maksfb, PowerPC.
Herald added a subscriber: hiraditya.
Herald added a project: All.
Esme requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Currently the crush info is ambiguous when DwarfLineStrSection is null.
The patch adds an assertion in the constructor of MCDwarfLineStr when DwarfLineStrSection is null.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D149121

Files:
  llvm/lib/MC/MCDwarf.cpp


Index: llvm/lib/MC/MCDwarf.cpp
===================================================================
--- llvm/lib/MC/MCDwarf.cpp
+++ llvm/lib/MC/MCDwarf.cpp
@@ -78,9 +78,12 @@
 
 MCDwarfLineStr::MCDwarfLineStr(MCContext &Ctx) {
   UseRelocs = Ctx.getAsmInfo()->doesDwarfUseRelocationsAcrossSections();
-  if (UseRelocs)
-    LineStrLabel =
-        Ctx.getObjectFileInfo()->getDwarfLineStrSection()->getBeginSymbol();
+  if (UseRelocs) {
+    MCSection *DwarfLineStrSection =
+        Ctx.getObjectFileInfo()->getDwarfLineStrSection();
+    assert(DwarfLineStrSection && "DwarfLineStrSection must not be NULL");
+    LineStrLabel = DwarfLineStrSection->getBeginSymbol();
+  }
 }
 
 //


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D149121.516622.patch
Type: text/x-patch
Size: 683 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230425/4f506ccb/attachment.bin>


More information about the llvm-commits mailing list