diff --git a/llvm/lib/Support/Caching.cpp b/llvm/lib/Support/Caching.cpp index 628e23e1cb3d..1ef51db218e8 100644 --- a/llvm/lib/Support/Caching.cpp +++ b/llvm/lib/Support/Caching.cpp @@ -163,8 +163,8 @@ Expected llvm::localCache(const Twine &CacheNameRef, // This CacheStream will move the temporary file into the cache when done. return std::make_unique( std::make_unique(Temp->FD, /* ShouldClose */ false), - AddBuffer, std::move(*Temp), std::string(EntryPath.str()), - ModuleName.str(), Task); + AddBuffer, std::move(*Temp), std::string(EntryPath), ModuleName.str(), + Task); }; }; } diff --git a/llvm/lib/Support/FileCollector.cpp b/llvm/lib/Support/FileCollector.cpp index c0ce6b5d74e8..92bcdf00b8a8 100644 --- a/llvm/lib/Support/FileCollector.cpp +++ b/llvm/lib/Support/FileCollector.cpp @@ -71,7 +71,7 @@ void FileCollector::PathCanonicalizer::updateWithRealPath( // cases? What if there is nothing on disk? if (sys::fs::real_path(Directory, RealPath)) return; - CachedDirs[Directory] = std::string(RealPath.str()); + CachedDirs[Directory] = std::string(RealPath); } else { RealPath = DirWithSymlink->second; } diff --git a/llvm/lib/Support/GraphWriter.cpp b/llvm/lib/Support/GraphWriter.cpp index 57559ad0830d..0c7aacb2fe21 100644 --- a/llvm/lib/Support/GraphWriter.cpp +++ b/llvm/lib/Support/GraphWriter.cpp @@ -128,7 +128,7 @@ std::string llvm::createGraphFilename(const Twine &Name, int &FD) { } errs() << "Writing '" << Filename << "'... "; - return std::string(Filename.str()); + return std::string(Filename); } // Execute the graph viewer. Return true if there were errors. diff --git a/llvm/lib/Support/LockFileManager.cpp b/llvm/lib/Support/LockFileManager.cpp index b64d48302775..a2b0fe8ca8f2 100644 --- a/llvm/lib/Support/LockFileManager.cpp +++ b/llvm/lib/Support/LockFileManager.cpp @@ -162,7 +162,7 @@ LockFileManager::LockFileManager(StringRef FileName) this->FileName = FileName; if (std::error_code EC = sys::fs::make_absolute(this->FileName)) { std::string S("failed to obtain absolute path for "); - S.append(std::string(this->FileName.str())); + S.append(std::string(this->FileName)); setError(EC, S); return; } @@ -181,7 +181,7 @@ LockFileManager::LockFileManager(StringRef FileName) if (std::error_code EC = sys::fs::createUniqueFile( UniqueLockFileName, UniqueLockFileID, UniqueLockFileName)) { std::string S("failed to create unique file "); - S.append(std::string(UniqueLockFileName.str())); + S.append(std::string(UniqueLockFileName)); setError(EC, S); return; } @@ -202,7 +202,7 @@ LockFileManager::LockFileManager(StringRef FileName) // We failed to write out PID, so report the error, remove the // unique lock file, and fail. std::string S("failed to write to "); - S.append(std::string(UniqueLockFileName.str())); + S.append(std::string(UniqueLockFileName)); setError(Out.error(), S); sys::fs::remove(UniqueLockFileName); return; @@ -248,7 +248,7 @@ LockFileManager::LockFileManager(StringRef FileName) // ownership. if ((EC = sys::fs::remove(LockFileName))) { std::string S("failed to remove lockfile "); - S.append(std::string(UniqueLockFileName.str())); + S.append(std::string(UniqueLockFileName)); setError(EC, S); return; } diff --git a/llvm/lib/Support/Path.cpp b/llvm/lib/Support/Path.cpp index c2456dcac097..9410252ba331 100644 --- a/llvm/lib/Support/Path.cpp +++ b/llvm/lib/Support/Path.cpp @@ -1145,7 +1145,7 @@ void directory_entry::replace_filename(const Twine &Filename, file_type Type, basic_file_status Status) { SmallString<128> PathStr = path::parent_path(Path); path::append(PathStr, Filename); - this->Path = std::string(PathStr.str()); + this->Path = std::string(PathStr); this->Type = Type; this->Status = Status; } diff --git a/llvm/lib/Support/Process.cpp b/llvm/lib/Support/Process.cpp index 30c64d3ed9ed..f81c13970d52 100644 --- a/llvm/lib/Support/Process.cpp +++ b/llvm/lib/Support/Process.cpp @@ -59,7 +59,7 @@ Process::FindInEnvPath(StringRef EnvName, StringRef FileName, SmallString<128> FilePath(Dir); path::append(FilePath, FileName); if (fs::exists(Twine(FilePath))) { - FoundPath = std::string(FilePath.str()); + FoundPath = std::string(FilePath); break; } } diff --git a/llvm/lib/Support/Unix/Program.inc b/llvm/lib/Support/Unix/Program.inc index 260719b2b58d..5d9757bcc51b 100644 --- a/llvm/lib/Support/Unix/Program.inc +++ b/llvm/lib/Support/Unix/Program.inc @@ -91,7 +91,7 @@ ErrorOr sys::findProgramByName(StringRef Name, SmallString<128> FilePath(Path); sys::path::append(FilePath, Name); if (sys::fs::can_execute(FilePath.c_str())) - return std::string(FilePath.str()); // Found the executable! + return std::string(FilePath); // Found the executable! } return errc::no_such_file_or_directory; } diff --git a/llvm/lib/Support/VirtualFileSystem.cpp b/llvm/lib/Support/VirtualFileSystem.cpp index 367e794d38f6..c43b70e239e0 100644 --- a/llvm/lib/Support/VirtualFileSystem.cpp +++ b/llvm/lib/Support/VirtualFileSystem.cpp @@ -325,14 +325,14 @@ RealFileSystem::openFileForRead(const Twine &Name) { llvm::ErrorOr RealFileSystem::getCurrentWorkingDirectory() const { if (WD && *WD) - return std::string(WD->get().Specified.str()); + return std::string(WD->get().Specified); if (WD) return WD->getError(); SmallString<128> Dir; if (std::error_code EC = llvm::sys::fs::current_path(Dir)) return EC; - return std::string(Dir.str()); + return std::string(Dir); } std::error_code RealFileSystem::setCurrentWorkingDirectory(const Twine &Path) { @@ -1091,7 +1091,7 @@ class InMemoryFileSystem::DirIterator : public llvm::vfs::detail::DirIterImpl { } break; } - CurrentEntry = directory_entry(std::string(Path.str()), Type); + CurrentEntry = directory_entry(std::string(Path), Type); } else { // When we're at the end, make CurrentEntry invalid and DirIterImpl will // do the rest. @@ -1146,7 +1146,7 @@ std::error_code InMemoryFileSystem::setCurrentWorkingDirectory(const Twine &P) { llvm::sys::path::remove_dots(Path, /*remove_dot_dot=*/true); if (!Path.empty()) - WorkingDirectory = std::string(Path.str()); + WorkingDirectory = std::string(Path); return {}; } @@ -1252,7 +1252,7 @@ class llvm::vfs::RedirectingFSDirIterImpl Type = sys::fs::file_type::regular_file; break; } - CurrentEntry = directory_entry(std::string(PathStr.str()), Type); + CurrentEntry = directory_entry(std::string(PathStr), Type); } else { CurrentEntry = directory_entry(); } @@ -1328,7 +1328,7 @@ RedirectingFileSystem::setCurrentWorkingDirectory(const Twine &Path) { Path.toVector(AbsolutePath); if (std::error_code EC = makeAbsolute(AbsolutePath)) return EC; - WorkingDirectory = std::string(AbsolutePath.str()); + WorkingDirectory = std::string(AbsolutePath); return {}; }