mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-01-26 23:32:58 +00:00
Remove many superfluous SmallString::str() calls.
Now that SmallString is a first-class citizen, most SmallString::str() calls are not required. This patch removes a whole bunch of them, yet there are lots more. There are two use cases where str() is really needed: 1) To use one of StringRef member functions which is not available in SmallString. 2) To convert to std::string, as StringRef implicitly converts while SmallString do not. We may wish to change this, but it may introduce ambiguity. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@232622 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
f3f16aa1c9
commit
703b185464
@ -51,7 +51,7 @@ namespace llvm {
|
|||||||
~FileRemover() {
|
~FileRemover() {
|
||||||
if (DeleteIt) {
|
if (DeleteIt) {
|
||||||
// Ignore problems deleting the file.
|
// Ignore problems deleting the file.
|
||||||
sys::fs::remove(Filename.str());
|
sys::fs::remove(Filename);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -61,7 +61,7 @@ namespace llvm {
|
|||||||
void setFile(const Twine& filename, bool deleteIt = true) {
|
void setFile(const Twine& filename, bool deleteIt = true) {
|
||||||
if (DeleteIt) {
|
if (DeleteIt) {
|
||||||
// Ignore problems deleting the file.
|
// Ignore problems deleting the file.
|
||||||
sys::fs::remove(Filename.str());
|
sys::fs::remove(Filename);
|
||||||
}
|
}
|
||||||
|
|
||||||
Filename.clear();
|
Filename.clear();
|
||||||
|
@ -267,7 +267,7 @@ void MCAsmStreamer::EmitCommentsAndEOL() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
CommentStream.flush();
|
CommentStream.flush();
|
||||||
StringRef Comments = CommentToEmit.str();
|
StringRef Comments = CommentToEmit;
|
||||||
|
|
||||||
assert(Comments.back() == '\n' &&
|
assert(Comments.back() == '\n' &&
|
||||||
"Comment array not newline terminated");
|
"Comment array not newline terminated");
|
||||||
|
@ -789,7 +789,7 @@ static void writeFragment(const MCAssembler &Asm, const MCAsmLayout &Layout,
|
|||||||
|
|
||||||
case MCFragment::FT_LEB: {
|
case MCFragment::FT_LEB: {
|
||||||
const MCLEBFragment &LF = cast<MCLEBFragment>(F);
|
const MCLEBFragment &LF = cast<MCLEBFragment>(F);
|
||||||
OW->WriteBytes(LF.getContents().str());
|
OW->WriteBytes(LF.getContents());
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -805,12 +805,12 @@ static void writeFragment(const MCAssembler &Asm, const MCAsmLayout &Layout,
|
|||||||
|
|
||||||
case MCFragment::FT_Dwarf: {
|
case MCFragment::FT_Dwarf: {
|
||||||
const MCDwarfLineAddrFragment &OF = cast<MCDwarfLineAddrFragment>(F);
|
const MCDwarfLineAddrFragment &OF = cast<MCDwarfLineAddrFragment>(F);
|
||||||
OW->WriteBytes(OF.getContents().str());
|
OW->WriteBytes(OF.getContents());
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case MCFragment::FT_DwarfFrame: {
|
case MCFragment::FT_DwarfFrame: {
|
||||||
const MCDwarfCallFrameFragment &CF = cast<MCDwarfCallFrameFragment>(F);
|
const MCDwarfCallFrameFragment &CF = cast<MCDwarfCallFrameFragment>(F);
|
||||||
OW->WriteBytes(CF.getContents().str());
|
OW->WriteBytes(CF.getContents());
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1293,7 +1293,7 @@ const MCSymbol &FrameEmitterImpl::EmitCIE(MCObjectStreamer &streamer,
|
|||||||
Augmentation += "R";
|
Augmentation += "R";
|
||||||
if (IsSignalFrame)
|
if (IsSignalFrame)
|
||||||
Augmentation += "S";
|
Augmentation += "S";
|
||||||
streamer.EmitBytes(Augmentation.str());
|
streamer.EmitBytes(Augmentation);
|
||||||
}
|
}
|
||||||
streamer.EmitIntValue(0, 1);
|
streamer.EmitIntValue(0, 1);
|
||||||
|
|
||||||
|
@ -2297,7 +2297,7 @@ void APInt::dump() const {
|
|||||||
void APInt::print(raw_ostream &OS, bool isSigned) const {
|
void APInt::print(raw_ostream &OS, bool isSigned) const {
|
||||||
SmallString<40> S;
|
SmallString<40> S;
|
||||||
this->toString(S, 10, isSigned, /* formatAsCLiteral = */false);
|
this->toString(S, 10, isSigned, /* formatAsCLiteral = */false);
|
||||||
OS << S.str();
|
OS << S;
|
||||||
}
|
}
|
||||||
|
|
||||||
// This implements a variety of operations on a representation of
|
// This implements a variety of operations on a representation of
|
||||||
|
@ -91,7 +91,7 @@ LockFileManager::LockFileManager(StringRef FileName)
|
|||||||
UniqueLockFileName += "-%%%%%%%%";
|
UniqueLockFileName += "-%%%%%%%%";
|
||||||
int UniqueLockFileID;
|
int UniqueLockFileID;
|
||||||
if (std::error_code EC = sys::fs::createUniqueFile(
|
if (std::error_code EC = sys::fs::createUniqueFile(
|
||||||
UniqueLockFileName.str(), UniqueLockFileID, UniqueLockFileName)) {
|
UniqueLockFileName, UniqueLockFileID, UniqueLockFileName)) {
|
||||||
Error = EC;
|
Error = EC;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -116,7 +116,7 @@ LockFileManager::LockFileManager(StringRef FileName)
|
|||||||
// We failed to write out PID, so make up an excuse, remove the
|
// We failed to write out PID, so make up an excuse, remove the
|
||||||
// unique lock file, and fail.
|
// unique lock file, and fail.
|
||||||
Error = make_error_code(errc::no_space_on_device);
|
Error = make_error_code(errc::no_space_on_device);
|
||||||
sys::fs::remove(UniqueLockFileName.c_str());
|
sys::fs::remove(UniqueLockFileName);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -124,7 +124,7 @@ LockFileManager::LockFileManager(StringRef FileName)
|
|||||||
while (1) {
|
while (1) {
|
||||||
// Create a link from the lock file name. If this succeeds, we're done.
|
// Create a link from the lock file name. If this succeeds, we're done.
|
||||||
std::error_code EC =
|
std::error_code EC =
|
||||||
sys::fs::create_link(UniqueLockFileName.str(), LockFileName.str());
|
sys::fs::create_link(UniqueLockFileName, LockFileName);
|
||||||
if (!EC)
|
if (!EC)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@ -137,11 +137,11 @@ LockFileManager::LockFileManager(StringRef FileName)
|
|||||||
// from the lock file.
|
// from the lock file.
|
||||||
if ((Owner = readLockFile(LockFileName))) {
|
if ((Owner = readLockFile(LockFileName))) {
|
||||||
// Wipe out our unique lock file (it's useless now)
|
// Wipe out our unique lock file (it's useless now)
|
||||||
sys::fs::remove(UniqueLockFileName.str());
|
sys::fs::remove(UniqueLockFileName);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!sys::fs::exists(LockFileName.str())) {
|
if (!sys::fs::exists(LockFileName)) {
|
||||||
// The previous owner released the lock file before we could read it.
|
// The previous owner released the lock file before we could read it.
|
||||||
// Try to get ownership again.
|
// Try to get ownership again.
|
||||||
continue;
|
continue;
|
||||||
@ -149,7 +149,7 @@ LockFileManager::LockFileManager(StringRef FileName)
|
|||||||
|
|
||||||
// There is a lock file that nobody owns; try to clean it up and get
|
// There is a lock file that nobody owns; try to clean it up and get
|
||||||
// ownership.
|
// ownership.
|
||||||
if ((EC = sys::fs::remove(LockFileName.str()))) {
|
if ((EC = sys::fs::remove(LockFileName))) {
|
||||||
Error = EC;
|
Error = EC;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -171,8 +171,8 @@ LockFileManager::~LockFileManager() {
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
// Since we own the lock, remove the lock file and our own unique lock file.
|
// Since we own the lock, remove the lock file and our own unique lock file.
|
||||||
sys::fs::remove(LockFileName.str());
|
sys::fs::remove(LockFileName);
|
||||||
sys::fs::remove(UniqueLockFileName.str());
|
sys::fs::remove(UniqueLockFileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
LockFileManager::WaitForUnlockResult LockFileManager::waitForUnlock() {
|
LockFileManager::WaitForUnlockResult LockFileManager::waitForUnlock() {
|
||||||
@ -203,7 +203,7 @@ LockFileManager::WaitForUnlockResult LockFileManager::waitForUnlock() {
|
|||||||
if (sys::fs::access(LockFileName.c_str(), sys::fs::AccessMode::Exist) ==
|
if (sys::fs::access(LockFileName.c_str(), sys::fs::AccessMode::Exist) ==
|
||||||
errc::no_such_file_or_directory) {
|
errc::no_such_file_or_directory) {
|
||||||
// If the original file wasn't created, somone thought the lock was dead.
|
// If the original file wasn't created, somone thought the lock was dead.
|
||||||
if (!sys::fs::exists(FileName.str()))
|
if (!sys::fs::exists(FileName))
|
||||||
return Res_OwnerDied;
|
return Res_OwnerDied;
|
||||||
return Res_Success;
|
return Res_Success;
|
||||||
}
|
}
|
||||||
@ -236,5 +236,5 @@ LockFileManager::WaitForUnlockResult LockFileManager::waitForUnlock() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
std::error_code LockFileManager::unsafeRemoveLockFile() {
|
std::error_code LockFileManager::unsafeRemoveLockFile() {
|
||||||
return sys::fs::remove(LockFileName.str());
|
return sys::fs::remove(LockFileName);
|
||||||
}
|
}
|
||||||
|
@ -850,7 +850,7 @@ void Triple::setArchName(StringRef Str) {
|
|||||||
Triple += getVendorName();
|
Triple += getVendorName();
|
||||||
Triple += "-";
|
Triple += "-";
|
||||||
Triple += getOSAndEnvironmentName();
|
Triple += getOSAndEnvironmentName();
|
||||||
setTriple(Triple.str());
|
setTriple(Triple);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Triple::setVendorName(StringRef Str) {
|
void Triple::setVendorName(StringRef Str) {
|
||||||
|
@ -599,8 +599,8 @@ std::error_code detail::directory_iterator_construct(detail::DirIterState &it,
|
|||||||
|
|
||||||
it.IterationHandle = intptr_t(FindHandle.take());
|
it.IterationHandle = intptr_t(FindHandle.take());
|
||||||
SmallString<128> directory_entry_path(path);
|
SmallString<128> directory_entry_path(path);
|
||||||
path::append(directory_entry_path, directory_entry_name_utf8.str());
|
path::append(directory_entry_path, directory_entry_name_utf8);
|
||||||
it.CurrentEntry = directory_entry(directory_entry_path.str());
|
it.CurrentEntry = directory_entry(directory_entry_path);
|
||||||
|
|
||||||
return std::error_code();
|
return std::error_code();
|
||||||
}
|
}
|
||||||
|
@ -1091,7 +1091,7 @@ unsigned FilterChooser::getDecoderIndex(DecoderSet &Decoders,
|
|||||||
// overkill for now, though.
|
// overkill for now, though.
|
||||||
|
|
||||||
// Make sure the predicate is in the table.
|
// Make sure the predicate is in the table.
|
||||||
Decoders.insert(Decoder.str());
|
Decoders.insert(StringRef(Decoder));
|
||||||
// Now figure out the index for when we write out the table.
|
// Now figure out the index for when we write out the table.
|
||||||
DecoderSet::const_iterator P = std::find(Decoders.begin(),
|
DecoderSet::const_iterator P = std::find(Decoders.begin(),
|
||||||
Decoders.end(),
|
Decoders.end(),
|
||||||
|
Loading…
x
Reference in New Issue
Block a user