llvm.org GIT mirror llvm / ef350f2
Revert "Re-commit "Use StringRef in Support/Darf APIs (NFC)"" One test seems randomly broken: DebugInfo/X86/gnu-public-names.ll git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@283285 91177308-0d34-0410-b5e6-96231b3b80d8 Mehdi Amini 4 years ago
11 changed file(s) with 161 addition(s) and 175 deletion(s). Raw diff Collapse all Expand all
605605 /// known.
606606 ///
607607 /// @{
608 StringRef TagString(unsigned Tag);
609 StringRef ChildrenString(unsigned Children);
610 StringRef AttributeString(unsigned Attribute);
611 StringRef FormEncodingString(unsigned Encoding);
612 StringRef OperationEncodingString(unsigned Encoding);
613 StringRef AttributeEncodingString(unsigned Encoding);
614 StringRef DecimalSignString(unsigned Sign);
615 StringRef EndianityString(unsigned Endian);
616 StringRef AccessibilityString(unsigned Access);
617 StringRef VisibilityString(unsigned Visibility);
618 StringRef VirtualityString(unsigned Virtuality);
619 StringRef LanguageString(unsigned Language);
620 StringRef CaseString(unsigned Case);
621 StringRef ConventionString(unsigned Convention);
622 StringRef InlineCodeString(unsigned Code);
623 StringRef ArrayOrderString(unsigned Order);
624 StringRef DiscriminantString(unsigned Discriminant);
625 StringRef LNStandardString(unsigned Standard);
626 StringRef LNExtendedString(unsigned Encoding);
627 StringRef MacinfoString(unsigned Encoding);
628 StringRef CallFrameString(unsigned Encoding);
629 StringRef ApplePropertyString(unsigned);
630 StringRef AtomTypeString(unsigned Atom);
631 StringRef GDBIndexEntryKindString(GDBIndexEntryKind Kind);
632 StringRef GDBIndexEntryLinkageString(GDBIndexEntryLinkage Linkage);
608 const char *TagString(unsigned Tag);
609 const char *ChildrenString(unsigned Children);
610 const char *AttributeString(unsigned Attribute);
611 const char *FormEncodingString(unsigned Encoding);
612 const char *OperationEncodingString(unsigned Encoding);
613 const char *AttributeEncodingString(unsigned Encoding);
614 const char *DecimalSignString(unsigned Sign);
615 const char *EndianityString(unsigned Endian);
616 const char *AccessibilityString(unsigned Access);
617 const char *VisibilityString(unsigned Visibility);
618 const char *VirtualityString(unsigned Virtuality);
619 const char *LanguageString(unsigned Language);
620 const char *CaseString(unsigned Case);
621 const char *ConventionString(unsigned Convention);
622 const char *InlineCodeString(unsigned Code);
623 const char *ArrayOrderString(unsigned Order);
624 const char *DiscriminantString(unsigned Discriminant);
625 const char *LNStandardString(unsigned Standard);
626 const char *LNExtendedString(unsigned Encoding);
627 const char *MacinfoString(unsigned Encoding);
628 const char *CallFrameString(unsigned Encoding);
629 const char *ApplePropertyString(unsigned);
630 const char *AtomTypeString(unsigned Atom);
631 const char *GDBIndexEntryKindString(GDBIndexEntryKind Kind);
632 const char *GDBIndexEntryLinkageString(GDBIndexEntryLinkage Linkage);
633633 /// @}
634634
635635 /// \defgroup DwarfConstantsParsing Dwarf constants parsing functions
653653
654654 /// \brief Returns the symbolic string representing Val when used as a value
655655 /// for attribute Attr.
656 StringRef AttributeValueString(uint16_t Attr, unsigned Val);
656 const char *AttributeValueString(uint16_t Attr, unsigned Val);
657657
658658 /// \brief Decsribes an entry of the various gnu_pub* debug sections.
659659 ///
7373 // filenames), so just print a few useful things.
7474 for (DICompileUnit *CU : Finder.compile_units()) {
7575 O << "Compile unit: ";
76 auto Lang = dwarf::LanguageString(CU->getSourceLanguage());
77 if (!Lang.empty())
76 if (const char *Lang = dwarf::LanguageString(CU->getSourceLanguage()))
7877 O << Lang;
7978 else
8079 O << "unknown-language(" << CU->getSourceLanguage() << ")";
105104 printFile(O, T->getFilename(), T->getDirectory(), T->getLine());
106105 if (auto *BT = dyn_cast(T)) {
107106 O << " ";
108 auto Encoding = dwarf::AttributeEncodingString(BT->getEncoding());
109 if (!Encoding.empty())
107 if (const char *Encoding =
108 dwarf::AttributeEncodingString(BT->getEncoding()))
110109 O << Encoding;
111110 else
112111 O << "unknown-encoding(" << BT->getEncoding() << ')';
113112 } else {
114113 O << ' ';
115 auto Tag = dwarf::TagString(T->getTag());
116 if (!Tag.empty())
114 if (const char *Tag = dwarf::TagString(T->getTag()))
117115 O << Tag;
118116 else
119117 O << "unknown-tag(" << T->getTag() << ")";
6262 ///
6363 void DIEAbbrev::Emit(const AsmPrinter *AP) const {
6464 // Emit its Dwarf tag type.
65 AP->EmitULEB128(Tag, dwarf::TagString(Tag).data());
65 AP->EmitULEB128(Tag, dwarf::TagString(Tag));
6666
6767 // Emit whether it has children DIEs.
68 AP->EmitULEB128((unsigned)Children, dwarf::ChildrenString(Children).data());
68 AP->EmitULEB128((unsigned)Children, dwarf::ChildrenString(Children));
6969
7070 // For each attribute description.
7171 for (unsigned i = 0, N = Data.size(); i < N; ++i) {
7373
7474 // Emit attribute type.
7575 AP->EmitULEB128(AttrData.getAttribute(),
76 dwarf::AttributeString(AttrData.getAttribute()).data());
76 dwarf::AttributeString(AttrData.getAttribute()));
7777
7878 // Emit form type.
7979 AP->EmitULEB128(AttrData.getForm(),
80 dwarf::FormEncodingString(AttrData.getForm()).data());
80 dwarf::FormEncodingString(AttrData.getForm()));
8181 }
8282
8383 // Mark end of abbreviation.
6161 }
6262
6363 void DWARFAbbreviationDeclaration::dump(raw_ostream &OS) const {
64 auto tagString = TagString(getTag());
64 const char *tagString = TagString(getTag());
6565 OS << '[' << getCode() << "] ";
66 if (!tagString.empty())
66 if (tagString)
6767 OS << tagString;
6868 else
6969 OS << format("DW_TAG_Unknown_%x", getTag());
7070 OS << "\tDW_CHILDREN_" << (hasChildren() ? "yes" : "no") << '\n';
7171 for (const AttributeSpec &Spec : AttributeSpecs) {
7272 OS << '\t';
73 auto attrString = AttributeString(Spec.Attr);
74 if (!attrString.empty())
73 const char *attrString = AttributeString(Spec.Attr);
74 if (attrString)
7575 OS << attrString;
7676 else
7777 OS << format("DW_AT_Unknown_%x", Spec.Attr);
7878 OS << '\t';
79 auto formString = FormEncodingString(Spec.Form);
80 if (!formString.empty())
79 const char *formString = FormEncodingString(Spec.Form);
80 if (formString)
8181 OS << formString;
8282 else
8383 OS << format("DW_FORM_Unknown_%x", Spec.Form);
6060 SmallVector AtomForms;
6161 for (const auto &Atom: HdrData.Atoms) {
6262 OS << format("Atom[%d] Type: ", i++);
63 auto TypeString = dwarf::AtomTypeString(Atom.first);
64 if (!TypeString.empty())
63 if (const char *TypeString = dwarf::AtomTypeString(Atom.first))
6564 OS << TypeString;
6665 else
6766 OS << format("DW_ATOM_Unknown_0x%x", Atom.first);
6867 OS << " Form: ";
69 auto FormString = dwarf::FormEncodingString(Atom.second);
70 if (!FormString.empty())
68 if (const char *FormString = dwarf::FormEncodingString(Atom.second))
7169 OS << FormString;
7270 else
7371 OS << format("DW_FORM_Unknown_0x%x", Atom.second);
393393 OperandType Type = OpTypes[Opcode][OperandIdx];
394394
395395 switch (Type) {
396 case OT_Unset: {
396 case OT_Unset:
397397 OS << " Unsupported " << (OperandIdx ? "second" : "first") << " operand to";
398 auto OpcodeName = CallFrameString(Opcode);
399 if (!OpcodeName.empty())
398 if (const char *OpcodeName = CallFrameString(Opcode))
400399 OS << " " << OpcodeName;
401400 else
402401 OS << format(" Opcode %x", Opcode);
403402 break;
404 }
405403 case OT_None:
406404 break;
407405 case OT_Address:
4444
4545 if (abbrCode) {
4646 if (AbbrevDecl) {
47 auto tagString = TagString(getTag());
48 if (!tagString.empty())
49 WithColor(OS, syntax::Tag).get().indent(indent) << tagString;
50 else
51 WithColor(OS, syntax::Tag).get().indent(indent)
52 << format("DW_TAG_Unknown_%x", getTag());
47 const char *tagString = TagString(getTag());
48 if (tagString)
49 WithColor(OS, syntax::Tag).get().indent(indent) << tagString;
50 else
51 WithColor(OS, syntax::Tag).get().indent(indent) <<
52 format("DW_TAG_Unknown_%x", getTag());
5353
5454 OS << format(" [%u] %c\n", abbrCode,
5555 AbbrevDecl->hasChildren() ? '*' : ' ');
8282 uint64_t Shift = countTrailingZeros(Val);
8383 assert(Shift < 64 && "undefined behavior");
8484 uint64_t Bit = 1ULL << Shift;
85 auto PropName = ApplePropertyString(Bit);
86 if (!PropName.empty())
85 if (const char *PropName = ApplePropertyString(Bit))
8786 OS << PropName;
8887 else
8988 OS << format("DW_APPLE_PROPERTY_0x%" PRIx64, Bit);
116115 const char BaseIndent[] = " ";
117116 OS << BaseIndent;
118117 OS.indent(indent+2);
119 auto attrString = AttributeString(attr);
120 if (!attrString.empty())
118 const char *attrString = AttributeString(attr);
119 if (attrString)
121120 WithColor(OS, syntax::Attribute) << attrString;
122121 else
123122 WithColor(OS, syntax::Attribute).get() << format("DW_AT_Unknown_%x", attr);
124123
125 auto formString = FormEncodingString(form);
126 if (!formString.empty())
124 const char *formString = FormEncodingString(form);
125 if (formString)
127126 OS << " [" << formString << ']';
128127 else
129128 OS << format(" [DW_FORM_Unknown_%x]", form);
134133 return;
135134
136135 OS << "\t(";
137
138 StringRef Name;
136
137 const char *Name = nullptr;
139138 std::string File;
140139 auto Color = syntax::Enumerator;
141140 if (attr == DW_AT_decl_file || attr == DW_AT_call_file) {
146145 u->getCompilationDir(),
147146 DILineInfoSpecifier::FileLineInfoKind::AbsoluteFilePath, File)) {
148147 File = '"' + File + '"';
149 Name = File;
148 Name = File.c_str();
150149 }
151150 } else if (Optional Val = formValue.getAsUnsignedConstant())
152151 Name = AttributeValueString(attr, *Val);
153152
154 if (!Name.empty())
153 if (Name)
155154 WithColor(OS, Color) << Name;
156155 else if (attr == DW_AT_decl_line || attr == DW_AT_call_line)
157156 OS << *formValue.getAsUnsignedConstant();
4141 << format(" opcode_base: %u\n", OpcodeBase);
4242
4343 for (uint32_t i = 0; i < StandardOpcodeLengths.size(); ++i)
44 OS << format("standard_opcode_lengths[%s] = %u\n",
45 LNStandardString(i + 1).data(), StandardOpcodeLengths[i]);
44 OS << format("standard_opcode_lengths[%s] = %u\n", LNStandardString(i + 1),
45 StandardOpcodeLengths[i]);
4646
4747 if (!IncludeDirectories.empty())
4848 for (uint32_t i = 0; i < IncludeDirectories.size(); ++i)
14171417
14181418 void MDFieldPrinter::printTag(const DINode *N) {
14191419 Out << FS << "tag: ";
1420 auto Tag = dwarf::TagString(N->getTag());
1421 if (!Tag.empty())
1420 if (const char *Tag = dwarf::TagString(N->getTag()))
14221421 Out << Tag;
14231422 else
14241423 Out << N->getTag();
14261425
14271426 void MDFieldPrinter::printMacinfoType(const DIMacroNode *N) {
14281427 Out << FS << "type: ";
1429 auto Type = dwarf::MacinfoString(N->getMacinfoType());
1430 if (!Type.empty())
1428 if (const char *Type = dwarf::MacinfoString(N->getMacinfoType()))
14311429 Out << Type;
14321430 else
14331431 Out << N->getMacinfoType();
15101508 return;
15111509
15121510 Out << FS << Name << ": ";
1513 auto S = toString(Value);
1514 if (!S.empty())
1511 if (const char *S = toString(Value))
15151512 Out << S;
15161513 else
15171514 Out << Value;
18451842 FieldSeparator FS;
18461843 if (N->isValid()) {
18471844 for (auto I = N->expr_op_begin(), E = N->expr_op_end(); I != E; ++I) {
1848 auto OpStr = dwarf::OperationEncodingString(I->getOp());
1849 assert(!OpStr.empty() && "Expected valid opcode");
1845 const char *OpStr = dwarf::OperationEncodingString(I->getOp());
1846 assert(OpStr && "Expected valid opcode");
18501847
18511848 Out << FS << OpStr;
18521849 for (unsigned A = 0, AE = I->getNumArgs(); A != AE; ++A)
1717 using namespace llvm;
1818 using namespace dwarf;
1919
20 StringRef llvm::dwarf::TagString(unsigned Tag) {
20 const char *llvm::dwarf::TagString(unsigned Tag) {
2121 switch (Tag) {
22 default:
23 return StringRef();
22 default: return nullptr;
2423 #define HANDLE_DW_TAG(ID, NAME) \
2524 case DW_TAG_##NAME: \
2625 return "DW_TAG_" #NAME;
3534 .Default(DW_TAG_invalid);
3635 }
3736
38 StringRef llvm::dwarf::ChildrenString(unsigned Children) {
37 const char *llvm::dwarf::ChildrenString(unsigned Children) {
3938 switch (Children) {
4039 case DW_CHILDREN_no: return "DW_CHILDREN_no";
4140 case DW_CHILDREN_yes: return "DW_CHILDREN_yes";
4241 }
43 return StringRef();
44 }
45
46 StringRef llvm::dwarf::AttributeString(unsigned Attribute) {
42 return nullptr;
43 }
44
45 const char *llvm::dwarf::AttributeString(unsigned Attribute) {
4746 switch (Attribute) {
4847 case DW_AT_sibling: return "DW_AT_sibling";
4948 case DW_AT_location: return "DW_AT_location";
221220 case DW_AT_GNU_pubtypes: return "DW_AT_GNU_pubtypes";
222221 case DW_AT_GNU_discriminator: return "DW_AT_GNU_discriminator";
223222 }
224 return StringRef();
225 }
226
227 StringRef llvm::dwarf::FormEncodingString(unsigned Encoding) {
223 return nullptr;
224 }
225
226 const char *llvm::dwarf::FormEncodingString(unsigned Encoding) {
228227 switch (Encoding) {
229228 case DW_FORM_addr: return "DW_FORM_addr";
230229 case DW_FORM_block2: return "DW_FORM_block2";
260259 case DW_FORM_GNU_ref_alt: return "DW_FORM_GNU_ref_alt";
261260 case DW_FORM_GNU_strp_alt: return "DW_FORM_GNU_strp_alt";
262261 }
263 return StringRef();
264 }
265
266 StringRef llvm::dwarf::OperationEncodingString(unsigned Encoding) {
262 return nullptr;
263 }
264
265 const char *llvm::dwarf::OperationEncodingString(unsigned Encoding) {
267266 switch (Encoding) {
268 default:
269 return StringRef();
267 default: return nullptr;
270268 #define HANDLE_DW_OP(ID, NAME) \
271269 case DW_OP_##NAME: \
272270 return "DW_OP_" #NAME;
281279 .Default(0);
282280 }
283281
284 StringRef llvm::dwarf::AttributeEncodingString(unsigned Encoding) {
282 const char *llvm::dwarf::AttributeEncodingString(unsigned Encoding) {
285283 switch (Encoding) {
286 default:
287 return StringRef();
284 default: return nullptr;
288285 #define HANDLE_DW_ATE(ID, NAME) \
289286 case DW_ATE_##NAME: \
290287 return "DW_ATE_" #NAME;
299296 .Default(0);
300297 }
301298
302 StringRef llvm::dwarf::DecimalSignString(unsigned Sign) {
299 const char *llvm::dwarf::DecimalSignString(unsigned Sign) {
303300 switch (Sign) {
304301 case DW_DS_unsigned: return "DW_DS_unsigned";
305302 case DW_DS_leading_overpunch: return "DW_DS_leading_overpunch";
307304 case DW_DS_leading_separate: return "DW_DS_leading_separate";
308305 case DW_DS_trailing_separate: return "DW_DS_trailing_separate";
309306 }
310 return StringRef();
311 }
312
313 StringRef llvm::dwarf::EndianityString(unsigned Endian) {
307 return nullptr;
308 }
309
310 const char *llvm::dwarf::EndianityString(unsigned Endian) {
314311 switch (Endian) {
315312 case DW_END_default: return "DW_END_default";
316313 case DW_END_big: return "DW_END_big";
318315 case DW_END_lo_user: return "DW_END_lo_user";
319316 case DW_END_hi_user: return "DW_END_hi_user";
320317 }
321 return StringRef();
322 }
323
324 StringRef llvm::dwarf::AccessibilityString(unsigned Access) {
318 return nullptr;
319 }
320
321 const char *llvm::dwarf::AccessibilityString(unsigned Access) {
325322 switch (Access) {
326323 // Accessibility codes
327324 case DW_ACCESS_public: return "DW_ACCESS_public";
328325 case DW_ACCESS_protected: return "DW_ACCESS_protected";
329326 case DW_ACCESS_private: return "DW_ACCESS_private";
330327 }
331 return StringRef();
332 }
333
334 StringRef llvm::dwarf::VisibilityString(unsigned Visibility) {
328 return nullptr;
329 }
330
331 const char *llvm::dwarf::VisibilityString(unsigned Visibility) {
335332 switch (Visibility) {
336333 case DW_VIS_local: return "DW_VIS_local";
337334 case DW_VIS_exported: return "DW_VIS_exported";
338335 case DW_VIS_qualified: return "DW_VIS_qualified";
339336 }
340 return StringRef();
341 }
342
343 StringRef llvm::dwarf::VirtualityString(unsigned Virtuality) {
337 return nullptr;
338 }
339
340 const char *llvm::dwarf::VirtualityString(unsigned Virtuality) {
344341 switch (Virtuality) {
345342 default:
346 return StringRef();
343 return nullptr;
347344 #define HANDLE_DW_VIRTUALITY(ID, NAME) \
348345 case DW_VIRTUALITY_##NAME: \
349346 return "DW_VIRTUALITY_" #NAME;
359356 .Default(DW_VIRTUALITY_invalid);
360357 }
361358
362 StringRef llvm::dwarf::LanguageString(unsigned Language) {
359 const char *llvm::dwarf::LanguageString(unsigned Language) {
363360 switch (Language) {
364361 default:
365 return StringRef();
362 return nullptr;
366363 #define HANDLE_DW_LANG(ID, NAME) \
367364 case DW_LANG_##NAME: \
368365 return "DW_LANG_" #NAME;
377374 .Default(0);
378375 }
379376
380 StringRef llvm::dwarf::CaseString(unsigned Case) {
377 const char *llvm::dwarf::CaseString(unsigned Case) {
381378 switch (Case) {
382379 case DW_ID_case_sensitive: return "DW_ID_case_sensitive";
383380 case DW_ID_up_case: return "DW_ID_up_case";
384381 case DW_ID_down_case: return "DW_ID_down_case";
385382 case DW_ID_case_insensitive: return "DW_ID_case_insensitive";
386383 }
387 return StringRef();
388 }
389
390 StringRef llvm::dwarf::ConventionString(unsigned CC) {
384 return nullptr;
385 }
386
387 const char *llvm::dwarf::ConventionString(unsigned CC) {
391388 switch (CC) {
392389 default:
393 return StringRef();
390 return nullptr;
394391 #define HANDLE_DW_CC(ID, NAME) \
395392 case DW_CC_##NAME: \
396393 return "DW_CC_" #NAME;
405402 .Default(0);
406403 }
407404
408 StringRef llvm::dwarf::InlineCodeString(unsigned Code) {
405 const char *llvm::dwarf::InlineCodeString(unsigned Code) {
409406 switch (Code) {
410407 case DW_INL_not_inlined: return "DW_INL_not_inlined";
411408 case DW_INL_inlined: return "DW_INL_inlined";
412409 case DW_INL_declared_not_inlined: return "DW_INL_declared_not_inlined";
413410 case DW_INL_declared_inlined: return "DW_INL_declared_inlined";
414411 }
415 return StringRef();
416 }
417
418 StringRef llvm::dwarf::ArrayOrderString(unsigned Order) {
412 return nullptr;
413 }
414
415 const char *llvm::dwarf::ArrayOrderString(unsigned Order) {
419416 switch (Order) {
420417 case DW_ORD_row_major: return "DW_ORD_row_major";
421418 case DW_ORD_col_major: return "DW_ORD_col_major";
422419 }
423 return StringRef();
424 }
425
426 StringRef llvm::dwarf::DiscriminantString(unsigned Discriminant) {
420 return nullptr;
421 }
422
423 const char *llvm::dwarf::DiscriminantString(unsigned Discriminant) {
427424 switch (Discriminant) {
428425 case DW_DSC_label: return "DW_DSC_label";
429426 case DW_DSC_range: return "DW_DSC_range";
430427 }
431 return StringRef();
432 }
433
434 StringRef llvm::dwarf::LNStandardString(unsigned Standard) {
428 return nullptr;
429 }
430
431 const char *llvm::dwarf::LNStandardString(unsigned Standard) {
435432 switch (Standard) {
436433 case DW_LNS_copy: return "DW_LNS_copy";
437434 case DW_LNS_advance_pc: return "DW_LNS_advance_pc";
446443 case DW_LNS_set_epilogue_begin: return "DW_LNS_set_epilogue_begin";
447444 case DW_LNS_set_isa: return "DW_LNS_set_isa";
448445 }
449 return StringRef();
450 }
451
452 StringRef llvm::dwarf::LNExtendedString(unsigned Encoding) {
446 return nullptr;
447 }
448
449 const char *llvm::dwarf::LNExtendedString(unsigned Encoding) {
453450 switch (Encoding) {
454451 // Line Number Extended Opcode Encodings
455452 case DW_LNE_end_sequence: return "DW_LNE_end_sequence";
459456 case DW_LNE_lo_user: return "DW_LNE_lo_user";
460457 case DW_LNE_hi_user: return "DW_LNE_hi_user";
461458 }
462 return StringRef();
463 }
464
465 StringRef llvm::dwarf::MacinfoString(unsigned Encoding) {
459 return nullptr;
460 }
461
462 const char *llvm::dwarf::MacinfoString(unsigned Encoding) {
466463 switch (Encoding) {
467464 // Macinfo Type Encodings
468465 case DW_MACINFO_define: return "DW_MACINFO_define";
472469 case DW_MACINFO_vendor_ext: return "DW_MACINFO_vendor_ext";
473470 case DW_MACINFO_invalid: return "DW_MACINFO_invalid";
474471 }
475 return StringRef();
472 return nullptr;
476473 }
477474
478475 unsigned llvm::dwarf::getMacinfo(StringRef MacinfoString) {
485482 .Default(DW_MACINFO_invalid);
486483 }
487484
488 StringRef llvm::dwarf::CallFrameString(unsigned Encoding) {
485 const char *llvm::dwarf::CallFrameString(unsigned Encoding) {
489486 switch (Encoding) {
490487 case DW_CFA_nop: return "DW_CFA_nop";
491488 case DW_CFA_advance_loc: return "DW_CFA_advance_loc";
519516 case DW_CFA_lo_user: return "DW_CFA_lo_user";
520517 case DW_CFA_hi_user: return "DW_CFA_hi_user";
521518 }
522 return StringRef();
523 }
524
525 StringRef llvm::dwarf::ApplePropertyString(unsigned Prop) {
519 return nullptr;
520 }
521
522 const char *llvm::dwarf::ApplePropertyString(unsigned Prop) {
526523 switch (Prop) {
527524 case DW_APPLE_PROPERTY_readonly:
528525 return "DW_APPLE_PROPERTY_readonly";
555552 case DW_APPLE_PROPERTY_class:
556553 return "DW_APPLE_PROPERTY_class";
557554 }
558 return StringRef();
559 }
560
561 StringRef llvm::dwarf::AtomTypeString(unsigned AT) {
555 return nullptr;
556 }
557
558 const char *llvm::dwarf::AtomTypeString(unsigned AT) {
562559 switch (AT) {
563560 case dwarf::DW_ATOM_null:
564561 return "DW_ATOM_null";
571568 case DW_ATOM_type_flags:
572569 return "DW_ATOM_type_flags";
573570 }
574 return StringRef();
575 }
576
577 StringRef llvm::dwarf::GDBIndexEntryKindString(GDBIndexEntryKind Kind) {
571 return nullptr;
572 }
573
574 const char *llvm::dwarf::GDBIndexEntryKindString(GDBIndexEntryKind Kind) {
578575 switch (Kind) {
579576 case GIEK_NONE:
580577 return "NONE";
596593 llvm_unreachable("Unknown GDBIndexEntryKind value");
597594 }
598595
599 StringRef
600 llvm::dwarf::GDBIndexEntryLinkageString(GDBIndexEntryLinkage Linkage) {
596 const char *llvm::dwarf::GDBIndexEntryLinkageString(GDBIndexEntryLinkage Linkage) {
601597 switch (Linkage) {
602598 case GIEL_EXTERNAL:
603599 return "EXTERNAL";
607603 llvm_unreachable("Unknown GDBIndexEntryLinkage value");
608604 }
609605
610 StringRef llvm::dwarf::AttributeValueString(uint16_t Attr, unsigned Val) {
606 const char *llvm::dwarf::AttributeValueString(uint16_t Attr, unsigned Val) {
611607 switch (Attr) {
612608 case DW_AT_accessibility:
613609 return AccessibilityString(Val);
635631 return DiscriminantString(Val);
636632 }
637633
638 return StringRef();
639 }
634 return nullptr;
635 }
1616
1717 TEST(DwarfTest, TagStringOnInvalid) {
1818 // This is invalid, so it shouldn't be stringified.
19 EXPECT_EQ(StringRef(), TagString(DW_TAG_invalid));
19 EXPECT_EQ(nullptr, TagString(DW_TAG_invalid));
2020
2121 // These aren't really tags: they describe ranges within tags. They
2222 // shouldn't be stringified either.
23 EXPECT_EQ(StringRef(), TagString(DW_TAG_lo_user));
24 EXPECT_EQ(StringRef(), TagString(DW_TAG_hi_user));
25 EXPECT_EQ(StringRef(), TagString(DW_TAG_user_base));
23 EXPECT_EQ(nullptr, TagString(DW_TAG_lo_user));
24 EXPECT_EQ(nullptr, TagString(DW_TAG_hi_user));
25 EXPECT_EQ(nullptr, TagString(DW_TAG_user_base));
2626 }
2727
2828 TEST(DwarfTest, getTag) {
5757
5858 TEST(DwarfTest, LanguageStringOnInvalid) {
5959 // This is invalid, so it shouldn't be stringified.
60 EXPECT_EQ(StringRef(), LanguageString(0));
60 EXPECT_EQ(nullptr, LanguageString(0));
6161
6262 // These aren't really tags: they describe ranges within tags. They
6363 // shouldn't be stringified either.
64 EXPECT_EQ(StringRef(), LanguageString(DW_LANG_lo_user));
65 EXPECT_EQ(StringRef(), LanguageString(DW_LANG_hi_user));
64 EXPECT_EQ(nullptr, LanguageString(DW_LANG_lo_user));
65 EXPECT_EQ(nullptr, LanguageString(DW_LANG_hi_user));
6666 }
6767
6868 TEST(DwarfTest, getLanguage) {
8484
8585 TEST(DwarfTest, AttributeEncodingStringOnInvalid) {
8686 // This is invalid, so it shouldn't be stringified.
87 EXPECT_EQ(StringRef(), AttributeEncodingString(0));
87 EXPECT_EQ(nullptr, AttributeEncodingString(0));
8888
8989 // These aren't really tags: they describe ranges within tags. They
9090 // shouldn't be stringified either.
91 EXPECT_EQ(StringRef(), AttributeEncodingString(DW_ATE_lo_user));
92 EXPECT_EQ(StringRef(), AttributeEncodingString(DW_ATE_hi_user));
91 EXPECT_EQ(nullptr, AttributeEncodingString(DW_ATE_lo_user));
92 EXPECT_EQ(nullptr, AttributeEncodingString(DW_ATE_hi_user));
9393 }
9494
9595 TEST(DwarfTest, getAttributeEncoding) {
121121 VirtualityString(DW_VIRTUALITY_max));
122122
123123 // Invalid numbers shouldn't be stringified.
124 EXPECT_EQ(StringRef(), VirtualityString(DW_VIRTUALITY_max + 1));
125 EXPECT_EQ(StringRef(), VirtualityString(DW_VIRTUALITY_max + 77));
124 EXPECT_EQ(nullptr, VirtualityString(DW_VIRTUALITY_max + 1));
125 EXPECT_EQ(nullptr, VirtualityString(DW_VIRTUALITY_max + 77));
126126 }
127127
128128 TEST(DwarfTest, getVirtuality) {