[PATCH] D84092: [DebugInfo] Make DIELocList::SizeOf() more explicit. NFCI.

Igor Kudrin via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sat Jul 18 04:32:28 PDT 2020


ikudrin created this revision.
ikudrin added reviewers: dblaikie, echristo, jhenderson, aprantl.
ikudrin added projects: LLVM, debug-info.
Herald added a subscriber: hiraditya.

`DIELocList` is used with a limited number of DWARF forms, see the only place where it is instantiated, `DwarfCompileUnit::addLocationList()`.

The patch marks the unexpected execution path in `DIELocList::SizeOf()` as unreachable, to reduce ambiguity.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D84092

Files:
  llvm/lib/CodeGen/AsmPrinter/DIE.cpp


Index: llvm/lib/CodeGen/AsmPrinter/DIE.cpp
===================================================================
--- llvm/lib/CodeGen/AsmPrinter/DIE.cpp
+++ llvm/lib/CodeGen/AsmPrinter/DIE.cpp
@@ -809,13 +809,17 @@
 //===----------------------------------------------------------------------===//
 
 unsigned DIELocList::SizeOf(const AsmPrinter *AP, dwarf::Form Form) const {
-  if (Form == dwarf::DW_FORM_loclistx)
+  switch (Form) {
+  case dwarf::DW_FORM_loclistx:
     return getULEB128Size(Index);
-  if (Form == dwarf::DW_FORM_data4)
+  case dwarf::DW_FORM_data4:
     return 4;
-  if (Form == dwarf::DW_FORM_sec_offset)
+  case dwarf::DW_FORM_sec_offset:
+    // FIXME: add support for DWARF64
     return 4;
-  return AP->MAI->getCodePointerSize();
+  default:
+    llvm_unreachable("DIE Value form not supported yet");
+  }
 }
 
 /// EmitValue - Emit label value.


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D84092.278986.patch
Type: text/x-patch
Size: 871 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200718/8b74e3a8/attachment.bin>


More information about the llvm-commits mailing list