Revert r354244 "[DAGCombiner] Eliminate dead stores to stack."
[llvm-complete.git] / lib / BinaryFormat / Dwarf.cpp
blob73f04a3ed2897643052d6c5352a359876c62912c
1 //===-- llvm/BinaryFormat/Dwarf.cpp - Dwarf Framework ------------*- C++-*-===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 //
9 // This file contains support for generic dwarf information.
11 //===----------------------------------------------------------------------===//
13 #include "llvm/BinaryFormat/Dwarf.h"
14 #include "llvm/ADT/StringSwitch.h"
15 #include "llvm/ADT/Triple.h"
16 #include "llvm/Support/ErrorHandling.h"
18 using namespace llvm;
19 using namespace dwarf;
21 StringRef llvm::dwarf::TagString(unsigned Tag) {
22 switch (Tag) {
23 default:
24 return StringRef();
25 #define HANDLE_DW_TAG(ID, NAME, VERSION, VENDOR) \
26 case DW_TAG_##NAME: \
27 return "DW_TAG_" #NAME;
28 #include "llvm/BinaryFormat/Dwarf.def"
32 unsigned llvm::dwarf::getTag(StringRef TagString) {
33 return StringSwitch<unsigned>(TagString)
34 #define HANDLE_DW_TAG(ID, NAME, VERSION, VENDOR) \
35 .Case("DW_TAG_" #NAME, DW_TAG_##NAME)
36 #include "llvm/BinaryFormat/Dwarf.def"
37 .Default(DW_TAG_invalid);
40 unsigned llvm::dwarf::TagVersion(dwarf::Tag Tag) {
41 switch (Tag) {
42 default:
43 return 0;
44 #define HANDLE_DW_TAG(ID, NAME, VERSION, VENDOR) \
45 case DW_TAG_##NAME: \
46 return VERSION;
47 #include "llvm/BinaryFormat/Dwarf.def"
51 unsigned llvm::dwarf::TagVendor(dwarf::Tag Tag) {
52 switch (Tag) {
53 default:
54 return 0;
55 #define HANDLE_DW_TAG(ID, NAME, VERSION, VENDOR) \
56 case DW_TAG_##NAME: \
57 return DWARF_VENDOR_##VENDOR;
58 #include "llvm/BinaryFormat/Dwarf.def"
62 StringRef llvm::dwarf::ChildrenString(unsigned Children) {
63 switch (Children) {
64 case DW_CHILDREN_no:
65 return "DW_CHILDREN_no";
66 case DW_CHILDREN_yes:
67 return "DW_CHILDREN_yes";
69 return StringRef();
72 StringRef llvm::dwarf::AttributeString(unsigned Attribute) {
73 switch (Attribute) {
74 default:
75 return StringRef();
76 #define HANDLE_DW_AT(ID, NAME, VERSION, VENDOR) \
77 case DW_AT_##NAME: \
78 return "DW_AT_" #NAME;
79 #include "llvm/BinaryFormat/Dwarf.def"
83 unsigned llvm::dwarf::AttributeVersion(dwarf::Attribute Attribute) {
84 switch (Attribute) {
85 default:
86 return 0;
87 #define HANDLE_DW_AT(ID, NAME, VERSION, VENDOR) \
88 case DW_AT_##NAME: \
89 return VERSION;
90 #include "llvm/BinaryFormat/Dwarf.def"
94 unsigned llvm::dwarf::AttributeVendor(dwarf::Attribute Attribute) {
95 switch (Attribute) {
96 default:
97 return 0;
98 #define HANDLE_DW_AT(ID, NAME, VERSION, VENDOR) \
99 case DW_AT_##NAME: \
100 return DWARF_VENDOR_##VENDOR;
101 #include "llvm/BinaryFormat/Dwarf.def"
105 StringRef llvm::dwarf::FormEncodingString(unsigned Encoding) {
106 switch (Encoding) {
107 default:
108 return StringRef();
109 #define HANDLE_DW_FORM(ID, NAME, VERSION, VENDOR) \
110 case DW_FORM_##NAME: \
111 return "DW_FORM_" #NAME;
112 #include "llvm/BinaryFormat/Dwarf.def"
116 unsigned llvm::dwarf::FormVersion(dwarf::Form Form) {
117 switch (Form) {
118 default:
119 return 0;
120 #define HANDLE_DW_FORM(ID, NAME, VERSION, VENDOR) \
121 case DW_FORM_##NAME: \
122 return VERSION;
123 #include "llvm/BinaryFormat/Dwarf.def"
127 unsigned llvm::dwarf::FormVendor(dwarf::Form Form) {
128 switch (Form) {
129 default:
130 return 0;
131 #define HANDLE_DW_FORM(ID, NAME, VERSION, VENDOR) \
132 case DW_FORM_##NAME: \
133 return DWARF_VENDOR_##VENDOR;
134 #include "llvm/BinaryFormat/Dwarf.def"
138 StringRef llvm::dwarf::OperationEncodingString(unsigned Encoding) {
139 switch (Encoding) {
140 default:
141 return StringRef();
142 #define HANDLE_DW_OP(ID, NAME, VERSION, VENDOR) \
143 case DW_OP_##NAME: \
144 return "DW_OP_" #NAME;
145 #include "llvm/BinaryFormat/Dwarf.def"
146 case DW_OP_LLVM_fragment:
147 return "DW_OP_LLVM_fragment";
151 unsigned llvm::dwarf::getOperationEncoding(StringRef OperationEncodingString) {
152 return StringSwitch<unsigned>(OperationEncodingString)
153 #define HANDLE_DW_OP(ID, NAME, VERSION, VENDOR) \
154 .Case("DW_OP_" #NAME, DW_OP_##NAME)
155 #include "llvm/BinaryFormat/Dwarf.def"
156 .Case("DW_OP_LLVM_fragment", DW_OP_LLVM_fragment)
157 .Default(0);
160 unsigned llvm::dwarf::OperationVersion(dwarf::LocationAtom Op) {
161 switch (Op) {
162 default:
163 return 0;
164 #define HANDLE_DW_OP(ID, NAME, VERSION, VENDOR) \
165 case DW_OP_##NAME: \
166 return VERSION;
167 #include "llvm/BinaryFormat/Dwarf.def"
171 unsigned llvm::dwarf::OperationVendor(dwarf::LocationAtom Op) {
172 switch (Op) {
173 default:
174 return 0;
175 #define HANDLE_DW_OP(ID, NAME, VERSION, VENDOR) \
176 case DW_OP_##NAME: \
177 return DWARF_VENDOR_##VENDOR;
178 #include "llvm/BinaryFormat/Dwarf.def"
182 StringRef llvm::dwarf::AttributeEncodingString(unsigned Encoding) {
183 switch (Encoding) {
184 default:
185 return StringRef();
186 #define HANDLE_DW_ATE(ID, NAME, VERSION, VENDOR) \
187 case DW_ATE_##NAME: \
188 return "DW_ATE_" #NAME;
189 #include "llvm/BinaryFormat/Dwarf.def"
193 unsigned llvm::dwarf::getAttributeEncoding(StringRef EncodingString) {
194 return StringSwitch<unsigned>(EncodingString)
195 #define HANDLE_DW_ATE(ID, NAME, VERSION, VENDOR) \
196 .Case("DW_ATE_" #NAME, DW_ATE_##NAME)
197 #include "llvm/BinaryFormat/Dwarf.def"
198 .Default(0);
201 unsigned llvm::dwarf::AttributeEncodingVersion(dwarf::TypeKind ATE) {
202 switch (ATE) {
203 default:
204 return 0;
205 #define HANDLE_DW_ATE(ID, NAME, VERSION, VENDOR) \
206 case DW_ATE_##NAME: \
207 return VERSION;
208 #include "llvm/BinaryFormat/Dwarf.def"
212 unsigned llvm::dwarf::AttributeEncodingVendor(dwarf::TypeKind ATE) {
213 switch (ATE) {
214 default:
215 return 0;
216 #define HANDLE_DW_ATE(ID, NAME, VERSION, VENDOR) \
217 case DW_ATE_##NAME: \
218 return DWARF_VENDOR_##VENDOR;
219 #include "llvm/BinaryFormat/Dwarf.def"
223 StringRef llvm::dwarf::DecimalSignString(unsigned Sign) {
224 switch (Sign) {
225 case DW_DS_unsigned:
226 return "DW_DS_unsigned";
227 case DW_DS_leading_overpunch:
228 return "DW_DS_leading_overpunch";
229 case DW_DS_trailing_overpunch:
230 return "DW_DS_trailing_overpunch";
231 case DW_DS_leading_separate:
232 return "DW_DS_leading_separate";
233 case DW_DS_trailing_separate:
234 return "DW_DS_trailing_separate";
236 return StringRef();
239 StringRef llvm::dwarf::EndianityString(unsigned Endian) {
240 switch (Endian) {
241 case DW_END_default:
242 return "DW_END_default";
243 case DW_END_big:
244 return "DW_END_big";
245 case DW_END_little:
246 return "DW_END_little";
247 case DW_END_lo_user:
248 return "DW_END_lo_user";
249 case DW_END_hi_user:
250 return "DW_END_hi_user";
252 return StringRef();
255 StringRef llvm::dwarf::AccessibilityString(unsigned Access) {
256 switch (Access) {
257 // Accessibility codes
258 case DW_ACCESS_public:
259 return "DW_ACCESS_public";
260 case DW_ACCESS_protected:
261 return "DW_ACCESS_protected";
262 case DW_ACCESS_private:
263 return "DW_ACCESS_private";
265 return StringRef();
268 StringRef llvm::dwarf::VisibilityString(unsigned Visibility) {
269 switch (Visibility) {
270 case DW_VIS_local:
271 return "DW_VIS_local";
272 case DW_VIS_exported:
273 return "DW_VIS_exported";
274 case DW_VIS_qualified:
275 return "DW_VIS_qualified";
277 return StringRef();
280 StringRef llvm::dwarf::VirtualityString(unsigned Virtuality) {
281 switch (Virtuality) {
282 default:
283 return StringRef();
284 #define HANDLE_DW_VIRTUALITY(ID, NAME) \
285 case DW_VIRTUALITY_##NAME: \
286 return "DW_VIRTUALITY_" #NAME;
287 #include "llvm/BinaryFormat/Dwarf.def"
291 unsigned llvm::dwarf::getVirtuality(StringRef VirtualityString) {
292 return StringSwitch<unsigned>(VirtualityString)
293 #define HANDLE_DW_VIRTUALITY(ID, NAME) \
294 .Case("DW_VIRTUALITY_" #NAME, DW_VIRTUALITY_##NAME)
295 #include "llvm/BinaryFormat/Dwarf.def"
296 .Default(DW_VIRTUALITY_invalid);
299 StringRef llvm::dwarf::LanguageString(unsigned Language) {
300 switch (Language) {
301 default:
302 return StringRef();
303 #define HANDLE_DW_LANG(ID, NAME, LOWER_BOUND, VERSION, VENDOR) \
304 case DW_LANG_##NAME: \
305 return "DW_LANG_" #NAME;
306 #include "llvm/BinaryFormat/Dwarf.def"
310 unsigned llvm::dwarf::getLanguage(StringRef LanguageString) {
311 return StringSwitch<unsigned>(LanguageString)
312 #define HANDLE_DW_LANG(ID, NAME, LOWER_BOUND, VERSION, VENDOR) \
313 .Case("DW_LANG_" #NAME, DW_LANG_##NAME)
314 #include "llvm/BinaryFormat/Dwarf.def"
315 .Default(0);
318 unsigned llvm::dwarf::LanguageVersion(dwarf::SourceLanguage Lang) {
319 switch (Lang) {
320 default:
321 return 0;
322 #define HANDLE_DW_LANG(ID, NAME, LOWER_BOUND, VERSION, VENDOR) \
323 case DW_LANG_##NAME: \
324 return VERSION;
325 #include "llvm/BinaryFormat/Dwarf.def"
329 unsigned llvm::dwarf::LanguageVendor(dwarf::SourceLanguage Lang) {
330 switch (Lang) {
331 default:
332 return 0;
333 #define HANDLE_DW_LANG(ID, NAME, LOWER_BOUND, VERSION, VENDOR) \
334 case DW_LANG_##NAME: \
335 return DWARF_VENDOR_##VENDOR;
336 #include "llvm/BinaryFormat/Dwarf.def"
340 Optional<unsigned> llvm::dwarf::LanguageLowerBound(dwarf::SourceLanguage Lang) {
341 switch (Lang) {
342 default:
343 return None;
344 #define HANDLE_DW_LANG(ID, NAME, LOWER_BOUND, VERSION, VENDOR) \
345 case DW_LANG_##NAME: \
346 return LOWER_BOUND;
347 #include "llvm/BinaryFormat/Dwarf.def"
351 StringRef llvm::dwarf::CaseString(unsigned Case) {
352 switch (Case) {
353 case DW_ID_case_sensitive:
354 return "DW_ID_case_sensitive";
355 case DW_ID_up_case:
356 return "DW_ID_up_case";
357 case DW_ID_down_case:
358 return "DW_ID_down_case";
359 case DW_ID_case_insensitive:
360 return "DW_ID_case_insensitive";
362 return StringRef();
365 StringRef llvm::dwarf::ConventionString(unsigned CC) {
366 switch (CC) {
367 default:
368 return StringRef();
369 #define HANDLE_DW_CC(ID, NAME) \
370 case DW_CC_##NAME: \
371 return "DW_CC_" #NAME;
372 #include "llvm/BinaryFormat/Dwarf.def"
376 unsigned llvm::dwarf::getCallingConvention(StringRef CCString) {
377 return StringSwitch<unsigned>(CCString)
378 #define HANDLE_DW_CC(ID, NAME) .Case("DW_CC_" #NAME, DW_CC_##NAME)
379 #include "llvm/BinaryFormat/Dwarf.def"
380 .Default(0);
383 StringRef llvm::dwarf::InlineCodeString(unsigned Code) {
384 switch (Code) {
385 case DW_INL_not_inlined:
386 return "DW_INL_not_inlined";
387 case DW_INL_inlined:
388 return "DW_INL_inlined";
389 case DW_INL_declared_not_inlined:
390 return "DW_INL_declared_not_inlined";
391 case DW_INL_declared_inlined:
392 return "DW_INL_declared_inlined";
394 return StringRef();
397 StringRef llvm::dwarf::ArrayOrderString(unsigned Order) {
398 switch (Order) {
399 case DW_ORD_row_major:
400 return "DW_ORD_row_major";
401 case DW_ORD_col_major:
402 return "DW_ORD_col_major";
404 return StringRef();
407 StringRef llvm::dwarf::LNStandardString(unsigned Standard) {
408 switch (Standard) {
409 default:
410 return StringRef();
411 #define HANDLE_DW_LNS(ID, NAME) \
412 case DW_LNS_##NAME: \
413 return "DW_LNS_" #NAME;
414 #include "llvm/BinaryFormat/Dwarf.def"
418 StringRef llvm::dwarf::LNExtendedString(unsigned Encoding) {
419 switch (Encoding) {
420 default:
421 return StringRef();
422 #define HANDLE_DW_LNE(ID, NAME) \
423 case DW_LNE_##NAME: \
424 return "DW_LNE_" #NAME;
425 #include "llvm/BinaryFormat/Dwarf.def"
429 StringRef llvm::dwarf::MacinfoString(unsigned Encoding) {
430 switch (Encoding) {
431 // Macinfo Type Encodings
432 case DW_MACINFO_define:
433 return "DW_MACINFO_define";
434 case DW_MACINFO_undef:
435 return "DW_MACINFO_undef";
436 case DW_MACINFO_start_file:
437 return "DW_MACINFO_start_file";
438 case DW_MACINFO_end_file:
439 return "DW_MACINFO_end_file";
440 case DW_MACINFO_vendor_ext:
441 return "DW_MACINFO_vendor_ext";
442 case DW_MACINFO_invalid:
443 return "DW_MACINFO_invalid";
445 return StringRef();
448 unsigned llvm::dwarf::getMacinfo(StringRef MacinfoString) {
449 return StringSwitch<unsigned>(MacinfoString)
450 .Case("DW_MACINFO_define", DW_MACINFO_define)
451 .Case("DW_MACINFO_undef", DW_MACINFO_undef)
452 .Case("DW_MACINFO_start_file", DW_MACINFO_start_file)
453 .Case("DW_MACINFO_end_file", DW_MACINFO_end_file)
454 .Case("DW_MACINFO_vendor_ext", DW_MACINFO_vendor_ext)
455 .Default(DW_MACINFO_invalid);
458 StringRef llvm::dwarf::RangeListEncodingString(unsigned Encoding) {
459 switch (Encoding) {
460 default:
461 return StringRef();
462 #define HANDLE_DW_RLE(ID, NAME) \
463 case DW_RLE_##NAME: \
464 return "DW_RLE_" #NAME;
465 #include "llvm/BinaryFormat/Dwarf.def"
469 StringRef llvm::dwarf::CallFrameString(unsigned Encoding,
470 Triple::ArchType Arch) {
471 assert(Arch != llvm::Triple::ArchType::UnknownArch);
472 #define SELECT_AARCH64 (Arch == llvm::Triple::aarch64_be || Arch == llvm::Triple::aarch64)
473 #define SELECT_MIPS64 Arch == llvm::Triple::mips64
474 #define SELECT_SPARC (Arch == llvm::Triple::sparc || Arch == llvm::Triple::sparcv9)
475 #define SELECT_X86 (Arch == llvm::Triple::x86 || Arch == llvm::Triple::x86_64)
476 #define HANDLE_DW_CFA(ID, NAME)
477 #define HANDLE_DW_CFA_PRED(ID, NAME, PRED) \
478 if (ID == Encoding && PRED) \
479 return "DW_CFA_" #NAME;
480 #include "llvm/BinaryFormat/Dwarf.def"
482 switch (Encoding) {
483 default:
484 return StringRef();
485 #define HANDLE_DW_CFA_PRED(ID, NAME, PRED)
486 #define HANDLE_DW_CFA(ID, NAME) \
487 case DW_CFA_##NAME: \
488 return "DW_CFA_" #NAME;
489 #include "llvm/BinaryFormat/Dwarf.def"
491 #undef SELECT_X86
492 #undef SELECT_SPARC
493 #undef SELECT_MIPS64
494 #undef SELECT_AARCH64
498 StringRef llvm::dwarf::ApplePropertyString(unsigned Prop) {
499 switch (Prop) {
500 default:
501 return StringRef();
502 #define HANDLE_DW_APPLE_PROPERTY(ID, NAME) \
503 case DW_APPLE_PROPERTY_##NAME: \
504 return "DW_APPLE_PROPERTY_" #NAME;
505 #include "llvm/BinaryFormat/Dwarf.def"
509 StringRef llvm::dwarf::UnitTypeString(unsigned UT) {
510 switch (UT) {
511 default:
512 return StringRef();
513 #define HANDLE_DW_UT(ID, NAME) \
514 case DW_UT_##NAME: \
515 return "DW_UT_" #NAME;
516 #include "llvm/BinaryFormat/Dwarf.def"
520 StringRef llvm::dwarf::AtomTypeString(unsigned AT) {
521 switch (AT) {
522 case dwarf::DW_ATOM_null:
523 return "DW_ATOM_null";
524 case dwarf::DW_ATOM_die_offset:
525 return "DW_ATOM_die_offset";
526 case DW_ATOM_cu_offset:
527 return "DW_ATOM_cu_offset";
528 case DW_ATOM_die_tag:
529 return "DW_ATOM_die_tag";
530 case DW_ATOM_type_flags:
531 case DW_ATOM_type_type_flags:
532 return "DW_ATOM_type_flags";
533 case DW_ATOM_qual_name_hash:
534 return "DW_ATOM_qual_name_hash";
536 return StringRef();
539 StringRef llvm::dwarf::GDBIndexEntryKindString(GDBIndexEntryKind Kind) {
540 switch (Kind) {
541 case GIEK_NONE:
542 return "NONE";
543 case GIEK_TYPE:
544 return "TYPE";
545 case GIEK_VARIABLE:
546 return "VARIABLE";
547 case GIEK_FUNCTION:
548 return "FUNCTION";
549 case GIEK_OTHER:
550 return "OTHER";
551 case GIEK_UNUSED5:
552 return "UNUSED5";
553 case GIEK_UNUSED6:
554 return "UNUSED6";
555 case GIEK_UNUSED7:
556 return "UNUSED7";
558 llvm_unreachable("Unknown GDBIndexEntryKind value");
561 StringRef
562 llvm::dwarf::GDBIndexEntryLinkageString(GDBIndexEntryLinkage Linkage) {
563 switch (Linkage) {
564 case GIEL_EXTERNAL:
565 return "EXTERNAL";
566 case GIEL_STATIC:
567 return "STATIC";
569 llvm_unreachable("Unknown GDBIndexEntryLinkage value");
572 StringRef llvm::dwarf::AttributeValueString(uint16_t Attr, unsigned Val) {
573 switch (Attr) {
574 case DW_AT_accessibility:
575 return AccessibilityString(Val);
576 case DW_AT_virtuality:
577 return VirtualityString(Val);
578 case DW_AT_language:
579 return LanguageString(Val);
580 case DW_AT_encoding:
581 return AttributeEncodingString(Val);
582 case DW_AT_decimal_sign:
583 return DecimalSignString(Val);
584 case DW_AT_endianity:
585 return EndianityString(Val);
586 case DW_AT_visibility:
587 return VisibilityString(Val);
588 case DW_AT_identifier_case:
589 return CaseString(Val);
590 case DW_AT_calling_convention:
591 return ConventionString(Val);
592 case DW_AT_inline:
593 return InlineCodeString(Val);
594 case DW_AT_ordering:
595 return ArrayOrderString(Val);
596 case DW_AT_APPLE_runtime_class:
597 return LanguageString(Val);
600 return StringRef();
603 StringRef llvm::dwarf::AtomValueString(uint16_t Atom, unsigned Val) {
604 switch (Atom) {
605 case DW_ATOM_null:
606 return "NULL";
607 case DW_ATOM_die_tag:
608 return TagString(Val);
611 return StringRef();
614 StringRef llvm::dwarf::IndexString(unsigned Idx) {
615 switch (Idx) {
616 default:
617 return StringRef();
618 #define HANDLE_DW_IDX(ID, NAME) \
619 case DW_IDX_##NAME: \
620 return "DW_IDX_" #NAME;
621 #include "llvm/BinaryFormat/Dwarf.def"
625 Optional<uint8_t> llvm::dwarf::getFixedFormByteSize(dwarf::Form Form,
626 FormParams Params) {
627 switch (Form) {
628 case DW_FORM_addr:
629 if (Params)
630 return Params.AddrSize;
631 return None;
633 case DW_FORM_block: // ULEB128 length L followed by L bytes.
634 case DW_FORM_block1: // 1 byte length L followed by L bytes.
635 case DW_FORM_block2: // 2 byte length L followed by L bytes.
636 case DW_FORM_block4: // 4 byte length L followed by L bytes.
637 case DW_FORM_string: // C-string with null terminator.
638 case DW_FORM_sdata: // SLEB128.
639 case DW_FORM_udata: // ULEB128.
640 case DW_FORM_ref_udata: // ULEB128.
641 case DW_FORM_indirect: // ULEB128.
642 case DW_FORM_exprloc: // ULEB128 length L followed by L bytes.
643 case DW_FORM_strx: // ULEB128.
644 case DW_FORM_addrx: // ULEB128.
645 case DW_FORM_loclistx: // ULEB128.
646 case DW_FORM_rnglistx: // ULEB128.
647 case DW_FORM_GNU_addr_index: // ULEB128.
648 case DW_FORM_GNU_str_index: // ULEB128.
649 return None;
651 case DW_FORM_ref_addr:
652 if (Params)
653 return Params.getRefAddrByteSize();
654 return None;
656 case DW_FORM_flag:
657 case DW_FORM_data1:
658 case DW_FORM_ref1:
659 case DW_FORM_strx1:
660 case DW_FORM_addrx1:
661 return 1;
663 case DW_FORM_data2:
664 case DW_FORM_ref2:
665 case DW_FORM_strx2:
666 case DW_FORM_addrx2:
667 return 2;
669 case DW_FORM_strx3:
670 return 3;
672 case DW_FORM_data4:
673 case DW_FORM_ref4:
674 case DW_FORM_ref_sup4:
675 case DW_FORM_strx4:
676 case DW_FORM_addrx4:
677 return 4;
679 case DW_FORM_strp:
680 case DW_FORM_GNU_ref_alt:
681 case DW_FORM_GNU_strp_alt:
682 case DW_FORM_line_strp:
683 case DW_FORM_sec_offset:
684 case DW_FORM_strp_sup:
685 if (Params)
686 return Params.getDwarfOffsetByteSize();
687 return None;
689 case DW_FORM_data8:
690 case DW_FORM_ref8:
691 case DW_FORM_ref_sig8:
692 case DW_FORM_ref_sup8:
693 return 8;
695 case DW_FORM_flag_present:
696 return 0;
698 case DW_FORM_data16:
699 return 16;
701 case DW_FORM_implicit_const:
702 // The implicit value is stored in the abbreviation as a SLEB128, and
703 // there no data in debug info.
704 return 0;
706 default:
707 break;
709 return None;
712 bool llvm::dwarf::isValidFormForVersion(Form F, unsigned Version,
713 bool ExtensionsOk) {
714 if (FormVendor(F) == DWARF_VENDOR_DWARF) {
715 unsigned FV = FormVersion(F);
716 return FV > 0 && FV <= Version;
718 return ExtensionsOk;
721 constexpr char llvm::dwarf::EnumTraits<Attribute>::Type[];
722 constexpr char llvm::dwarf::EnumTraits<Form>::Type[];
723 constexpr char llvm::dwarf::EnumTraits<Index>::Type[];
724 constexpr char llvm::dwarf::EnumTraits<Tag>::Type[];