diff --git a/lib/CodeGen/AsmPrinter/AsmPrinter.cpp b/lib/CodeGen/AsmPrinter/AsmPrinter.cpp index f04cbb07403..a1507a349d4 100644 --- a/lib/CodeGen/AsmPrinter/AsmPrinter.cpp +++ b/lib/CodeGen/AsmPrinter/AsmPrinter.cpp @@ -1684,7 +1684,7 @@ void AsmPrinter::emitRemarksSection(remarks::RemarkStreamer &RS) { std::string Buf; raw_string_ostream OS(Buf); std::unique_ptr MetaSerializer = - Filename ? RemarkSerializer.metaSerializer(OS, StringRef(*Filename)) + Filename ? RemarkSerializer.metaSerializer(OS, Filename->str()) : RemarkSerializer.metaSerializer(OS); MetaSerializer->emit(); diff --git a/lib/IR/ValueSymbolTable.cpp b/lib/IR/ValueSymbolTable.cpp index 6e5330ecc5f..cf85a571f9a 100644 --- a/lib/IR/ValueSymbolTable.cpp +++ b/lib/IR/ValueSymbolTable.cpp @@ -61,7 +61,7 @@ ValueName *ValueSymbolTable::makeUniqueName(Value *V, S << ++LastUnique; // Try insert the vmap entry with this suffix. - auto IterBool = vmap.insert(std::make_pair(UniqueName, V)); + auto IterBool = vmap.insert(std::make_pair(UniqueName.str(), V)); if (IterBool.second) return &*IterBool.first; } diff --git a/lib/LTO/LTOModule.cpp b/lib/LTO/LTOModule.cpp index 1119622578d..155790041a7 100644 --- a/lib/LTO/LTOModule.cpp +++ b/lib/LTO/LTOModule.cpp @@ -545,7 +545,8 @@ void LTOModule::addPotentialUndefinedSymbol(ModuleSymbolTable::Symbol Sym, name.c_str(); } - auto IterBool = _undefines.insert(std::make_pair(name, NameAndAttributes())); + auto IterBool = + _undefines.insert(std::make_pair(name.str(), NameAndAttributes())); // we already have the symbol if (!IterBool.second) @@ -582,7 +583,7 @@ void LTOModule::parseSymbols() { SymTab.printSymbolName(OS, Sym); Buffer.c_str(); } - StringRef Name(Buffer); + StringRef Name = Buffer; if (IsUndefined) addAsmGlobalSymbolUndef(Name); diff --git a/lib/MC/MCContext.cpp b/lib/MC/MCContext.cpp index 906588a1a16..af2546cb0a8 100644 --- a/lib/MC/MCContext.cpp +++ b/lib/MC/MCContext.cpp @@ -261,7 +261,7 @@ MCSymbol *MCContext::createSymbol(StringRef Name, bool AlwaysAddSuffix, NewName.resize(Name.size()); raw_svector_ostream(NewName) << NextUniqueID++; } - auto NameEntry = UsedNames.insert(std::make_pair(NewName, true)); + auto NameEntry = UsedNames.insert(std::make_pair(NewName.str(), true)); if (NameEntry.second || !NameEntry.first->second) { // Ok, we found a name. // Mark it as used for a non-section symbol. @@ -394,7 +394,7 @@ MCContext::createXCOFFSymbolImpl(const StringMapEntry *Name, else ValidName.append(InvalidName); - auto NameEntry = UsedNames.insert(std::make_pair(ValidName, true)); + auto NameEntry = UsedNames.insert(std::make_pair(ValidName.str(), true)); assert((NameEntry.second || !NameEntry.first->second) && "This name is used somewhere else."); // Mark the name as used for a non-section symbol. diff --git a/lib/Object/IRSymtab.cpp b/lib/Object/IRSymtab.cpp index 4ff73f9356c..70655d1a26b 100644 --- a/lib/Object/IRSymtab.cpp +++ b/lib/Object/IRSymtab.cpp @@ -230,7 +230,7 @@ Error Builder::addSymbol(const ModuleSymbolTable &Msymtab, raw_svector_ostream OS(Name); Msymtab.printSymbolName(OS, Msym); } - setStr(Sym.Name, Saver.save(StringRef(Name))); + setStr(Sym.Name, Saver.save(Name.str())); auto Flags = Msymtab.getSymbolFlags(Msym); if (Flags & object::BasicSymbolRef::SF_Undefined) diff --git a/lib/ProfileData/Coverage/CoverageMappingWriter.cpp b/lib/ProfileData/Coverage/CoverageMappingWriter.cpp index 6a9258fee5e..ceb2d7dcb5b 100644 --- a/lib/ProfileData/Coverage/CoverageMappingWriter.cpp +++ b/lib/ProfileData/Coverage/CoverageMappingWriter.cpp @@ -63,7 +63,7 @@ void CoverageFilenamesSectionWriter::write(raw_ostream &OS, bool Compress) { encodeULEB128(Filenames.size(), OS); encodeULEB128(FilenamesStr.size(), OS); encodeULEB128(doCompression ? CompressedStr.size() : 0U, OS); - OS << (doCompression ? StringRef(CompressedStr) : StringRef(FilenamesStr)); + OS << (doCompression ? CompressedStr.str() : StringRef(FilenamesStr)); } namespace { diff --git a/lib/Support/CommandLine.cpp b/lib/Support/CommandLine.cpp index 0cc82739798..8cf7d5b1e57 100644 --- a/lib/Support/CommandLine.cpp +++ b/lib/Support/CommandLine.cpp @@ -864,7 +864,7 @@ void cl::TokenizeGNUCommandLine(StringRef Src, StringSaver &Saver, // End the token if this is whitespace. if (isWhitespace(C)) { if (!Token.empty()) - NewArgv.push_back(Saver.save(StringRef(Token)).data()); + NewArgv.push_back(Saver.save(Token.str()).data()); // Mark the end of lines in response files. if (MarkEOLs && C == '\n') NewArgv.push_back(nullptr); @@ -878,7 +878,7 @@ void cl::TokenizeGNUCommandLine(StringRef Src, StringSaver &Saver, // Append the last token after hitting EOF with no whitespace. if (!Token.empty()) - NewArgv.push_back(Saver.save(StringRef(Token)).data()); + NewArgv.push_back(Saver.save(Token.str()).data()); } /// Backslashes are interpreted in a rather complicated way in the Windows-style diff --git a/lib/Support/Signals.cpp b/lib/Support/Signals.cpp index 5aa1a9efcf5..4e70eed28b8 100644 --- a/lib/Support/Signals.cpp +++ b/lib/Support/Signals.cpp @@ -165,8 +165,8 @@ static bool printSymbolizedStackTrace(StringRef Argv0, void **StackTrace, } } - Optional Redirects[] = {StringRef(InputFile), - StringRef(OutputFile), StringRef("")}; + Optional Redirects[] = {InputFile.str(), OutputFile.str(), + StringRef("")}; StringRef Args[] = {"llvm-symbolizer", "--functions=linkage", "--inlining", #ifdef _WIN32 // Pass --relative-address on Windows so that we don't diff --git a/lib/Support/VirtualFileSystem.cpp b/lib/Support/VirtualFileSystem.cpp index 3f6c434f772..15bb54e6181 100644 --- a/lib/Support/VirtualFileSystem.cpp +++ b/lib/Support/VirtualFileSystem.cpp @@ -1604,7 +1604,7 @@ private: } // Remove trailing slash(es), being careful not to remove the root path - StringRef Trimmed(Name); + StringRef Trimmed = Name; size_t RootPathLen = sys::path::root_path(Trimmed, path_style).size(); while (Trimmed.size() > RootPathLen && sys::path::is_separator(Trimmed.back(), path_style)) diff --git a/lib/Transforms/Scalar/MergeICmps.cpp b/lib/Transforms/Scalar/MergeICmps.cpp index 0327652ab92..283e9029571 100644 --- a/lib/Transforms/Scalar/MergeICmps.cpp +++ b/lib/Transforms/Scalar/MergeICmps.cpp @@ -596,7 +596,7 @@ private: append(BB->getName()); } } - return StringRef(Scratch); + return Scratch.str(); } }; } // namespace diff --git a/lib/Transforms/Utils/MemoryOpRemark.cpp b/lib/Transforms/Utils/MemoryOpRemark.cpp index 8836fe220ad..0f0b551f754 100644 --- a/lib/Transforms/Utils/MemoryOpRemark.cpp +++ b/lib/Transforms/Utils/MemoryOpRemark.cpp @@ -217,7 +217,7 @@ void MemoryOpRemark::visitIntrinsicCall(const IntrinsicInst &II) { } auto R = makeRemark(RemarkPass.data(), remarkName(RK_IntrinsicCall), &II); - visitCallee(StringRef(CallTo), /*KnownLibCall=*/true, *R); + visitCallee(CallTo.str(), /*KnownLibCall=*/true, *R); visitSizeOperand(II.getOperand(2), *R); auto *CIVolatile = dyn_cast(II.getOperand(3)); diff --git a/tools/llvm-exegesis/lib/Analysis.cpp b/tools/llvm-exegesis/lib/Analysis.cpp index 519b54512da..be360b9f6d7 100644 --- a/tools/llvm-exegesis/lib/Analysis.cpp +++ b/tools/llvm-exegesis/lib/Analysis.cpp @@ -116,7 +116,7 @@ void Analysis::writeSnippet(raw_ostream &OS, ArrayRef Bytes, raw_svector_ostream OSS(InstPrinterStr); InstPrinter_->printInst(&MI, 0, "", *SubtargetInfo_, OSS); Bytes = Bytes.drop_front(MISize); - Lines.emplace_back(StringRef(InstPrinterStr).trim()); + Lines.emplace_back(InstPrinterStr.str().trim()); } writeEscaped(OS, join(Lines, Separator)); } diff --git a/tools/llvm-readobj/COFFDumper.cpp b/tools/llvm-readobj/COFFDumper.cpp index 4647b24f8ba..96124cc0348 100644 --- a/tools/llvm-readobj/COFFDumper.cpp +++ b/tools/llvm-readobj/COFFDumper.cpp @@ -1874,7 +1874,7 @@ void COFFDumper::printResourceDirectoryTable( OS << ": (ID " << Entry.Identifier.ID << ")"; } } - Name = StringRef(IDStr); + Name = IDStr; ListScope ResourceType(W, Level.str() + Name.str()); if (Entry.Offset.isSubDir()) { W.printHex("Table Offset", Entry.Offset.value()); diff --git a/unittests/Bitstream/BitstreamWriterTest.cpp b/unittests/Bitstream/BitstreamWriterTest.cpp index 993c5aadee2..054948e7e8b 100644 --- a/unittests/Bitstream/BitstreamWriterTest.cpp +++ b/unittests/Bitstream/BitstreamWriterTest.cpp @@ -38,7 +38,7 @@ TEST(BitstreamWriterTest, emitBlobWithSize) { W.Emit('r', 8); W.Emit(0, 8); } - EXPECT_EQ(StringRef(Expected), Buffer); + EXPECT_EQ(Expected.str(), Buffer); } TEST(BitstreamWriterTest, emitBlobEmpty) { diff --git a/unittests/DebugInfo/DWARF/DWARFDieManualExtractTest.cpp b/unittests/DebugInfo/DWARF/DWARFDieManualExtractTest.cpp index 458f1db63c5..d41e0ffa501 100644 --- a/unittests/DebugInfo/DWARF/DWARFDieManualExtractTest.cpp +++ b/unittests/DebugInfo/DWARF/DWARFDieManualExtractTest.cpp @@ -72,7 +72,7 @@ TEST(DWARFDie, manualExtractDump) { "0x0000000b: DW_TAG_compile_unit", " DW_AT_name (\"/tmp/main.c\")", " DW_AT_language (DW_LANG_C)"}; - StringRef(Output).split(Strings, '\n', -1, false); + Output.str().split(Strings, '\n', -1, false); ASSERT_EQ(Strings.size(), NumOfLines); for (size_t I = 0; I < NumOfLines; ++I) EXPECT_EQ(ValidStrings[I], Strings[I]); diff --git a/unittests/Support/CommandLineTest.cpp b/unittests/Support/CommandLineTest.cpp index 57fae856acb..7d880464e26 100644 --- a/unittests/Support/CommandLineTest.cpp +++ b/unittests/Support/CommandLineTest.cpp @@ -1064,7 +1064,7 @@ TEST(CommandLineTest, ReadConfigFile) { llvm::SmallString<128> CurrDir; std::error_code EC = llvm::sys::fs::current_path(CurrDir); EXPECT_TRUE(!EC); - EXPECT_TRUE(StringRef(CurrDir) != TestDir.path()); + EXPECT_NE(CurrDir.str(), TestDir.path()); llvm::BumpPtrAllocator A; llvm::StringSaver Saver(A); diff --git a/unittests/Support/LockFileManagerTest.cpp b/unittests/Support/LockFileManagerTest.cpp index 0b5a0d982a8..552053d46e8 100644 --- a/unittests/Support/LockFileManagerTest.cpp +++ b/unittests/Support/LockFileManagerTest.cpp @@ -36,7 +36,7 @@ TEST(LockFileManagerTest, Basic) { } // Now that the lock is out of scope, the file should be gone. - EXPECT_FALSE(sys::fs::exists(StringRef(LockedFile))); + EXPECT_FALSE(sys::fs::exists(LockedFile.str())); } TEST(LockFileManagerTest, LinkLockExists) { @@ -52,7 +52,7 @@ TEST(LockFileManagerTest, LinkLockExists) { sys::path::append(TmpFileLock, "file.lock-000"); int FD; - std::error_code EC = sys::fs::openFileForWrite(StringRef(TmpFileLock), FD); + std::error_code EC = sys::fs::openFileForWrite(TmpFileLock.str(), FD); ASSERT_FALSE(EC); int Ret = close(FD); @@ -61,7 +61,7 @@ TEST(LockFileManagerTest, LinkLockExists) { EC = sys::fs::create_link(TmpFileLock.str(), FileLocK.str()); ASSERT_FALSE(EC); - EC = sys::fs::remove(StringRef(TmpFileLock)); + EC = sys::fs::remove(TmpFileLock.str()); ASSERT_FALSE(EC); { @@ -72,7 +72,7 @@ TEST(LockFileManagerTest, LinkLockExists) { } // Now that the lock is out of scope, the file should be gone. - EXPECT_FALSE(sys::fs::exists(StringRef(LockedFile))); + EXPECT_FALSE(sys::fs::exists(LockedFile.str())); }