[PATCH] D26526: Clean up DWARFFormValue by reducing duplicated code and removing DWARFFormValue::getFixedFormSizes()

Greg Clayton via llvm-commits llvm-commits at lists.llvm.org
Thu Nov 10 16:05:05 PST 2016


clayborg updated this revision to Diff 77566.
clayborg added a comment.

Ok, I think this will keep David happy. I templatized the static functions:

  template <class T> static Optional<uint8_t> getFixedByteSize(dwarf::Form Form, const T *U);
  template <class T> static bool skipFormValue(dwarf::Form Form, const DataExtractor &DebugInfoData, uint32_t *OffsetPtr, const T *U);

This means they can be called directly with a "const DWARFUnit *" or we can make a local FormSizeHelper instance and pass the address of that. The template assumes that the following functions can be call on T:

  class T {
  public:
    uint8_t getAddressByteSize() const;
    uint8_t getRefAddrByteSize() const;
    uint8_t getDwarfOffsetByteSize() const;
  };

FormSizeHelper doesn't have a vtable anymore and the template functions will ensure I get the laziness that I was trying for.


https://reviews.llvm.org/D26526

Files:
  include/llvm/DebugInfo/DWARF/DWARFFormValue.h
  include/llvm/DebugInfo/DWARF/DWARFUnit.h
  include/llvm/Support/Dwarf.h
  lib/DebugInfo/DWARF/DWARFDebugInfoEntry.cpp
  lib/DebugInfo/DWARF/DWARFFormValue.cpp
  tools/llvm-dwp/llvm-dwp.cpp
  unittests/DebugInfo/DWARF/DWARFFormValueTest.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D26526.77566.patch
Type: text/x-patch
Size: 26154 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20161111/78155bb4/attachment.bin>


More information about the llvm-commits mailing list