Revert "Convert a few std::strings to StringRef."

This reverts commit r212342.

We can get a StringRef into the current Record, but not one in the bitcode
itself since the string is compressed in it.

llvm-svn: 212356
diff --git a/llvm/lib/Bitcode/Reader/BitcodeReader.cpp b/llvm/lib/Bitcode/Reader/BitcodeReader.cpp
index 348234d..c02b587 100644
--- a/llvm/lib/Bitcode/Reader/BitcodeReader.cpp
+++ b/llvm/lib/Bitcode/Reader/BitcodeReader.cpp
@@ -71,15 +71,6 @@
   return false;
 }
 
-ErrorOr<StringRef> BitcodeReader::convertToStringRef(ArrayRef<uint64_t> Record,
-                                                     unsigned Idx) {
-  if (Idx > Record.size())
-    return Error(InvalidRecord);
-
-  return StringRef((char*)&Record[Idx], Record.size() - Idx);
-}
-
-
 static GlobalValue::LinkageTypes GetDecodedLinkage(unsigned Val) {
   switch (Val) {
   default: // Map unknown/new linkages to external
@@ -2125,13 +2116,13 @@
   }
 }
 
-ErrorOr<StringRef> BitcodeReader::parseModuleTriple() {
+ErrorOr<std::string> BitcodeReader::parseModuleTriple() {
   if (Stream.EnterSubBlock(bitc::MODULE_BLOCK_ID))
     return Error(InvalidRecord);
 
   SmallVector<uint64_t, 64> Record;
 
-  StringRef Triple;
+  std::string Triple;
   // Read all the records for this module.
   while (1) {
     BitstreamEntry Entry = Stream.advanceSkippingSubblocks();
@@ -2151,10 +2142,10 @@
     switch (Stream.readRecord(Entry.ID, Record)) {
     default: break;  // Default behavior, ignore unknown content.
     case bitc::MODULE_CODE_TRIPLE: {  // TRIPLE: [strchr x N]
-      ErrorOr<StringRef> S = convertToStringRef(Record, 0);
-      if (std::error_code EC = S.getError())
-        return EC;
-      Triple = S.get();
+      std::string S;
+      if (ConvertToString(Record, 0, S))
+        return Error(InvalidRecord);
+      Triple = S;
       break;
     }
     }
@@ -2163,7 +2154,7 @@
   return Triple;
 }
 
-ErrorOr<StringRef> BitcodeReader::parseTriple() {
+ErrorOr<std::string> BitcodeReader::parseTriple() {
   if (std::error_code EC = InitStream())
     return EC;
 
@@ -3478,10 +3469,10 @@
   return M;
 }
 
-StringRef llvm::getBitcodeTargetTriple(MemoryBuffer *Buffer,
-                                       LLVMContext &Context) {
+std::string llvm::getBitcodeTargetTriple(MemoryBuffer *Buffer,
+                                         LLVMContext &Context) {
   BitcodeReader *R = new BitcodeReader(Buffer, Context);
-  ErrorOr<StringRef> Triple = R->parseTriple();
+  ErrorOr<std::string> Triple = R->parseTriple();
   R->releaseBuffer();
   delete R;
   if (Triple.getError())