[llvm] 52ae3b5 - [DWARF][MC] improve the error message when DwarfLineStrSection is null.

via llvm-commits llvm-commits at lists.llvm.org
Sun May 7 21:56:53 PDT 2023


Author: esmeyi
Date: 2023-05-08T00:55:27-04:00
New Revision: 52ae3b5725441dca252c6e7bbbb23fc7c316a591

URL: https://github.com/llvm/llvm-project/commit/52ae3b5725441dca252c6e7bbbb23fc7c316a591
DIFF: https://github.com/llvm/llvm-project/commit/52ae3b5725441dca252c6e7bbbb23fc7c316a591.diff

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

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

Reviewed By: shchenz

Differential Revision: https://reviews.llvm.org/D149121

Added: 
    

Modified: 
    llvm/lib/MC/MCDwarf.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/MC/MCDwarf.cpp b/llvm/lib/MC/MCDwarf.cpp
index 6acfd08d4ce6..9506b5cd5929 100644
--- a/llvm/lib/MC/MCDwarf.cpp
+++ b/llvm/lib/MC/MCDwarf.cpp
@@ -78,9 +78,12 @@ static inline uint64_t ScaleAddrDelta(MCContext &Context, uint64_t AddrDelta) {
 
 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();
+  }
 }
 
 //


        


More information about the llvm-commits mailing list