mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-21 18:22:53 +01:00
PR51018: Remove explicit conversions from SmallString to StringRef to future-proof against C++23
C++23 will make these conversions ambiguous - so fix them to make the codebase forward-compatible with C++23 (& a follow-up change I've made will make this ambiguous/invalid even in <C++23 so we don't regress this & it generally improves the code anyway)
This commit is contained in:
parent
dec7ba68ad
commit
a9632b4cd8
@ -1684,7 +1684,7 @@ void AsmPrinter::emitRemarksSection(remarks::RemarkStreamer &RS) {
|
||||
std::string Buf;
|
||||
raw_string_ostream OS(Buf);
|
||||
std::unique_ptr<remarks::MetaSerializer> MetaSerializer =
|
||||
Filename ? RemarkSerializer.metaSerializer(OS, StringRef(*Filename))
|
||||
Filename ? RemarkSerializer.metaSerializer(OS, Filename->str())
|
||||
: RemarkSerializer.metaSerializer(OS);
|
||||
MetaSerializer->emit();
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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);
|
||||
|
@ -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<bool> *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.
|
||||
|
@ -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)
|
||||
|
@ -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 {
|
||||
|
@ -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
|
||||
|
@ -165,8 +165,8 @@ static bool printSymbolizedStackTrace(StringRef Argv0, void **StackTrace,
|
||||
}
|
||||
}
|
||||
|
||||
Optional<StringRef> Redirects[] = {StringRef(InputFile),
|
||||
StringRef(OutputFile), StringRef("")};
|
||||
Optional<StringRef> 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
|
||||
|
@ -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))
|
||||
|
@ -596,7 +596,7 @@ private:
|
||||
append(BB->getName());
|
||||
}
|
||||
}
|
||||
return StringRef(Scratch);
|
||||
return Scratch.str();
|
||||
}
|
||||
};
|
||||
} // namespace
|
||||
|
@ -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<ConstantInt>(II.getOperand(3));
|
||||
|
@ -116,7 +116,7 @@ void Analysis::writeSnippet(raw_ostream &OS, ArrayRef<uint8_t> 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<Tag>(OS, join(Lines, Separator));
|
||||
}
|
||||
|
@ -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());
|
||||
|
@ -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) {
|
||||
|
@ -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]);
|
||||
|
@ -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);
|
||||
|
@ -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()));
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user