[llvm] r283278 - Revert "Use StringRef in Support/Darf APIs (NFC)"

Mehdi Amini via llvm-commits llvm-commits at lists.llvm.org
Tue Oct 4 17:21:14 PDT 2016


Author: mehdi_amini
Date: Tue Oct  4 19:21:14 2016
New Revision: 283278

URL: http://llvm.org/viewvc/llvm-project?rev=283278&view=rev
Log:
Revert "Use StringRef in Support/Darf APIs (NFC)"

This reverts commit r283275, it broke LLDB Android debug server.

Modified:
    llvm/trunk/include/llvm/Support/Dwarf.h
    llvm/trunk/lib/Analysis/ModuleDebugInfoPrinter.cpp
    llvm/trunk/lib/CodeGen/AsmPrinter/DIE.cpp
    llvm/trunk/lib/DebugInfo/DWARF/DWARFAbbreviationDeclaration.cpp
    llvm/trunk/lib/DebugInfo/DWARF/DWARFAcceleratorTable.cpp
    llvm/trunk/lib/DebugInfo/DWARF/DWARFDebugFrame.cpp
    llvm/trunk/lib/DebugInfo/DWARF/DWARFDebugInfoEntry.cpp
    llvm/trunk/lib/DebugInfo/DWARF/DWARFDebugLine.cpp
    llvm/trunk/lib/IR/AsmWriter.cpp
    llvm/trunk/lib/Support/Dwarf.cpp
    llvm/trunk/unittests/Support/DwarfTest.cpp

Modified: llvm/trunk/include/llvm/Support/Dwarf.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/Dwarf.h?rev=283278&r1=283277&r2=283278&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Support/Dwarf.h (original)
+++ llvm/trunk/include/llvm/Support/Dwarf.h Tue Oct  4 19:21:14 2016
@@ -606,31 +606,31 @@ enum GDBIndexEntryLinkage {
 /// known.
 ///
 /// @{
-StringRef TagString(unsigned Tag);
-StringRef ChildrenString(unsigned Children);
-StringRef AttributeString(unsigned Attribute);
-StringRef FormEncodingString(unsigned Encoding);
-StringRef OperationEncodingString(unsigned Encoding);
-StringRef AttributeEncodingString(unsigned Encoding);
-StringRef DecimalSignString(unsigned Sign);
-StringRef EndianityString(unsigned Endian);
-StringRef AccessibilityString(unsigned Access);
-StringRef VisibilityString(unsigned Visibility);
-StringRef VirtualityString(unsigned Virtuality);
-StringRef LanguageString(unsigned Language);
-StringRef CaseString(unsigned Case);
-StringRef ConventionString(unsigned Convention);
-StringRef InlineCodeString(unsigned Code);
-StringRef ArrayOrderString(unsigned Order);
-StringRef DiscriminantString(unsigned Discriminant);
-StringRef LNStandardString(unsigned Standard);
-StringRef LNExtendedString(unsigned Encoding);
-StringRef MacinfoString(unsigned Encoding);
-StringRef CallFrameString(unsigned Encoding);
-StringRef ApplePropertyString(unsigned);
-StringRef AtomTypeString(unsigned Atom);
-StringRef GDBIndexEntryKindString(GDBIndexEntryKind Kind);
-StringRef GDBIndexEntryLinkageString(GDBIndexEntryLinkage Linkage);
+const char *TagString(unsigned Tag);
+const char *ChildrenString(unsigned Children);
+const char *AttributeString(unsigned Attribute);
+const char *FormEncodingString(unsigned Encoding);
+const char *OperationEncodingString(unsigned Encoding);
+const char *AttributeEncodingString(unsigned Encoding);
+const char *DecimalSignString(unsigned Sign);
+const char *EndianityString(unsigned Endian);
+const char *AccessibilityString(unsigned Access);
+const char *VisibilityString(unsigned Visibility);
+const char *VirtualityString(unsigned Virtuality);
+const char *LanguageString(unsigned Language);
+const char *CaseString(unsigned Case);
+const char *ConventionString(unsigned Convention);
+const char *InlineCodeString(unsigned Code);
+const char *ArrayOrderString(unsigned Order);
+const char *DiscriminantString(unsigned Discriminant);
+const char *LNStandardString(unsigned Standard);
+const char *LNExtendedString(unsigned Encoding);
+const char *MacinfoString(unsigned Encoding);
+const char *CallFrameString(unsigned Encoding);
+const char *ApplePropertyString(unsigned);
+const char *AtomTypeString(unsigned Atom);
+const char *GDBIndexEntryKindString(GDBIndexEntryKind Kind);
+const char *GDBIndexEntryLinkageString(GDBIndexEntryLinkage Linkage);
 /// @}
 
 /// \defgroup DwarfConstantsParsing Dwarf constants parsing functions
@@ -654,7 +654,7 @@ unsigned getMacinfo(StringRef MacinfoStr
 
 /// \brief Returns the symbolic string representing Val when used as a value
 /// for attribute Attr.
-StringRef AttributeValueString(uint16_t Attr, unsigned Val);
+const char *AttributeValueString(uint16_t Attr, unsigned Val);
 
 /// \brief Decsribes an entry of the various gnu_pub* debug sections.
 ///

Modified: llvm/trunk/lib/Analysis/ModuleDebugInfoPrinter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/ModuleDebugInfoPrinter.cpp?rev=283278&r1=283277&r2=283278&view=diff
==============================================================================
--- llvm/trunk/lib/Analysis/ModuleDebugInfoPrinter.cpp (original)
+++ llvm/trunk/lib/Analysis/ModuleDebugInfoPrinter.cpp Tue Oct  4 19:21:14 2016
@@ -74,8 +74,7 @@ void ModuleDebugInfoPrinter::print(raw_o
   // filenames), so just print a few useful things.
   for (DICompileUnit *CU : Finder.compile_units()) {
     O << "Compile unit: ";
-    auto Lang = dwarf::LanguageString(CU->getSourceLanguage());
-    if (!Lang.empty())
+    if (const char *Lang = dwarf::LanguageString(CU->getSourceLanguage()))
       O << Lang;
     else
       O << "unknown-language(" << CU->getSourceLanguage() << ")";
@@ -106,15 +105,14 @@ void ModuleDebugInfoPrinter::print(raw_o
     printFile(O, T->getFilename(), T->getDirectory(), T->getLine());
     if (auto *BT = dyn_cast<DIBasicType>(T)) {
       O << " ";
-      auto Encoding = dwarf::AttributeEncodingString(BT->getEncoding());
-      if (!Encoding.empty())
+      if (const char *Encoding =
+              dwarf::AttributeEncodingString(BT->getEncoding()))
         O << Encoding;
       else
         O << "unknown-encoding(" << BT->getEncoding() << ')';
     } else {
       O << ' ';
-      auto Tag = dwarf::TagString(T->getTag());
-      if (!Tag.empty())
+      if (const char *Tag = dwarf::TagString(T->getTag()))
         O << Tag;
       else
         O << "unknown-tag(" << T->getTag() << ")";

Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DIE.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DIE.cpp?rev=283278&r1=283277&r2=283278&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/AsmPrinter/DIE.cpp (original)
+++ llvm/trunk/lib/CodeGen/AsmPrinter/DIE.cpp Tue Oct  4 19:21:14 2016
@@ -63,10 +63,10 @@ void DIEAbbrev::Profile(FoldingSetNodeID
 ///
 void DIEAbbrev::Emit(const AsmPrinter *AP) const {
   // Emit its Dwarf tag type.
-  AP->EmitULEB128(Tag, dwarf::TagString(Tag).data());
+  AP->EmitULEB128(Tag, dwarf::TagString(Tag));
 
   // Emit whether it has children DIEs.
-  AP->EmitULEB128((unsigned)Children, dwarf::ChildrenString(Children).data());
+  AP->EmitULEB128((unsigned)Children, dwarf::ChildrenString(Children));
 
   // For each attribute description.
   for (unsigned i = 0, N = Data.size(); i < N; ++i) {
@@ -74,11 +74,11 @@ void DIEAbbrev::Emit(const AsmPrinter *A
 
     // Emit attribute type.
     AP->EmitULEB128(AttrData.getAttribute(),
-                    dwarf::AttributeString(AttrData.getAttribute()).data());
+                    dwarf::AttributeString(AttrData.getAttribute()));
 
     // Emit form type.
     AP->EmitULEB128(AttrData.getForm(),
-                    dwarf::FormEncodingString(AttrData.getForm()).data());
+                    dwarf::FormEncodingString(AttrData.getForm()));
   }
 
   // Mark end of abbreviation.

Modified: llvm/trunk/lib/DebugInfo/DWARF/DWARFAbbreviationDeclaration.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/DWARF/DWARFAbbreviationDeclaration.cpp?rev=283278&r1=283277&r2=283278&view=diff
==============================================================================
--- llvm/trunk/lib/DebugInfo/DWARF/DWARFAbbreviationDeclaration.cpp (original)
+++ llvm/trunk/lib/DebugInfo/DWARF/DWARFAbbreviationDeclaration.cpp Tue Oct  4 19:21:14 2016
@@ -62,23 +62,23 @@ DWARFAbbreviationDeclaration::extract(Da
 }
 
 void DWARFAbbreviationDeclaration::dump(raw_ostream &OS) const {
-  auto tagString = TagString(getTag());
+  const char *tagString = TagString(getTag());
   OS << '[' << getCode() << "] ";
-  if (!tagString.empty())
+  if (tagString)
     OS << tagString;
   else
     OS << format("DW_TAG_Unknown_%x", getTag());
   OS << "\tDW_CHILDREN_" << (hasChildren() ? "yes" : "no") << '\n';
   for (const AttributeSpec &Spec : AttributeSpecs) {
     OS << '\t';
-    auto attrString = AttributeString(Spec.Attr);
-    if (!attrString.empty())
+    const char *attrString = AttributeString(Spec.Attr);
+    if (attrString)
       OS << attrString;
     else
       OS << format("DW_AT_Unknown_%x", Spec.Attr);
     OS << '\t';
-    auto formString = FormEncodingString(Spec.Form);
-    if (!formString.empty())
+    const char *formString = FormEncodingString(Spec.Form);
+    if (formString)
       OS << formString;
     else
       OS << format("DW_FORM_Unknown_%x", Spec.Form);

Modified: llvm/trunk/lib/DebugInfo/DWARF/DWARFAcceleratorTable.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/DWARF/DWARFAcceleratorTable.cpp?rev=283278&r1=283277&r2=283278&view=diff
==============================================================================
--- llvm/trunk/lib/DebugInfo/DWARF/DWARFAcceleratorTable.cpp (original)
+++ llvm/trunk/lib/DebugInfo/DWARF/DWARFAcceleratorTable.cpp Tue Oct  4 19:21:14 2016
@@ -61,14 +61,12 @@ void DWARFAcceleratorTable::dump(raw_ost
   SmallVector<DWARFFormValue, 3> AtomForms;
   for (const auto &Atom: HdrData.Atoms) {
     OS << format("Atom[%d] Type: ", i++);
-    auto TypeString = dwarf::AtomTypeString(Atom.first);
-    if (!TypeString.empty())
+    if (const char *TypeString = dwarf::AtomTypeString(Atom.first))
       OS << TypeString;
     else
       OS << format("DW_ATOM_Unknown_0x%x", Atom.first);
     OS << " Form: ";
-    auto FormString = dwarf::FormEncodingString(Atom.second);
-    if (!FormString.empty())
+    if (const char *FormString = dwarf::FormEncodingString(Atom.second))
       OS << FormString;
     else
       OS << format("DW_FORM_Unknown_0x%x", Atom.second);

Modified: llvm/trunk/lib/DebugInfo/DWARF/DWARFDebugFrame.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/DWARF/DWARFDebugFrame.cpp?rev=283278&r1=283277&r2=283278&view=diff
==============================================================================
--- llvm/trunk/lib/DebugInfo/DWARF/DWARFDebugFrame.cpp (original)
+++ llvm/trunk/lib/DebugInfo/DWARF/DWARFDebugFrame.cpp Tue Oct  4 19:21:14 2016
@@ -394,15 +394,13 @@ static void printOperand(raw_ostream &OS
   OperandType Type = OpTypes[Opcode][OperandIdx];
 
   switch (Type) {
-  case OT_Unset: {
+  case OT_Unset:
     OS << " Unsupported " << (OperandIdx ? "second" : "first") << " operand to";
-    auto OpcodeName = CallFrameString(Opcode);
-    if (!OpcodeName.empty())
+    if (const char *OpcodeName = CallFrameString(Opcode))
       OS << " " << OpcodeName;
     else
       OS << format(" Opcode %x",  Opcode);
     break;
-  }
   case OT_None:
     break;
   case OT_Address:

Modified: llvm/trunk/lib/DebugInfo/DWARF/DWARFDebugInfoEntry.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/DWARF/DWARFDebugInfoEntry.cpp?rev=283278&r1=283277&r2=283278&view=diff
==============================================================================
--- llvm/trunk/lib/DebugInfo/DWARF/DWARFDebugInfoEntry.cpp (original)
+++ llvm/trunk/lib/DebugInfo/DWARF/DWARFDebugInfoEntry.cpp Tue Oct  4 19:21:14 2016
@@ -45,12 +45,12 @@ void DWARFDebugInfoEntryMinimal::dump(ra
 
     if (abbrCode) {
       if (AbbrevDecl) {
-        auto tagString = TagString(getTag());
-        if (!tagString.empty())
-          WithColor(OS, syntax::Tag).get().indent(indent) << tagString;
-        else
-          WithColor(OS, syntax::Tag).get().indent(indent)
-              << format("DW_TAG_Unknown_%x", getTag());
+          const char *tagString = TagString(getTag());
+          if (tagString)
+            WithColor(OS, syntax::Tag).get().indent(indent) << tagString;
+          else
+            WithColor(OS, syntax::Tag).get().indent(indent) <<
+              format("DW_TAG_Unknown_%x", getTag());
 
         OS << format(" [%u] %c\n", abbrCode,
                      AbbrevDecl->hasChildren() ? '*' : ' ');
@@ -83,8 +83,7 @@ static void dumpApplePropertyAttribute(r
     uint64_t Shift = countTrailingZeros(Val);
     assert(Shift < 64 && "undefined behavior");
     uint64_t Bit = 1ULL << Shift;
-    auto PropName = ApplePropertyString(Bit);
-    if (!PropName.empty())
+    if (const char *PropName = ApplePropertyString(Bit))
       OS << PropName;
     else
       OS << format("DW_APPLE_PROPERTY_0x%" PRIx64, Bit);
@@ -117,14 +116,14 @@ void DWARFDebugInfoEntryMinimal::dumpAtt
   const char BaseIndent[] = "            ";
   OS << BaseIndent;
   OS.indent(indent+2);
-  auto attrString = AttributeString(attr);
-  if (!attrString.empty())
+  const char *attrString = AttributeString(attr);
+  if (attrString)
     WithColor(OS, syntax::Attribute) << attrString;
   else
     WithColor(OS, syntax::Attribute).get() << format("DW_AT_Unknown_%x", attr);
 
-  auto formString = FormEncodingString(form);
-  if (!formString.empty())
+  const char *formString = FormEncodingString(form);
+  if (formString)
     OS << " [" << formString << ']';
   else
     OS << format(" [DW_FORM_Unknown_%x]", form);
@@ -135,8 +134,8 @@ void DWARFDebugInfoEntryMinimal::dumpAtt
     return;
 
   OS << "\t(";
-
-  StringRef Name;
+  
+  const char *Name = nullptr;
   std::string File;
   auto Color = syntax::Enumerator;
   if (attr == DW_AT_decl_file || attr == DW_AT_call_file) {
@@ -147,12 +146,12 @@ void DWARFDebugInfoEntryMinimal::dumpAtt
              u->getCompilationDir(),
              DILineInfoSpecifier::FileLineInfoKind::AbsoluteFilePath, File)) {
         File = '"' + File + '"';
-        Name = File;
+        Name = File.c_str();
       }
   } else if (Optional<uint64_t> Val = formValue.getAsUnsignedConstant())
     Name = AttributeValueString(attr, *Val);
 
-  if (!Name.empty())
+  if (Name)
     WithColor(OS, Color) << Name;
   else if (attr == DW_AT_decl_line || attr == DW_AT_call_line)
     OS << *formValue.getAsUnsignedConstant();

Modified: llvm/trunk/lib/DebugInfo/DWARF/DWARFDebugLine.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/DWARF/DWARFDebugLine.cpp?rev=283278&r1=283277&r2=283278&view=diff
==============================================================================
--- llvm/trunk/lib/DebugInfo/DWARF/DWARFDebugLine.cpp (original)
+++ llvm/trunk/lib/DebugInfo/DWARF/DWARFDebugLine.cpp Tue Oct  4 19:21:14 2016
@@ -42,8 +42,8 @@ void DWARFDebugLine::Prologue::dump(raw_
      << format("     opcode_base: %u\n", OpcodeBase);
 
   for (uint32_t i = 0; i < StandardOpcodeLengths.size(); ++i)
-    OS << format("standard_opcode_lengths[%s] = %u\n",
-                 LNStandardString(i + 1).data(), StandardOpcodeLengths[i]);
+    OS << format("standard_opcode_lengths[%s] = %u\n", LNStandardString(i + 1),
+                 StandardOpcodeLengths[i]);
 
   if (!IncludeDirectories.empty())
     for (uint32_t i = 0; i < IncludeDirectories.size(); ++i)

Modified: llvm/trunk/lib/IR/AsmWriter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/IR/AsmWriter.cpp?rev=283278&r1=283277&r2=283278&view=diff
==============================================================================
--- llvm/trunk/lib/IR/AsmWriter.cpp (original)
+++ llvm/trunk/lib/IR/AsmWriter.cpp Tue Oct  4 19:21:14 2016
@@ -1418,8 +1418,7 @@ struct MDFieldPrinter {
 
 void MDFieldPrinter::printTag(const DINode *N) {
   Out << FS << "tag: ";
-  auto Tag = dwarf::TagString(N->getTag());
-  if (!Tag.empty())
+  if (const char *Tag = dwarf::TagString(N->getTag()))
     Out << Tag;
   else
     Out << N->getTag();
@@ -1427,8 +1426,7 @@ void MDFieldPrinter::printTag(const DINo
 
 void MDFieldPrinter::printMacinfoType(const DIMacroNode *N) {
   Out << FS << "type: ";
-  auto Type = dwarf::MacinfoString(N->getMacinfoType());
-  if (!Type.empty())
+  if (const char *Type = dwarf::MacinfoString(N->getMacinfoType()))
     Out << Type;
   else
     Out << N->getMacinfoType();
@@ -1511,8 +1509,7 @@ void MDFieldPrinter::printDwarfEnum(Stri
     return;
 
   Out << FS << Name << ": ";
-  auto S = toString(Value);
-  if (!S.empty())
+  if (const char *S = toString(Value))
     Out << S;
   else
     Out << Value;
@@ -1846,8 +1843,8 @@ static void writeDIExpression(raw_ostrea
   FieldSeparator FS;
   if (N->isValid()) {
     for (auto I = N->expr_op_begin(), E = N->expr_op_end(); I != E; ++I) {
-      auto OpStr = dwarf::OperationEncodingString(I->getOp());
-      assert(!OpStr.empty() && "Expected valid opcode");
+      const char *OpStr = dwarf::OperationEncodingString(I->getOp());
+      assert(OpStr && "Expected valid opcode");
 
       Out << FS << OpStr;
       for (unsigned A = 0, AE = I->getNumArgs(); A != AE; ++A)

Modified: llvm/trunk/lib/Support/Dwarf.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/Dwarf.cpp?rev=283278&r1=283277&r2=283278&view=diff
==============================================================================
--- llvm/trunk/lib/Support/Dwarf.cpp (original)
+++ llvm/trunk/lib/Support/Dwarf.cpp Tue Oct  4 19:21:14 2016
@@ -18,10 +18,9 @@
 using namespace llvm;
 using namespace dwarf;
 
-StringRef llvm::dwarf::TagString(unsigned Tag) {
+const char *llvm::dwarf::TagString(unsigned Tag) {
   switch (Tag) {
-  default:
-    return StringRef();
+  default: return nullptr;
 #define HANDLE_DW_TAG(ID, NAME)                                                \
   case DW_TAG_##NAME:                                                          \
     return "DW_TAG_" #NAME;
@@ -36,15 +35,15 @@ unsigned llvm::dwarf::getTag(StringRef T
       .Default(DW_TAG_invalid);
 }
 
-StringRef llvm::dwarf::ChildrenString(unsigned Children) {
+const char *llvm::dwarf::ChildrenString(unsigned Children) {
   switch (Children) {
   case DW_CHILDREN_no:                   return "DW_CHILDREN_no";
   case DW_CHILDREN_yes:                  return "DW_CHILDREN_yes";
   }
-  return StringRef();
+  return nullptr;
 }
 
-StringRef llvm::dwarf::AttributeString(unsigned Attribute) {
+const char *llvm::dwarf::AttributeString(unsigned Attribute) {
   switch (Attribute) {
   case DW_AT_sibling:                    return "DW_AT_sibling";
   case DW_AT_location:                   return "DW_AT_location";
@@ -222,10 +221,10 @@ StringRef llvm::dwarf::AttributeString(u
   case DW_AT_GNU_pubtypes:               return "DW_AT_GNU_pubtypes";
   case DW_AT_GNU_discriminator:          return "DW_AT_GNU_discriminator";
   }
-  return StringRef();
+  return nullptr;
 }
 
-StringRef llvm::dwarf::FormEncodingString(unsigned Encoding) {
+const char *llvm::dwarf::FormEncodingString(unsigned Encoding) {
   switch (Encoding) {
   case DW_FORM_addr:                     return "DW_FORM_addr";
   case DW_FORM_block2:                   return "DW_FORM_block2";
@@ -261,13 +260,12 @@ StringRef llvm::dwarf::FormEncodingStrin
   case DW_FORM_GNU_ref_alt:              return "DW_FORM_GNU_ref_alt";
   case DW_FORM_GNU_strp_alt:             return "DW_FORM_GNU_strp_alt";
   }
-  return StringRef();
+  return nullptr;
 }
 
-StringRef llvm::dwarf::OperationEncodingString(unsigned Encoding) {
+const char *llvm::dwarf::OperationEncodingString(unsigned Encoding) {
   switch (Encoding) {
-  default:
-    return StringRef();
+  default: return nullptr;
 #define HANDLE_DW_OP(ID, NAME)                                                 \
   case DW_OP_##NAME:                                                           \
     return "DW_OP_" #NAME;
@@ -282,10 +280,9 @@ unsigned llvm::dwarf::getOperationEncodi
       .Default(0);
 }
 
-StringRef llvm::dwarf::AttributeEncodingString(unsigned Encoding) {
+const char *llvm::dwarf::AttributeEncodingString(unsigned Encoding) {
   switch (Encoding) {
-  default:
-    return StringRef();
+  default: return nullptr;
 #define HANDLE_DW_ATE(ID, NAME)                                                \
   case DW_ATE_##NAME:                                                          \
     return "DW_ATE_" #NAME;
@@ -300,7 +297,7 @@ unsigned llvm::dwarf::getAttributeEncodi
       .Default(0);
 }
 
-StringRef llvm::dwarf::DecimalSignString(unsigned Sign) {
+const char *llvm::dwarf::DecimalSignString(unsigned Sign) {
   switch (Sign) {
   case DW_DS_unsigned:                   return "DW_DS_unsigned";
   case DW_DS_leading_overpunch:          return "DW_DS_leading_overpunch";
@@ -308,10 +305,10 @@ StringRef llvm::dwarf::DecimalSignString
   case DW_DS_leading_separate:           return "DW_DS_leading_separate";
   case DW_DS_trailing_separate:          return "DW_DS_trailing_separate";
   }
-  return StringRef();
+  return nullptr;
 }
 
-StringRef llvm::dwarf::EndianityString(unsigned Endian) {
+const char *llvm::dwarf::EndianityString(unsigned Endian) {
   switch (Endian) {
   case DW_END_default:                   return "DW_END_default";
   case DW_END_big:                       return "DW_END_big";
@@ -319,32 +316,32 @@ StringRef llvm::dwarf::EndianityString(u
   case DW_END_lo_user:                   return "DW_END_lo_user";
   case DW_END_hi_user:                   return "DW_END_hi_user";
   }
-  return StringRef();
+  return nullptr;
 }
 
-StringRef llvm::dwarf::AccessibilityString(unsigned Access) {
+const char *llvm::dwarf::AccessibilityString(unsigned Access) {
   switch (Access) {
   // Accessibility codes
   case DW_ACCESS_public:                 return "DW_ACCESS_public";
   case DW_ACCESS_protected:              return "DW_ACCESS_protected";
   case DW_ACCESS_private:                return "DW_ACCESS_private";
   }
-  return StringRef();
+  return nullptr;
 }
 
-StringRef llvm::dwarf::VisibilityString(unsigned Visibility) {
+const char *llvm::dwarf::VisibilityString(unsigned Visibility) {
   switch (Visibility) {
   case DW_VIS_local:                     return "DW_VIS_local";
   case DW_VIS_exported:                  return "DW_VIS_exported";
   case DW_VIS_qualified:                 return "DW_VIS_qualified";
   }
-  return StringRef();
+  return nullptr;
 }
 
-StringRef llvm::dwarf::VirtualityString(unsigned Virtuality) {
+const char *llvm::dwarf::VirtualityString(unsigned Virtuality) {
   switch (Virtuality) {
   default:
-    return StringRef();
+    return nullptr;
 #define HANDLE_DW_VIRTUALITY(ID, NAME)                                         \
   case DW_VIRTUALITY_##NAME:                                                   \
     return "DW_VIRTUALITY_" #NAME;
@@ -360,10 +357,10 @@ unsigned llvm::dwarf::getVirtuality(Stri
       .Default(DW_VIRTUALITY_invalid);
 }
 
-StringRef llvm::dwarf::LanguageString(unsigned Language) {
+const char *llvm::dwarf::LanguageString(unsigned Language) {
   switch (Language) {
   default:
-    return StringRef();
+    return nullptr;
 #define HANDLE_DW_LANG(ID, NAME)                                               \
   case DW_LANG_##NAME:                                                         \
     return "DW_LANG_" #NAME;
@@ -378,20 +375,20 @@ unsigned llvm::dwarf::getLanguage(String
       .Default(0);
 }
 
-StringRef llvm::dwarf::CaseString(unsigned Case) {
+const char *llvm::dwarf::CaseString(unsigned Case) {
   switch (Case) {
   case DW_ID_case_sensitive:             return "DW_ID_case_sensitive";
   case DW_ID_up_case:                    return "DW_ID_up_case";
   case DW_ID_down_case:                  return "DW_ID_down_case";
   case DW_ID_case_insensitive:           return "DW_ID_case_insensitive";
   }
-  return StringRef();
+  return nullptr;
 }
 
-StringRef llvm::dwarf::ConventionString(unsigned CC) {
+const char *llvm::dwarf::ConventionString(unsigned CC) {
   switch (CC) {
   default:
-    return StringRef();
+    return nullptr;
 #define HANDLE_DW_CC(ID, NAME)                                               \
   case DW_CC_##NAME:                                                         \
     return "DW_CC_" #NAME;
@@ -406,33 +403,33 @@ unsigned llvm::dwarf::getCallingConventi
       .Default(0);
 }
 
-StringRef llvm::dwarf::InlineCodeString(unsigned Code) {
+const char *llvm::dwarf::InlineCodeString(unsigned Code) {
   switch (Code) {
   case DW_INL_not_inlined:               return "DW_INL_not_inlined";
   case DW_INL_inlined:                   return "DW_INL_inlined";
   case DW_INL_declared_not_inlined:      return "DW_INL_declared_not_inlined";
   case DW_INL_declared_inlined:          return "DW_INL_declared_inlined";
   }
-  return StringRef();
+  return nullptr;
 }
 
-StringRef llvm::dwarf::ArrayOrderString(unsigned Order) {
+const char *llvm::dwarf::ArrayOrderString(unsigned Order) {
   switch (Order) {
   case DW_ORD_row_major:                 return "DW_ORD_row_major";
   case DW_ORD_col_major:                 return "DW_ORD_col_major";
   }
-  return StringRef();
+  return nullptr;
 }
 
-StringRef llvm::dwarf::DiscriminantString(unsigned Discriminant) {
+const char *llvm::dwarf::DiscriminantString(unsigned Discriminant) {
   switch (Discriminant) {
   case DW_DSC_label:                     return "DW_DSC_label";
   case DW_DSC_range:                     return "DW_DSC_range";
   }
-  return StringRef();
+  return nullptr;
 }
 
-StringRef llvm::dwarf::LNStandardString(unsigned Standard) {
+const char *llvm::dwarf::LNStandardString(unsigned Standard) {
   switch (Standard) {
   case DW_LNS_copy:                      return "DW_LNS_copy";
   case DW_LNS_advance_pc:                return "DW_LNS_advance_pc";
@@ -447,10 +444,10 @@ StringRef llvm::dwarf::LNStandardString(
   case DW_LNS_set_epilogue_begin:        return "DW_LNS_set_epilogue_begin";
   case DW_LNS_set_isa:                   return "DW_LNS_set_isa";
   }
-  return StringRef();
+  return nullptr;
 }
 
-StringRef llvm::dwarf::LNExtendedString(unsigned Encoding) {
+const char *llvm::dwarf::LNExtendedString(unsigned Encoding) {
   switch (Encoding) {
   // Line Number Extended Opcode Encodings
   case DW_LNE_end_sequence:              return "DW_LNE_end_sequence";
@@ -460,10 +457,10 @@ StringRef llvm::dwarf::LNExtendedString(
   case DW_LNE_lo_user:                   return "DW_LNE_lo_user";
   case DW_LNE_hi_user:                   return "DW_LNE_hi_user";
   }
-  return StringRef();
+  return nullptr;
 }
 
-StringRef llvm::dwarf::MacinfoString(unsigned Encoding) {
+const char *llvm::dwarf::MacinfoString(unsigned Encoding) {
   switch (Encoding) {
   // Macinfo Type Encodings
   case DW_MACINFO_define:                return "DW_MACINFO_define";
@@ -473,7 +470,7 @@ StringRef llvm::dwarf::MacinfoString(uns
   case DW_MACINFO_vendor_ext:            return "DW_MACINFO_vendor_ext";
   case DW_MACINFO_invalid:               return "DW_MACINFO_invalid";
   }
-  return StringRef();
+  return nullptr;
 }
 
 unsigned llvm::dwarf::getMacinfo(StringRef MacinfoString) {
@@ -486,7 +483,7 @@ unsigned llvm::dwarf::getMacinfo(StringR
       .Default(DW_MACINFO_invalid);
 }
 
-StringRef llvm::dwarf::CallFrameString(unsigned Encoding) {
+const char *llvm::dwarf::CallFrameString(unsigned Encoding) {
   switch (Encoding) {
   case DW_CFA_nop:                       return "DW_CFA_nop";
   case DW_CFA_advance_loc:               return "DW_CFA_advance_loc";
@@ -520,10 +517,10 @@ StringRef llvm::dwarf::CallFrameString(u
   case DW_CFA_lo_user:                   return "DW_CFA_lo_user";
   case DW_CFA_hi_user:                   return "DW_CFA_hi_user";
   }
-  return StringRef();
+  return nullptr;
 }
 
-StringRef llvm::dwarf::ApplePropertyString(unsigned Prop) {
+const char *llvm::dwarf::ApplePropertyString(unsigned Prop) {
   switch (Prop) {
   case DW_APPLE_PROPERTY_readonly:
     return "DW_APPLE_PROPERTY_readonly";
@@ -556,10 +553,10 @@ StringRef llvm::dwarf::ApplePropertyStri
   case DW_APPLE_PROPERTY_class:
     return "DW_APPLE_PROPERTY_class";
   }
-  return StringRef();
+  return nullptr;
 }
 
-StringRef llvm::dwarf::AtomTypeString(unsigned AT) {
+const char *llvm::dwarf::AtomTypeString(unsigned AT) {
   switch (AT) {
   case dwarf::DW_ATOM_null:
     return "DW_ATOM_null";
@@ -572,10 +569,10 @@ StringRef llvm::dwarf::AtomTypeString(un
   case DW_ATOM_type_flags:
     return "DW_ATOM_type_flags";
   }
-  return StringRef();
+  return nullptr;
 }
 
-StringRef llvm::dwarf::GDBIndexEntryKindString(GDBIndexEntryKind Kind) {
+const char *llvm::dwarf::GDBIndexEntryKindString(GDBIndexEntryKind Kind) {
   switch (Kind) {
   case GIEK_NONE:
     return "NONE";
@@ -597,8 +594,7 @@ StringRef llvm::dwarf::GDBIndexEntryKind
   llvm_unreachable("Unknown GDBIndexEntryKind value");
 }
 
-StringRef
-llvm::dwarf::GDBIndexEntryLinkageString(GDBIndexEntryLinkage Linkage) {
+const char *llvm::dwarf::GDBIndexEntryLinkageString(GDBIndexEntryLinkage Linkage) {
   switch (Linkage) {
   case GIEL_EXTERNAL:
     return "EXTERNAL";
@@ -608,7 +604,7 @@ llvm::dwarf::GDBIndexEntryLinkageString(
   llvm_unreachable("Unknown GDBIndexEntryLinkage value");
 }
 
-StringRef llvm::dwarf::AttributeValueString(uint16_t Attr, unsigned Val) {
+const char *llvm::dwarf::AttributeValueString(uint16_t Attr, unsigned Val) {
   switch (Attr) {
   case DW_AT_accessibility:
     return AccessibilityString(Val);
@@ -636,5 +632,5 @@ StringRef llvm::dwarf::AttributeValueStr
     return DiscriminantString(Val);
   }
 
-  return StringRef();
+  return nullptr;
 }

Modified: llvm/trunk/unittests/Support/DwarfTest.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/unittests/Support/DwarfTest.cpp?rev=283278&r1=283277&r2=283278&view=diff
==============================================================================
--- llvm/trunk/unittests/Support/DwarfTest.cpp (original)
+++ llvm/trunk/unittests/Support/DwarfTest.cpp Tue Oct  4 19:21:14 2016
@@ -17,13 +17,13 @@ namespace {
 
 TEST(DwarfTest, TagStringOnInvalid) {
   // This is invalid, so it shouldn't be stringified.
-  EXPECT_EQ(StringRef(), TagString(DW_TAG_invalid));
+  EXPECT_EQ(nullptr, TagString(DW_TAG_invalid));
 
   // These aren't really tags: they describe ranges within tags.  They
   // shouldn't be stringified either.
-  EXPECT_EQ(StringRef(), TagString(DW_TAG_lo_user));
-  EXPECT_EQ(StringRef(), TagString(DW_TAG_hi_user));
-  EXPECT_EQ(StringRef(), TagString(DW_TAG_user_base));
+  EXPECT_EQ(nullptr, TagString(DW_TAG_lo_user));
+  EXPECT_EQ(nullptr, TagString(DW_TAG_hi_user));
+  EXPECT_EQ(nullptr, TagString(DW_TAG_user_base));
 }
 
 TEST(DwarfTest, getTag) {
@@ -58,12 +58,12 @@ TEST(DwarfTest, getOperationEncoding) {
 
 TEST(DwarfTest, LanguageStringOnInvalid) {
   // This is invalid, so it shouldn't be stringified.
-  EXPECT_EQ(StringRef(), LanguageString(0));
+  EXPECT_EQ(nullptr, LanguageString(0));
 
   // These aren't really tags: they describe ranges within tags.  They
   // shouldn't be stringified either.
-  EXPECT_EQ(StringRef(), LanguageString(DW_LANG_lo_user));
-  EXPECT_EQ(StringRef(), LanguageString(DW_LANG_hi_user));
+  EXPECT_EQ(nullptr, LanguageString(DW_LANG_lo_user));
+  EXPECT_EQ(nullptr, LanguageString(DW_LANG_hi_user));
 }
 
 TEST(DwarfTest, getLanguage) {
@@ -85,12 +85,12 @@ TEST(DwarfTest, getLanguage) {
 
 TEST(DwarfTest, AttributeEncodingStringOnInvalid) {
   // This is invalid, so it shouldn't be stringified.
-  EXPECT_EQ(StringRef(), AttributeEncodingString(0));
+  EXPECT_EQ(nullptr, AttributeEncodingString(0));
 
   // These aren't really tags: they describe ranges within tags.  They
   // shouldn't be stringified either.
-  EXPECT_EQ(StringRef(), AttributeEncodingString(DW_ATE_lo_user));
-  EXPECT_EQ(StringRef(), AttributeEncodingString(DW_ATE_hi_user));
+  EXPECT_EQ(nullptr, AttributeEncodingString(DW_ATE_lo_user));
+  EXPECT_EQ(nullptr, AttributeEncodingString(DW_ATE_hi_user));
 }
 
 TEST(DwarfTest, getAttributeEncoding) {
@@ -122,8 +122,8 @@ TEST(DwarfTest, VirtualityString) {
             VirtualityString(DW_VIRTUALITY_max));
 
   // Invalid numbers shouldn't be stringified.
-  EXPECT_EQ(StringRef(), VirtualityString(DW_VIRTUALITY_max + 1));
-  EXPECT_EQ(StringRef(), VirtualityString(DW_VIRTUALITY_max + 77));
+  EXPECT_EQ(nullptr, VirtualityString(DW_VIRTUALITY_max + 1));
+  EXPECT_EQ(nullptr, VirtualityString(DW_VIRTUALITY_max + 77));
 }
 
 TEST(DwarfTest, getVirtuality) {




More information about the llvm-commits mailing list