Skip to content

Commit b7a66d0

Browse files
[llvm] Use SmallString::operator std::string (NFC)
1 parent c0396e1 commit b7a66d0

File tree

20 files changed

+25
-25
lines changed

20 files changed

+25
-25
lines changed

llvm/include/llvm/ADT/APFixedPoint.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,7 @@ class APFixedPoint {
235235
std::string toString() const {
236236
SmallString<40> S;
237237
toString(S);
238-
return std::string(S.str());
238+
return std::string(S);
239239
}
240240

241241
void print(raw_ostream &) const;

llvm/include/llvm/ADT/StringExtras.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -332,7 +332,7 @@ inline std::string toString(const APInt &I, unsigned Radix, bool Signed,
332332
bool formatAsCLiteral = false) {
333333
SmallString<40> S;
334334
I.toString(S, Radix, Signed, formatAsCLiteral);
335-
return std::string(S.str());
335+
return std::string(S);
336336
}
337337

338338
inline std::string toString(const APSInt &I, unsigned Radix) {

llvm/include/llvm/IR/ModuleSummaryIndex.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1715,7 +1715,7 @@ class ModuleSummaryIndex {
17151715
SmallString<256> NewName(Name);
17161716
NewName += ".llvm.";
17171717
NewName += Suffix;
1718-
return std::string(NewName.str());
1718+
return std::string(NewName);
17191719
}
17201720

17211721
/// Helper to obtain the unpromoted name for a global value (or the original

llvm/include/llvm/Object/MachO.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -826,7 +826,7 @@ class MachOObjectFile : public ObjectFile {
826826
Version = utostr(major) + "." + utostr(minor);
827827
if (update != 0)
828828
Version += "." + utostr(update);
829-
return std::string(std::string(Version.str()));
829+
return std::string(std::string(Version));
830830
}
831831

832832
/// If the input path is a .dSYM bundle (as created by the dsymutil tool),

llvm/include/llvm/TableGen/StringToOffsetTable.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ class StringToOffsetTable {
4545
// Escape the string.
4646
SmallString<256> Str;
4747
raw_svector_ostream(Str).write_escaped(AggregateString);
48-
AggregateString = std::string(Str.str());
48+
AggregateString = std::string(Str);
4949

5050
O << " \"";
5151
unsigned CharsPrinted = 0;

llvm/lib/DWARFLinker/Classic/DWARFLinker.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,7 @@ static void analyzeImportedModule(
218218
ReportWarning(Twine("Conflicting parseable interfaces for Swift Module ") +
219219
*Name + ": " + Entry + " and " + Path,
220220
DIE);
221-
Entry = std::string(ResolvedPath.str());
221+
Entry = std::string(ResolvedPath);
222222
}
223223

224224
/// The distinct types of work performed by the work loop in

llvm/lib/DWARFLinker/Parallel/DWARFLinkerCompileUnit.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -294,7 +294,7 @@ void CompileUnit::analyzeImportedModule(const DWARFDebugInfoEntry *DieEntry) {
294294
": " + Entry + " and " + Path + ".",
295295
&Die);
296296
}
297-
Entry = std::string(ResolvedPath.str());
297+
Entry = std::string(ResolvedPath);
298298
}
299299
}
300300

llvm/lib/DebugInfo/DWARF/DWARFDebugLine.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1456,7 +1456,7 @@ bool DWARFDebugLine::Prologue::getFileNameByIndex(
14561456

14571457
// sys::path::append skips empty strings.
14581458
sys::path::append(FilePath, Style, IncludeDir, FileName);
1459-
Result = std::string(FilePath.str());
1459+
Result = std::string(FilePath);
14601460
return true;
14611461
}
14621462

llvm/lib/DebugInfo/Symbolize/Symbolize.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -303,7 +303,7 @@ std::string getDarwinDWARFResourceForPath(const std::string &Path,
303303
}
304304
sys::path::append(ResourceName, "Contents", "Resources", "DWARF");
305305
sys::path::append(ResourceName, Basename);
306-
return std::string(ResourceName.str());
306+
return std::string(ResourceName);
307307
}
308308

309309
bool checkFileCRC(StringRef Path, uint32_t CRCHash) {

llvm/lib/ExecutionEngine/ExecutionEngine.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ std::string ExecutionEngine::getMangledName(const GlobalValue *GV) {
197197
: GV->getParent()->getDataLayout();
198198

199199
Mangler::getNameWithPrefix(FullName, GV->getName(), DL);
200-
return std::string(FullName.str());
200+
return std::string(FullName);
201201
}
202202

203203
void ExecutionEngine::addGlobalMapping(const GlobalValue *GV, void *Addr) {

llvm/lib/ExecutionEngine/Orc/TargetProcess/JITLoaderPerf.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -323,7 +323,7 @@ static Error InitDebuggingDir(PerfState &State) {
323323
return make_error<StringError>(std::move(ErrStr), inconvertibleErrorCode());
324324
}
325325

326-
State.JitPath = std::string(UniqueDebugDir.str());
326+
State.JitPath = std::string(UniqueDebugDir);
327327

328328
return Error::success();
329329
}

llvm/lib/LTO/LTO.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1573,7 +1573,7 @@ std::string lto::getThinLTOOutputFile(StringRef Path, StringRef OldPrefix,
15731573
llvm::errs() << "warning: could not create directory '" << ParentPath
15741574
<< "': " << EC.message() << '\n';
15751575
}
1576-
return std::string(NewPath.str());
1576+
return std::string(NewPath);
15771577
}
15781578

15791579
namespace {

llvm/lib/LTO/ThinLTOCodeGenerator.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -947,11 +947,11 @@ ThinLTOCodeGenerator::writeGeneratedObject(int count, StringRef CacheEntryPath,
947947
// Cache is enabled, hard-link the entry (or copy if hard-link fails).
948948
auto Err = sys::fs::create_hard_link(CacheEntryPath, OutputPath);
949949
if (!Err)
950-
return std::string(OutputPath.str());
950+
return std::string(OutputPath);
951951
// Hard linking failed, try to copy.
952952
Err = sys::fs::copy_file(CacheEntryPath, OutputPath);
953953
if (!Err)
954-
return std::string(OutputPath.str());
954+
return std::string(OutputPath);
955955
// Copy failed (could be because the CacheEntry was removed from the cache
956956
// in the meantime by another process), fall back and try to write down the
957957
// buffer to the output.
@@ -964,7 +964,7 @@ ThinLTOCodeGenerator::writeGeneratedObject(int count, StringRef CacheEntryPath,
964964
if (Err)
965965
report_fatal_error(Twine("Can't open output '") + OutputPath + "'\n");
966966
OS << OutputBuffer.getBuffer();
967-
return std::string(OutputPath.str());
967+
return std::string(OutputPath);
968968
}
969969

970970
// Main entry point for the ThinLTO processing

llvm/lib/LineEditor/LineEditor.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ std::string LineEditor::getDefaultHistoryPath(StringRef ProgName) {
2525
SmallString<32> Path;
2626
if (sys::path::home_directory(Path)) {
2727
sys::path::append(Path, "." + ProgName + "-history");
28-
return std::string(Path.str());
28+
return std::string(Path);
2929
}
3030
return std::string();
3131
}

llvm/lib/Object/Archive.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -567,7 +567,7 @@ Expected<std::string> Archive::Child::getFullName() const {
567567
SmallString<128> FullName = sys::path::parent_path(
568568
Parent->getMemoryBufferRef().getBufferIdentifier());
569569
sys::path::append(FullName, Name);
570-
return std::string(FullName.str());
570+
return std::string(FullName);
571571
}
572572

573573
Expected<StringRef> Archive::Child::getBuffer() const {

llvm/lib/ProfileData/GCOV.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -666,7 +666,7 @@ static std::string mangleCoveragePath(StringRef Filename, bool PreservePaths) {
666666

667667
if (S < I)
668668
Result.append(S, I);
669-
return std::string(Result.str());
669+
return std::string(Result);
670670
}
671671

672672
std::string Context::getCoveragePath(StringRef filename,

llvm/lib/ToolDrivers/llvm-lib/LibDriver.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ class LibOptTable : public opt::GenericOptTable {
6767
static std::string getDefaultOutputPath(const NewArchiveMember &FirstMember) {
6868
SmallString<128> Val = StringRef(FirstMember.Buf->getBufferIdentifier());
6969
sys::path::replace_extension(Val, ".lib");
70-
return std::string(Val.str());
70+
return std::string(Val);
7171
}
7272

7373
static std::vector<StringRef> getSearchPaths(opt::InputArgList *Args,

llvm/lib/Transforms/Instrumentation/GCOVProfiling.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -535,7 +535,7 @@ std::string GCOVProfiler::mangleName(const DICompileUnit *CU,
535535

536536
SmallString<128> Filename = GCovFile->getString();
537537
sys::path::replace_extension(Filename, Notes ? "gcno" : "gcda");
538-
return std::string(Filename.str());
538+
return std::string(Filename);
539539
}
540540
}
541541

@@ -546,7 +546,7 @@ std::string GCOVProfiler::mangleName(const DICompileUnit *CU,
546546
if (sys::fs::current_path(CurPath))
547547
return std::string(FName);
548548
sys::path::append(CurPath, FName);
549-
return std::string(CurPath.str());
549+
return std::string(CurPath);
550550
}
551551

552552
bool GCOVProfiler::runOnModule(

llvm/lib/Transforms/Utils/NameAnonGlobals.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ class ModuleHasher {
5454
Hasher.final(Hash);
5555
SmallString<32> Result;
5656
MD5::stringifyResult(Hash, Result);
57-
TheHash = std::string(Result.str());
57+
TheHash = std::string(Result);
5858
return TheHash;
5959
}
6060
};

llvm/lib/WindowsDriver/MSVCPaths.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -328,7 +328,7 @@ bool appendArchToWindowsSDKLibPath(int SDKMajor, SmallString<128> LibPath,
328328
}
329329
}
330330

331-
path = std::string(LibPath.str());
331+
path = std::string(LibPath);
332332
return true;
333333
}
334334

@@ -383,7 +383,7 @@ std::string getSubDirectoryPath(SubDirectoryType Type, ToolsetLayout VSLayout,
383383
sys::path::append(Path, "lib", SubdirName);
384384
break;
385385
}
386-
return std::string(Path.str());
386+
return std::string(Path);
387387
}
388388

389389
bool useUniversalCRT(ToolsetLayout VSLayout, const std::string &VCToolChainPath,
@@ -720,7 +720,7 @@ bool findVCToolChainViaRegistry(std::string &Path, ToolsetLayout &VSLayout) {
720720
SmallString<256> VCPath(StringRef(VSInstallPath.c_str(), pos));
721721
sys::path::append(VCPath, "VC");
722722

723-
Path = std::string(VCPath.str());
723+
Path = std::string(VCPath);
724724
VSLayout = ToolsetLayout::OlderVS;
725725
return true;
726726
}

0 commit comments

Comments
 (0)