Make llvm::StringRef to std::string conversions explicit.

This is how it should've been and brings it more in line with
std::string_view. There should be no functional change here.

This is mostly mechanical from a custom clang-tidy check, with a lot of
manual fixups. It uncovers a lot of minor inefficiencies.

This doesn't actually modify StringRef yet, I'll do that in a follow-up.
diff --git a/llvm/tools/llvm-undname/llvm-undname.cpp b/llvm/tools/llvm-undname/llvm-undname.cpp
index aee9946..7c36825 100644
--- a/llvm/tools/llvm-undname/llvm-undname.cpp
+++ b/llvm/tools/llvm-undname/llvm-undname.cpp
@@ -87,7 +87,7 @@
                          << "\': " << EC.message() << '\n';
       return 1;
     }
-    return msDemangle(FileOrErr->get()->getBuffer()) ? 0 : 1;
+    return msDemangle(std::string(FileOrErr->get()->getBuffer())) ? 0 : 1;
   }
 
   bool Success = true;
@@ -111,7 +111,7 @@
         outs() << Line << "\n";
         outs().flush();
       }
-      if (!msDemangle(Line))
+      if (!msDemangle(std::string(Line)))
         Success = false;
       outs() << "\n";
     }
@@ -119,7 +119,7 @@
     for (StringRef S : Symbols) {
       outs() << S << "\n";
       outs().flush();
-      if (!msDemangle(S))
+      if (!msDemangle(std::string(S)))
         Success = false;
       outs() << "\n";
     }