llvm.org GIT mirror llvm / f9bb6bc
Re-commit "Use StringRef in Support/Darf APIs (NFC)" This reverts commit r283285 and re-commit r283275 with a fix for format("%s", Str); where Str is a StringRef. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@283298 91177308-0d34-0410-b5e6-96231b3b80d8 Mehdi Amini 4 years ago
12 changed file(s) with 179 addition(s) and 163 deletion(s). Raw diff Collapse all Expand all
605605 /// known.
606606 ///
607607 /// @{
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);
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);
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 const char *AttributeValueString(uint16_t Attr, unsigned Val);
656 StringRef 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 if (const char *Lang = dwarf::LanguageString(CU->getSourceLanguage()))
76 auto Lang = dwarf::LanguageString(CU->getSourceLanguage());
77 if (!Lang.empty())
7778 O << Lang;
7879 else
7980 O << "unknown-language(" << CU->getSourceLanguage() << ")";
104105 printFile(O, T->getFilename(), T->getDirectory(), T->getLine());
105106 if (auto *BT = dyn_cast(T)) {
106107 O << " ";
107 if (const char *Encoding =
108 dwarf::AttributeEncodingString(BT->getEncoding()))
108 auto Encoding = dwarf::AttributeEncodingString(BT->getEncoding());
109 if (!Encoding.empty())
109110 O << Encoding;
110111 else
111112 O << "unknown-encoding(" << BT->getEncoding() << ')';
112113 } else {
113114 O << ' ';
114 if (const char *Tag = dwarf::TagString(T->getTag()))
115 auto Tag = dwarf::TagString(T->getTag());
116 if (!Tag.empty())
115117 O << Tag;
116118 else
117119 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));
65 AP->EmitULEB128(Tag, dwarf::TagString(Tag).data());
6666
6767 // Emit whether it has children DIEs.
68 AP->EmitULEB128((unsigned)Children, dwarf::ChildrenString(Children));
68 AP->EmitULEB128((unsigned)Children, dwarf::ChildrenString(Children).data());
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()));
76 dwarf::AttributeString(AttrData.getAttribute()).data());
7777
7878 // Emit form type.
7979 AP->EmitULEB128(AttrData.getForm(),
80 dwarf::FormEncodingString(AttrData.getForm()));
80 dwarf::FormEncodingString(AttrData.getForm()).data());
8181 }
8282
8383 // Mark end of abbreviation.
6161 }
6262
6363 void DWARFAbbreviationDeclaration::dump(raw_ostream &OS) const {
64 const char *tagString = TagString(getTag());
64 auto tagString = TagString(getTag());
6565 OS << '[' << getCode() << "] ";
66 if (tagString)
66 if (!tagString.empty())
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 const char *attrString = AttributeString(Spec.Attr);
74 if (attrString)
73 auto attrString = AttributeString(Spec.Attr);
74 if (!attrString.empty())
7575 OS << attrString;
7676 else
7777 OS << format("DW_AT_Unknown_%x", Spec.Attr);
7878 OS << '\t';
79 const char *formString = FormEncodingString(Spec.Form);
80 if (formString)
79 auto formString = FormEncodingString(Spec.Form);
80 if (!formString.empty())
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 if (const char *TypeString = dwarf::AtomTypeString(Atom.first))
63 auto TypeString = dwarf::AtomTypeString(Atom.first);
64 if (!TypeString.empty())
6465 OS << TypeString;
6566 else
6667 OS << format("DW_ATOM_Unknown_0x%x", Atom.first);
6768 OS << " Form: ";
68 if (const char *FormString = dwarf::FormEncodingString(Atom.second))
69 auto FormString = dwarf::FormEncodingString(Atom.second);
70 if (!FormString.empty())
6971 OS << FormString;
7072 else
7173 OS << format("DW_FORM_Unknown_0x%x", Atom.second);
5353 OS << format("0x%8.8x ", dieRef);
5454 if (GnuStyle) {
5555 PubIndexEntryDescriptor desc(pubNames.getU8(&offset));
56 OS << format("%-8s", dwarf::GDBIndexEntryLinkageString(desc.Linkage))
57 << ' ' << format("%-8s", dwarf::GDBIndexEntryKindString(desc.Kind))
56 OS << format("%-8s",
57 dwarf::GDBIndexEntryLinkageString(desc.Linkage).data())
58 << ' '
59 << format("%-8s", dwarf::GDBIndexEntryKindString(desc.Kind).data())
5860 << ' ';
5961 }
6062 OS << '\"' << pubNames.getCStr(&offset) << "\"\n";
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 if (const char *OpcodeName = CallFrameString(Opcode))
398 auto OpcodeName = CallFrameString(Opcode);
399 if (!OpcodeName.empty())
399400 OS << " " << OpcodeName;
400401 else
401402 OS << format(" Opcode %x", Opcode);
402403 break;
404 }
403405 case OT_None:
404406 break;
405407 case OT_Address:
4444
4545 if (abbrCode) {
4646 if (AbbrevDecl) {
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());
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());
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 if (const char *PropName = ApplePropertyString(Bit))
85 auto PropName = ApplePropertyString(Bit);
86 if (!PropName.empty())
8687 OS << PropName;
8788 else
8889 OS << format("DW_APPLE_PROPERTY_0x%" PRIx64, Bit);
115116 const char BaseIndent[] = " ";
116117 OS << BaseIndent;
117118 OS.indent(indent+2);
118 const char *attrString = AttributeString(attr);
119 if (attrString)
119 auto attrString = AttributeString(attr);
120 if (!attrString.empty())
120121 WithColor(OS, syntax::Attribute) << attrString;
121122 else
122123 WithColor(OS, syntax::Attribute).get() << format("DW_AT_Unknown_%x", attr);
123124
124 const char *formString = FormEncodingString(form);
125 if (formString)
125 auto formString = FormEncodingString(form);
126 if (!formString.empty())
126127 OS << " [" << formString << ']';
127128 else
128129 OS << format(" [DW_FORM_Unknown_%x]", form);
133134 return;
134135
135136 OS << "\t(";
136
137 const char *Name = nullptr;
137
138 StringRef Name;
138139 std::string File;
139140 auto Color = syntax::Enumerator;
140141 if (attr == DW_AT_decl_file || attr == DW_AT_call_file) {
145146 u->getCompilationDir(),
146147 DILineInfoSpecifier::FileLineInfoKind::AbsoluteFilePath, File)) {
147148 File = '"' + File + '"';
148 Name = File.c_str();
149 Name = File;
149150 }
150151 } else if (Optional Val = formValue.getAsUnsignedConstant())
151152 Name = AttributeValueString(attr, *Val);
152153
153 if (Name)
154 if (!Name.empty())
154155 WithColor(OS, Color) << Name;
155156 else if (attr == DW_AT_decl_line || attr == DW_AT_call_line)
156157 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", LNStandardString(i + 1),
45 StandardOpcodeLengths[i]);
44 OS << format("standard_opcode_lengths[%s] = %u\n",
45 LNStandardString(i + 1).data(), 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 if (const char *Tag = dwarf::TagString(N->getTag()))
1420 auto Tag = dwarf::TagString(N->getTag());
1421 if (!Tag.empty())
14211422 Out << Tag;
14221423 else
14231424 Out << N->getTag();
14251426
14261427 void MDFieldPrinter::printMacinfoType(const DIMacroNode *N) {
14271428 Out << FS << "type: ";
1428 if (const char *Type = dwarf::MacinfoString(N->getMacinfoType()))
1429 auto Type = dwarf::MacinfoString(N->getMacinfoType());
1430 if (!Type.empty())
14291431 Out << Type;
14301432 else
14311433 Out << N->getMacinfoType();
15081510 return;
15091511
15101512 Out << FS << Name << ": ";
1511 if (const char *S = toString(Value))
1513 auto S = toString(Value);
1514 if (!S.empty())
15121515 Out << S;
15131516 else
15141517 Out << Value;
18421845 FieldSeparator FS;
18431846 if (N->isValid()) {
18441847 for (auto I = N->expr_op_begin(), E = N->expr_op_end(); I != E; ++I) {
1845 const char *OpStr = dwarf::OperationEncodingString(I->getOp());
1846 assert(OpStr && "Expected valid opcode");
1848 auto OpStr = dwarf::OperationEncodingString(I->getOp());
1849 assert(!OpStr.empty() && "Expected valid opcode");
18471850
18481851 Out << FS << OpStr;
18491852 for (unsigned A = 0, AE = I->getNumArgs(); A != AE; ++A)
1717 using namespace llvm;
1818 using namespace dwarf;
1919
20 const char *llvm::dwarf::TagString(unsigned Tag) {
20 StringRef llvm::dwarf::TagString(unsigned Tag) {
2121 switch (Tag) {
22 default: return nullptr;
22 default:
23 return StringRef();
2324 #define HANDLE_DW_TAG(ID, NAME) \
2425 case DW_TAG_##NAME: \
2526 return "DW_TAG_" #NAME;
3435 .Default(DW_TAG_invalid);
3536 }
3637
37 const char *llvm::dwarf::ChildrenString(unsigned Children) {
38 StringRef llvm::dwarf::ChildrenString(unsigned Children) {
3839 switch (Children) {
3940 case DW_CHILDREN_no: return "DW_CHILDREN_no";
4041 case DW_CHILDREN_yes: return "DW_CHILDREN_yes";
4142 }
42 return nullptr;
43 }
44
45 const char *llvm::dwarf::AttributeString(unsigned Attribute) {
43 return StringRef();
44 }
45
46 StringRef llvm::dwarf::AttributeString(unsigned Attribute) {
4647 switch (Attribute) {
4748 case DW_AT_sibling: return "DW_AT_sibling";
4849 case DW_AT_location: return "DW_AT_location";
220221 case DW_AT_GNU_pubtypes: return "DW_AT_GNU_pubtypes";
221222 case DW_AT_GNU_discriminator: return "DW_AT_GNU_discriminator";
222223 }
223 return nullptr;
224 }
225
226 const char *llvm::dwarf::FormEncodingString(unsigned Encoding) {
224 return StringRef();
225 }
226
227 StringRef llvm::dwarf::FormEncodingString(unsigned Encoding) {
227228 switch (Encoding) {
228229 case DW_FORM_addr: return "DW_FORM_addr";
229230 case DW_FORM_block2: return "DW_FORM_block2";
259260 case DW_FORM_GNU_ref_alt: return "DW_FORM_GNU_ref_alt";
260261 case DW_FORM_GNU_strp_alt: return "DW_FORM_GNU_strp_alt";
261262 }
262 return nullptr;
263 }
264
265 const char *llvm::dwarf::OperationEncodingString(unsigned Encoding) {
263 return StringRef();
264 }
265
266 StringRef llvm::dwarf::OperationEncodingString(unsigned Encoding) {
266267 switch (Encoding) {
267 default: return nullptr;
268 default:
269 return StringRef();
268270 #define HANDLE_DW_OP(ID, NAME) \
269271 case DW_OP_##NAME: \
270272 return "DW_OP_" #NAME;
279281 .Default(0);
280282 }
281283
282 const char *llvm::dwarf::AttributeEncodingString(unsigned Encoding) {
284 StringRef llvm::dwarf::AttributeEncodingString(unsigned Encoding) {
283285 switch (Encoding) {
284 default: return nullptr;
286 default:
287 return StringRef();
285288 #define HANDLE_DW_ATE(ID, NAME) \
286289 case DW_ATE_##NAME: \
287290 return "DW_ATE_" #NAME;
296299 .Default(0);
297300 }
298301
299 const char *llvm::dwarf::DecimalSignString(unsigned Sign) {
302 StringRef llvm::dwarf::DecimalSignString(unsigned Sign) {
300303 switch (Sign) {
301304 case DW_DS_unsigned: return "DW_DS_unsigned";
302305 case DW_DS_leading_overpunch: return "DW_DS_leading_overpunch";
304307 case DW_DS_leading_separate: return "DW_DS_leading_separate";
305308 case DW_DS_trailing_separate: return "DW_DS_trailing_separate";
306309 }
307 return nullptr;
308 }
309
310 const char *llvm::dwarf::EndianityString(unsigned Endian) {
310 return StringRef();
311 }
312
313 StringRef llvm::dwarf::EndianityString(unsigned Endian) {
311314 switch (Endian) {
312315 case DW_END_default: return "DW_END_default";
313316 case DW_END_big: return "DW_END_big";
315318 case DW_END_lo_user: return "DW_END_lo_user";
316319 case DW_END_hi_user: return "DW_END_hi_user";
317320 }
318 return nullptr;
319 }
320
321 const char *llvm::dwarf::AccessibilityString(unsigned Access) {
321 return StringRef();
322 }
323
324 StringRef llvm::dwarf::AccessibilityString(unsigned Access) {
322325 switch (Access) {
323326 // Accessibility codes
324327 case DW_ACCESS_public: return "DW_ACCESS_public";
325328 case DW_ACCESS_protected: return "DW_ACCESS_protected";
326329 case DW_ACCESS_private: return "DW_ACCESS_private";
327330 }
328 return nullptr;
329 }
330
331 const char *llvm::dwarf::VisibilityString(unsigned Visibility) {
331 return StringRef();
332 }
333
334 StringRef llvm::dwarf::VisibilityString(unsigned Visibility) {
332335 switch (Visibility) {
333336 case DW_VIS_local: return "DW_VIS_local";
334337 case DW_VIS_exported: return "DW_VIS_exported";
335338 case DW_VIS_qualified: return "DW_VIS_qualified";
336339 }
337 return nullptr;
338 }
339
340 const char *llvm::dwarf::VirtualityString(unsigned Virtuality) {
340 return StringRef();
341 }
342
343 StringRef llvm::dwarf::VirtualityString(unsigned Virtuality) {
341344 switch (Virtuality) {
342345 default:
343 return nullptr;
346 return StringRef();
344347 #define HANDLE_DW_VIRTUALITY(ID, NAME) \
345348 case DW_VIRTUALITY_##NAME: \
346349 return "DW_VIRTUALITY_" #NAME;
356359 .Default(DW_VIRTUALITY_invalid);
357360 }
358361
359 const char *llvm::dwarf::LanguageString(unsigned Language) {
362 StringRef llvm::dwarf::LanguageString(unsigned Language) {
360363 switch (Language) {
361364 default:
362 return nullptr;
365 return StringRef();
363366 #define HANDLE_DW_LANG(ID, NAME) \
364367 case DW_LANG_##NAME: \
365368 return "DW_LANG_" #NAME;
374377 .Default(0);
375378 }
376379
377 const char *llvm::dwarf::CaseString(unsigned Case) {
380 StringRef llvm::dwarf::CaseString(unsigned Case) {
378381 switch (Case) {
379382 case DW_ID_case_sensitive: return "DW_ID_case_sensitive";
380383 case DW_ID_up_case: return "DW_ID_up_case";
381384 case DW_ID_down_case: return "DW_ID_down_case";
382385 case DW_ID_case_insensitive: return "DW_ID_case_insensitive";
383386 }
384 return nullptr;
385 }
386
387 const char *llvm::dwarf::ConventionString(unsigned CC) {
387 return StringRef();
388 }
389
390 StringRef llvm::dwarf::ConventionString(unsigned CC) {
388391 switch (CC) {
389392 default:
390 return nullptr;
393 return StringRef();
391394 #define HANDLE_DW_CC(ID, NAME) \
392395 case DW_CC_##NAME: \
393396 return "DW_CC_" #NAME;
402405 .Default(0);
403406 }
404407
405 const char *llvm::dwarf::InlineCodeString(unsigned Code) {
408 StringRef llvm::dwarf::InlineCodeString(unsigned Code) {
406409 switch (Code) {
407410 case DW_INL_not_inlined: return "DW_INL_not_inlined";
408411 case DW_INL_inlined: return "DW_INL_inlined";
409412 case DW_INL_declared_not_inlined: return "DW_INL_declared_not_inlined";
410413 case DW_INL_declared_inlined: return "DW_INL_declared_inlined";
411414 }
412 return nullptr;
413 }
414
415 const char *llvm::dwarf::ArrayOrderString(unsigned Order) {
415 return StringRef();
416 }
417
418 StringRef llvm::dwarf::ArrayOrderString(unsigned Order) {
416419 switch (Order) {
417420 case DW_ORD_row_major: return "DW_ORD_row_major";
418421 case DW_ORD_col_major: return "DW_ORD_col_major";
419422 }
420 return nullptr;
421 }
422
423 const char *llvm::dwarf::DiscriminantString(unsigned Discriminant) {
423 return StringRef();
424 }
425
426 StringRef llvm::dwarf::DiscriminantString(unsigned Discriminant) {
424427 switch (Discriminant) {
425428 case DW_DSC_label: return "DW_DSC_label";
426429 case DW_DSC_range: return "DW_DSC_range";
427430 }
428 return nullptr;
429 }
430
431 const char *llvm::dwarf::LNStandardString(unsigned Standard) {
431 return StringRef();
432 }
433
434 StringRef llvm::dwarf::LNStandardString(unsigned Standard) {
432435 switch (Standard) {
433436 case DW_LNS_copy: return "DW_LNS_copy";
434437 case DW_LNS_advance_pc: return "DW_LNS_advance_pc";
443446 case DW_LNS_set_epilogue_begin: return "DW_LNS_set_epilogue_begin";
444447 case DW_LNS_set_isa: return "DW_LNS_set_isa";
445448 }
446 return nullptr;
447 }
448
449 const char *llvm::dwarf::LNExtendedString(unsigned Encoding) {
449 return StringRef();
450 }
451
452 StringRef llvm::dwarf::LNExtendedString(unsigned Encoding) {
450453 switch (Encoding) {
451454 // Line Number Extended Opcode Encodings
452455 case DW_LNE_end_sequence: return "DW_LNE_end_sequence";
456459 case DW_LNE_lo_user: return "DW_LNE_lo_user";
457460 case DW_LNE_hi_user: return "DW_LNE_hi_user";
458461 }
459 return nullptr;
460 }
461
462 const char *llvm::dwarf::MacinfoString(unsigned Encoding) {
462 return StringRef();
463 }
464
465 StringRef llvm::dwarf::MacinfoString(unsigned Encoding) {
463466 switch (Encoding) {
464467 // Macinfo Type Encodings
465468 case DW_MACINFO_define: return "DW_MACINFO_define";
469472 case DW_MACINFO_vendor_ext: return "DW_MACINFO_vendor_ext";
470473 case DW_MACINFO_invalid: return "DW_MACINFO_invalid";
471474 }
472 return nullptr;
475 return StringRef();
473476 }
474477
475478 unsigned llvm::dwarf::getMacinfo(StringRef MacinfoString) {
482485 .Default(DW_MACINFO_invalid);
483486 }
484487
485 const char *llvm::dwarf::CallFrameString(unsigned Encoding) {
488 StringRef llvm::dwarf::CallFrameString(unsigned Encoding) {
486489 switch (Encoding) {
487490 case DW_CFA_nop: return "DW_CFA_nop";
488491 case DW_CFA_advance_loc: return "DW_CFA_advance_loc";
516519 case DW_CFA_lo_user: return "DW_CFA_lo_user";
517520 case DW_CFA_hi_user: return "DW_CFA_hi_user";
518521 }
519 return nullptr;
520 }
521
522 const char *llvm::dwarf::ApplePropertyString(unsigned Prop) {
522 return StringRef();
523 }
524
525 StringRef llvm::dwarf::ApplePropertyString(unsigned Prop) {
523526 switch (Prop) {
524527 case DW_APPLE_PROPERTY_readonly:
525528 return "DW_APPLE_PROPERTY_readonly";
552555 case DW_APPLE_PROPERTY_class:
553556 return "DW_APPLE_PROPERTY_class";
554557 }
555 return nullptr;
556 }
557
558 const char *llvm::dwarf::AtomTypeString(unsigned AT) {
558 return StringRef();
559 }
560
561 StringRef llvm::dwarf::AtomTypeString(unsigned AT) {
559562 switch (AT) {
560563 case dwarf::DW_ATOM_null:
561564 return "DW_ATOM_null";
568571 case DW_ATOM_type_flags:
569572 return "DW_ATOM_type_flags";
570573 }
571 return nullptr;
572 }
573
574 const char *llvm::dwarf::GDBIndexEntryKindString(GDBIndexEntryKind Kind) {
574 return StringRef();
575 }
576
577 StringRef llvm::dwarf::GDBIndexEntryKindString(GDBIndexEntryKind Kind) {
575578 switch (Kind) {
576579 case GIEK_NONE:
577580 return "NONE";
593596 llvm_unreachable("Unknown GDBIndexEntryKind value");
594597 }
595598
596 const char *llvm::dwarf::GDBIndexEntryLinkageString(GDBIndexEntryLinkage Linkage) {
599 StringRef
600 llvm::dwarf::GDBIndexEntryLinkageString(GDBIndexEntryLinkage Linkage) {
597601 switch (Linkage) {
598602 case GIEL_EXTERNAL:
599603 return "EXTERNAL";
603607 llvm_unreachable("Unknown GDBIndexEntryLinkage value");
604608 }
605609
606 const char *llvm::dwarf::AttributeValueString(uint16_t Attr, unsigned Val) {
610 StringRef llvm::dwarf::AttributeValueString(uint16_t Attr, unsigned Val) {
607611 switch (Attr) {
608612 case DW_AT_accessibility:
609613 return AccessibilityString(Val);
631635 return DiscriminantString(Val);
632636 }
633637
634 return nullptr;
635 }
638 return StringRef();
639 }
1616
1717 TEST(DwarfTest, TagStringOnInvalid) {
1818 // This is invalid, so it shouldn't be stringified.
19 EXPECT_EQ(nullptr, TagString(DW_TAG_invalid));
19 EXPECT_EQ(StringRef(), 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(nullptr, TagString(DW_TAG_lo_user));
24 EXPECT_EQ(nullptr, TagString(DW_TAG_hi_user));
25 EXPECT_EQ(nullptr, TagString(DW_TAG_user_base));
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));
2626 }
2727
2828 TEST(DwarfTest, getTag) {
5757
5858 TEST(DwarfTest, LanguageStringOnInvalid) {
5959 // This is invalid, so it shouldn't be stringified.
60 EXPECT_EQ(nullptr, LanguageString(0));
60 EXPECT_EQ(StringRef(), LanguageString(0));
6161
6262 // These aren't really tags: they describe ranges within tags. They
6363 // shouldn't be stringified either.
64 EXPECT_EQ(nullptr, LanguageString(DW_LANG_lo_user));
65 EXPECT_EQ(nullptr, LanguageString(DW_LANG_hi_user));
64 EXPECT_EQ(StringRef(), LanguageString(DW_LANG_lo_user));
65 EXPECT_EQ(StringRef(), 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(nullptr, AttributeEncodingString(0));
87 EXPECT_EQ(StringRef(), AttributeEncodingString(0));
8888
8989 // These aren't really tags: they describe ranges within tags. They
9090 // shouldn't be stringified either.
91 EXPECT_EQ(nullptr, AttributeEncodingString(DW_ATE_lo_user));
92 EXPECT_EQ(nullptr, AttributeEncodingString(DW_ATE_hi_user));
91 EXPECT_EQ(StringRef(), AttributeEncodingString(DW_ATE_lo_user));
92 EXPECT_EQ(StringRef(), 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(nullptr, VirtualityString(DW_VIRTUALITY_max + 1));
125 EXPECT_EQ(nullptr, VirtualityString(DW_VIRTUALITY_max + 77));
124 EXPECT_EQ(StringRef(), VirtualityString(DW_VIRTUALITY_max + 1));
125 EXPECT_EQ(StringRef(), VirtualityString(DW_VIRTUALITY_max + 77));
126126 }
127127
128128 TEST(DwarfTest, getVirtuality) {