[PATCH] D84095: [DebugInfo] Make DIEDelta::SizeOf() more explicit. NFCI.

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


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

The patch restricts `DIEDelta::SizeOf()` to accept only DWARF forms that are actually used in the LLVM codebase. This should make the use of the class more explicit and help to avoid issues similar to fixed in D83958 <https://reviews.llvm.org/D83958> and D84094 <https://reviews.llvm.org/D84094>.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D84095

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
@@ -549,10 +549,15 @@
 /// SizeOf - Determine size of delta value in bytes.
 ///
 unsigned DIEDelta::SizeOf(const AsmPrinter *AP, dwarf::Form Form) const {
-  if (Form == dwarf::DW_FORM_data4) return 4;
-  if (Form == dwarf::DW_FORM_sec_offset) return 4;
-  if (Form == dwarf::DW_FORM_strp) return 4;
-  return AP->MAI->getCodePointerSize();
+  switch (Form) {
+  case dwarf::DW_FORM_data4:
+    return 4;
+  case dwarf::DW_FORM_sec_offset:
+    // FIXME: add support for DWARF64
+    return 4;
+  default:
+    llvm_unreachable("DIE Value form not supported yet");
+  }
 }
 
 LLVM_DUMP_METHOD


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D84095.278989.patch
Type: text/x-patch
Size: 785 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200718/55efd221/attachment.bin>


More information about the llvm-commits mailing list