mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-22 02:33:06 +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;
|
std::string Buf;
|
||||||
raw_string_ostream OS(Buf);
|
raw_string_ostream OS(Buf);
|
||||||
std::unique_ptr<remarks::MetaSerializer> MetaSerializer =
|
std::unique_ptr<remarks::MetaSerializer> MetaSerializer =
|
||||||
Filename ? RemarkSerializer.metaSerializer(OS, StringRef(*Filename))
|
Filename ? RemarkSerializer.metaSerializer(OS, Filename->str())
|
||||||
: RemarkSerializer.metaSerializer(OS);
|
: RemarkSerializer.metaSerializer(OS);
|
||||||
MetaSerializer->emit();
|
MetaSerializer->emit();
|
||||||
|
|
||||||
|
@ -61,7 +61,7 @@ ValueName *ValueSymbolTable::makeUniqueName(Value *V,
|
|||||||
S << ++LastUnique;
|
S << ++LastUnique;
|
||||||
|
|
||||||
// Try insert the vmap entry with this suffix.
|
// 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)
|
if (IterBool.second)
|
||||||
return &*IterBool.first;
|
return &*IterBool.first;
|
||||||
}
|
}
|
||||||
|
@ -545,7 +545,8 @@ void LTOModule::addPotentialUndefinedSymbol(ModuleSymbolTable::Symbol Sym,
|
|||||||
name.c_str();
|
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
|
// we already have the symbol
|
||||||
if (!IterBool.second)
|
if (!IterBool.second)
|
||||||
@ -582,7 +583,7 @@ void LTOModule::parseSymbols() {
|
|||||||
SymTab.printSymbolName(OS, Sym);
|
SymTab.printSymbolName(OS, Sym);
|
||||||
Buffer.c_str();
|
Buffer.c_str();
|
||||||
}
|
}
|
||||||
StringRef Name(Buffer);
|
StringRef Name = Buffer;
|
||||||
|
|
||||||
if (IsUndefined)
|
if (IsUndefined)
|
||||||
addAsmGlobalSymbolUndef(Name);
|
addAsmGlobalSymbolUndef(Name);
|
||||||
|
@ -261,7 +261,7 @@ MCSymbol *MCContext::createSymbol(StringRef Name, bool AlwaysAddSuffix,
|
|||||||
NewName.resize(Name.size());
|
NewName.resize(Name.size());
|
||||||
raw_svector_ostream(NewName) << NextUniqueID++;
|
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) {
|
if (NameEntry.second || !NameEntry.first->second) {
|
||||||
// Ok, we found a name.
|
// Ok, we found a name.
|
||||||
// Mark it as used for a non-section symbol.
|
// Mark it as used for a non-section symbol.
|
||||||
@ -394,7 +394,7 @@ MCContext::createXCOFFSymbolImpl(const StringMapEntry<bool> *Name,
|
|||||||
else
|
else
|
||||||
ValidName.append(InvalidName);
|
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) &&
|
assert((NameEntry.second || !NameEntry.first->second) &&
|
||||||
"This name is used somewhere else.");
|
"This name is used somewhere else.");
|
||||||
// Mark the name as used for a non-section symbol.
|
// 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);
|
raw_svector_ostream OS(Name);
|
||||||
Msymtab.printSymbolName(OS, Msym);
|
Msymtab.printSymbolName(OS, Msym);
|
||||||
}
|
}
|
||||||
setStr(Sym.Name, Saver.save(StringRef(Name)));
|
setStr(Sym.Name, Saver.save(Name.str()));
|
||||||
|
|
||||||
auto Flags = Msymtab.getSymbolFlags(Msym);
|
auto Flags = Msymtab.getSymbolFlags(Msym);
|
||||||
if (Flags & object::BasicSymbolRef::SF_Undefined)
|
if (Flags & object::BasicSymbolRef::SF_Undefined)
|
||||||
|
@ -63,7 +63,7 @@ void CoverageFilenamesSectionWriter::write(raw_ostream &OS, bool Compress) {
|
|||||||
encodeULEB128(Filenames.size(), OS);
|
encodeULEB128(Filenames.size(), OS);
|
||||||
encodeULEB128(FilenamesStr.size(), OS);
|
encodeULEB128(FilenamesStr.size(), OS);
|
||||||
encodeULEB128(doCompression ? CompressedStr.size() : 0U, OS);
|
encodeULEB128(doCompression ? CompressedStr.size() : 0U, OS);
|
||||||
OS << (doCompression ? StringRef(CompressedStr) : StringRef(FilenamesStr));
|
OS << (doCompression ? CompressedStr.str() : StringRef(FilenamesStr));
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
@ -864,7 +864,7 @@ void cl::TokenizeGNUCommandLine(StringRef Src, StringSaver &Saver,
|
|||||||
// End the token if this is whitespace.
|
// End the token if this is whitespace.
|
||||||
if (isWhitespace(C)) {
|
if (isWhitespace(C)) {
|
||||||
if (!Token.empty())
|
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.
|
// Mark the end of lines in response files.
|
||||||
if (MarkEOLs && C == '\n')
|
if (MarkEOLs && C == '\n')
|
||||||
NewArgv.push_back(nullptr);
|
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.
|
// Append the last token after hitting EOF with no whitespace.
|
||||||
if (!Token.empty())
|
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
|
/// 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),
|
Optional<StringRef> Redirects[] = {InputFile.str(), OutputFile.str(),
|
||||||
StringRef(OutputFile), StringRef("")};
|
StringRef("")};
|
||||||
StringRef Args[] = {"llvm-symbolizer", "--functions=linkage", "--inlining",
|
StringRef Args[] = {"llvm-symbolizer", "--functions=linkage", "--inlining",
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
// Pass --relative-address on Windows so that we don't
|
// 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
|
// 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();
|
size_t RootPathLen = sys::path::root_path(Trimmed, path_style).size();
|
||||||
while (Trimmed.size() > RootPathLen &&
|
while (Trimmed.size() > RootPathLen &&
|
||||||
sys::path::is_separator(Trimmed.back(), path_style))
|
sys::path::is_separator(Trimmed.back(), path_style))
|
||||||
|
@ -596,7 +596,7 @@ private:
|
|||||||
append(BB->getName());
|
append(BB->getName());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return StringRef(Scratch);
|
return Scratch.str();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
} // namespace
|
} // namespace
|
||||||
|
@ -217,7 +217,7 @@ void MemoryOpRemark::visitIntrinsicCall(const IntrinsicInst &II) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
auto R = makeRemark(RemarkPass.data(), remarkName(RK_IntrinsicCall), &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);
|
visitSizeOperand(II.getOperand(2), *R);
|
||||||
|
|
||||||
auto *CIVolatile = dyn_cast<ConstantInt>(II.getOperand(3));
|
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);
|
raw_svector_ostream OSS(InstPrinterStr);
|
||||||
InstPrinter_->printInst(&MI, 0, "", *SubtargetInfo_, OSS);
|
InstPrinter_->printInst(&MI, 0, "", *SubtargetInfo_, OSS);
|
||||||
Bytes = Bytes.drop_front(MISize);
|
Bytes = Bytes.drop_front(MISize);
|
||||||
Lines.emplace_back(StringRef(InstPrinterStr).trim());
|
Lines.emplace_back(InstPrinterStr.str().trim());
|
||||||
}
|
}
|
||||||
writeEscaped<Tag>(OS, join(Lines, Separator));
|
writeEscaped<Tag>(OS, join(Lines, Separator));
|
||||||
}
|
}
|
||||||
|
@ -1874,7 +1874,7 @@ void COFFDumper::printResourceDirectoryTable(
|
|||||||
OS << ": (ID " << Entry.Identifier.ID << ")";
|
OS << ": (ID " << Entry.Identifier.ID << ")";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Name = StringRef(IDStr);
|
Name = IDStr;
|
||||||
ListScope ResourceType(W, Level.str() + Name.str());
|
ListScope ResourceType(W, Level.str() + Name.str());
|
||||||
if (Entry.Offset.isSubDir()) {
|
if (Entry.Offset.isSubDir()) {
|
||||||
W.printHex("Table Offset", Entry.Offset.value());
|
W.printHex("Table Offset", Entry.Offset.value());
|
||||||
|
@ -38,7 +38,7 @@ TEST(BitstreamWriterTest, emitBlobWithSize) {
|
|||||||
W.Emit('r', 8);
|
W.Emit('r', 8);
|
||||||
W.Emit(0, 8);
|
W.Emit(0, 8);
|
||||||
}
|
}
|
||||||
EXPECT_EQ(StringRef(Expected), Buffer);
|
EXPECT_EQ(Expected.str(), Buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(BitstreamWriterTest, emitBlobEmpty) {
|
TEST(BitstreamWriterTest, emitBlobEmpty) {
|
||||||
|
@ -72,7 +72,7 @@ TEST(DWARFDie, manualExtractDump) {
|
|||||||
"0x0000000b: DW_TAG_compile_unit",
|
"0x0000000b: DW_TAG_compile_unit",
|
||||||
" DW_AT_name (\"/tmp/main.c\")",
|
" DW_AT_name (\"/tmp/main.c\")",
|
||||||
" DW_AT_language (DW_LANG_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);
|
ASSERT_EQ(Strings.size(), NumOfLines);
|
||||||
for (size_t I = 0; I < NumOfLines; ++I)
|
for (size_t I = 0; I < NumOfLines; ++I)
|
||||||
EXPECT_EQ(ValidStrings[I], Strings[I]);
|
EXPECT_EQ(ValidStrings[I], Strings[I]);
|
||||||
|
@ -1064,7 +1064,7 @@ TEST(CommandLineTest, ReadConfigFile) {
|
|||||||
llvm::SmallString<128> CurrDir;
|
llvm::SmallString<128> CurrDir;
|
||||||
std::error_code EC = llvm::sys::fs::current_path(CurrDir);
|
std::error_code EC = llvm::sys::fs::current_path(CurrDir);
|
||||||
EXPECT_TRUE(!EC);
|
EXPECT_TRUE(!EC);
|
||||||
EXPECT_TRUE(StringRef(CurrDir) != TestDir.path());
|
EXPECT_NE(CurrDir.str(), TestDir.path());
|
||||||
|
|
||||||
llvm::BumpPtrAllocator A;
|
llvm::BumpPtrAllocator A;
|
||||||
llvm::StringSaver Saver(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.
|
// 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) {
|
TEST(LockFileManagerTest, LinkLockExists) {
|
||||||
@ -52,7 +52,7 @@ TEST(LockFileManagerTest, LinkLockExists) {
|
|||||||
sys::path::append(TmpFileLock, "file.lock-000");
|
sys::path::append(TmpFileLock, "file.lock-000");
|
||||||
|
|
||||||
int FD;
|
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);
|
ASSERT_FALSE(EC);
|
||||||
|
|
||||||
int Ret = close(FD);
|
int Ret = close(FD);
|
||||||
@ -61,7 +61,7 @@ TEST(LockFileManagerTest, LinkLockExists) {
|
|||||||
EC = sys::fs::create_link(TmpFileLock.str(), FileLocK.str());
|
EC = sys::fs::create_link(TmpFileLock.str(), FileLocK.str());
|
||||||
ASSERT_FALSE(EC);
|
ASSERT_FALSE(EC);
|
||||||
|
|
||||||
EC = sys::fs::remove(StringRef(TmpFileLock));
|
EC = sys::fs::remove(TmpFileLock.str());
|
||||||
ASSERT_FALSE(EC);
|
ASSERT_FALSE(EC);
|
||||||
|
|
||||||
{
|
{
|
||||||
@ -72,7 +72,7 @@ TEST(LockFileManagerTest, LinkLockExists) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Now that the lock is out of scope, the file should be gone.
|
// 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