Revert "Re-commit "Use StringRef in Support/Darf APIs (NFC)""

One test seems randomly broken: DebugInfo/X86/gnu-public-names.ll

llvm-svn: 283285
diff --git a/llvm/lib/DebugInfo/DWARF/DWARFAbbreviationDeclaration.cpp b/llvm/lib/DebugInfo/DWARF/DWARFAbbreviationDeclaration.cpp
index afae00e..9314c9e 100644
--- a/llvm/lib/DebugInfo/DWARF/DWARFAbbreviationDeclaration.cpp
+++ b/llvm/lib/DebugInfo/DWARF/DWARFAbbreviationDeclaration.cpp
@@ -62,23 +62,23 @@
 }
 
 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);
diff --git a/llvm/lib/DebugInfo/DWARF/DWARFAcceleratorTable.cpp b/llvm/lib/DebugInfo/DWARF/DWARFAcceleratorTable.cpp
index 9aa3a2b..8ae0543 100644
--- a/llvm/lib/DebugInfo/DWARF/DWARFAcceleratorTable.cpp
+++ b/llvm/lib/DebugInfo/DWARF/DWARFAcceleratorTable.cpp
@@ -61,14 +61,12 @@
   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);
diff --git a/llvm/lib/DebugInfo/DWARF/DWARFDebugFrame.cpp b/llvm/lib/DebugInfo/DWARF/DWARFDebugFrame.cpp
index 046559e..4253401 100644
--- a/llvm/lib/DebugInfo/DWARF/DWARFDebugFrame.cpp
+++ b/llvm/lib/DebugInfo/DWARF/DWARFDebugFrame.cpp
@@ -394,15 +394,13 @@
   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:
diff --git a/llvm/lib/DebugInfo/DWARF/DWARFDebugInfoEntry.cpp b/llvm/lib/DebugInfo/DWARF/DWARFDebugInfoEntry.cpp
index c43456b..62d5e66 100644
--- a/llvm/lib/DebugInfo/DWARF/DWARFDebugInfoEntry.cpp
+++ b/llvm/lib/DebugInfo/DWARF/DWARFDebugInfoEntry.cpp
@@ -45,12 +45,12 @@
 
     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 @@
     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 @@
   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 @@
     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 @@
              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();
diff --git a/llvm/lib/DebugInfo/DWARF/DWARFDebugLine.cpp b/llvm/lib/DebugInfo/DWARF/DWARFDebugLine.cpp
index 1635808..63d22d8 100644
--- a/llvm/lib/DebugInfo/DWARF/DWARFDebugLine.cpp
+++ b/llvm/lib/DebugInfo/DWARF/DWARFDebugLine.cpp
@@ -42,8 +42,8 @@
      << 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)