diff --git a/llvm/test/tools/llvm-pdbutil/Inputs/unknown-record.obj b/llvm/test/tools/llvm-pdbutil/Inputs/unknown-record.obj new file mode 100644 index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 GIT binary patch literal 0 Hc$@"); -const StringRef SimpleLabel(""); -const StringRef UnknownLabel(""); - } // namespace -static StringRef getUdtStatLabel(uint32_t Kind) { +static std::string getUdtStatLabel(uint32_t Kind) { if (Kind == kNoneUdtKind) - return NoneLabel; + return ""; if (Kind == kSimpleUdtKind) - return SimpleLabel; + return ""; if (Kind == kUnknownUdtKind) - return UnknownLabel; + return ""; return formatTypeLeafKind(static_cast(Kind)); } @@ -760,7 +756,7 @@ static uint32_t getLongestTypeLeafName(const StatCollection &Stats) { size_t L = 0; for (const auto &Stat : Stats.Individual) { - StringRef Label = getUdtStatLabel(Stat.first); + std::string Label = getUdtStatLabel(Stat.first); L = std::max(L, Label.size()); } return static_cast(L); @@ -869,7 +865,7 @@ P.formatLine("{0}", fmt_repeat('-', TableWidth)); for (const auto &Stat : UdtTargetStats.getStatsSortedBySize()) { - StringRef Label = getUdtStatLabel(Stat.first); + std::string Label = getUdtStatLabel(Stat.first); P.formatLine("{0} | {1:N} {2:N}", fmt_align(Label, AlignStyle::Right, FieldWidth), fmt_align(Stat.second.Count, AlignStyle::Right, CD), diff --git a/llvm/tools/llvm-pdbutil/FormatUtil.h b/llvm/tools/llvm-pdbutil/FormatUtil.h --- a/llvm/tools/llvm-pdbutil/FormatUtil.h +++ b/llvm/tools/llvm-pdbutil/FormatUtil.h @@ -66,7 +66,7 @@ std::string formatChunkKind(codeview::DebugSubsectionKind Kind, bool Friendly = true); std::string formatSymbolKind(codeview::SymbolKind K); -StringRef formatTypeLeafKind(codeview::TypeLeafKind K); +std::string formatTypeLeafKind(codeview::TypeLeafKind K); /// Returns the number of digits in the given integer. inline int NumDigits(uint64_t N) { diff --git a/llvm/tools/llvm-pdbutil/FormatUtil.cpp b/llvm/tools/llvm-pdbutil/FormatUtil.cpp --- a/llvm/tools/llvm-pdbutil/FormatUtil.cpp +++ b/llvm/tools/llvm-pdbutil/FormatUtil.cpp @@ -156,16 +156,17 @@ return formatUnknownEnum(K); } -StringRef llvm::pdb::formatTypeLeafKind(TypeLeafKind K) { +std::string llvm::pdb::formatTypeLeafKind(TypeLeafKind K) { switch (K) { #define TYPE_RECORD(EnumName, value, name) \ case EnumName: \ return #EnumName; #include "llvm/DebugInfo/CodeView/CodeViewTypes.def" default: - llvm_unreachable("Unknown type leaf kind!"); + return formatv("UNKNOWN RECORD ({0:X})", + static_cast>(K)) + .str(); } - return ""; } std::string llvm::pdb::formatSegmentOffset(uint16_t Segment, uint32_t Offset) {