Skip to content

Commit a0f367f

Browse files
committed
[DWARF] Make dwarf::getDwarfOffsetByteSize() a free function. NFC.
This will help simplify code in upcoming patches and make some expressions constexpr. Differential Revision: https://reviews.llvm.org/D73039
1 parent d6f39cf commit a0f367f

File tree

1 file changed

+12
-7
lines changed
  • llvm/include/llvm/BinaryFormat

1 file changed

+12
-7
lines changed

llvm/include/llvm/BinaryFormat/Dwarf.h

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -532,6 +532,17 @@ unsigned LanguageVendor(SourceLanguage L);
532532

533533
Optional<unsigned> LanguageLowerBound(SourceLanguage L);
534534

535+
/// The size of a reference determined by the DWARF 32/64-bit format.
536+
constexpr uint8_t getDwarfOffsetByteSize(DwarfFormat Format) {
537+
switch (Format) {
538+
case DwarfFormat::DWARF32:
539+
return 4;
540+
case DwarfFormat::DWARF64:
541+
return 8;
542+
}
543+
llvm_unreachable("Invalid Format value");
544+
}
545+
535546
/// A helper struct providing information about the byte size of DW_FORM
536547
/// values that vary in size depending on the DWARF version, address byte
537548
/// size, or DWARF32/DWARF64.
@@ -551,13 +562,7 @@ struct FormParams {
551562

552563
/// The size of a reference is determined by the DWARF 32/64-bit format.
553564
uint8_t getDwarfOffsetByteSize() const {
554-
switch (Format) {
555-
case DwarfFormat::DWARF32:
556-
return 4;
557-
case DwarfFormat::DWARF64:
558-
return 8;
559-
}
560-
llvm_unreachable("Invalid Format value");
565+
return dwarf::getDwarfOffsetByteSize(Format);
561566
}
562567

563568
explicit operator bool() const { return Version && AddrSize; }

0 commit comments

Comments
 (0)