Skip to content

Commit 7e6482b

Browse files
[Support] Use SmallString::operator std::string (NFC)
1 parent 7f2408f commit 7e6482b

File tree

8 files changed

+17
-17
lines changed

8 files changed

+17
-17
lines changed

llvm/lib/Support/Caching.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -163,8 +163,8 @@ Expected<FileCache> llvm::localCache(const Twine &CacheNameRef,
163163
// This CacheStream will move the temporary file into the cache when done.
164164
return std::make_unique<CacheStream>(
165165
std::make_unique<raw_fd_ostream>(Temp->FD, /* ShouldClose */ false),
166-
AddBuffer, std::move(*Temp), std::string(EntryPath.str()),
167-
ModuleName.str(), Task);
166+
AddBuffer, std::move(*Temp), std::string(EntryPath), ModuleName.str(),
167+
Task);
168168
};
169169
};
170170
}

llvm/lib/Support/FileCollector.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ void FileCollector::PathCanonicalizer::updateWithRealPath(
7171
// cases? What if there is nothing on disk?
7272
if (sys::fs::real_path(Directory, RealPath))
7373
return;
74-
CachedDirs[Directory] = std::string(RealPath.str());
74+
CachedDirs[Directory] = std::string(RealPath);
7575
} else {
7676
RealPath = DirWithSymlink->second;
7777
}

llvm/lib/Support/GraphWriter.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ std::string llvm::createGraphFilename(const Twine &Name, int &FD) {
128128
}
129129

130130
errs() << "Writing '" << Filename << "'... ";
131-
return std::string(Filename.str());
131+
return std::string(Filename);
132132
}
133133

134134
// Execute the graph viewer. Return true if there were errors.

llvm/lib/Support/LockFileManager.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ LockFileManager::LockFileManager(StringRef FileName)
162162
this->FileName = FileName;
163163
if (std::error_code EC = sys::fs::make_absolute(this->FileName)) {
164164
std::string S("failed to obtain absolute path for ");
165-
S.append(std::string(this->FileName.str()));
165+
S.append(std::string(this->FileName));
166166
setError(EC, S);
167167
return;
168168
}
@@ -181,7 +181,7 @@ LockFileManager::LockFileManager(StringRef FileName)
181181
if (std::error_code EC = sys::fs::createUniqueFile(
182182
UniqueLockFileName, UniqueLockFileID, UniqueLockFileName)) {
183183
std::string S("failed to create unique file ");
184-
S.append(std::string(UniqueLockFileName.str()));
184+
S.append(std::string(UniqueLockFileName));
185185
setError(EC, S);
186186
return;
187187
}
@@ -202,7 +202,7 @@ LockFileManager::LockFileManager(StringRef FileName)
202202
// We failed to write out PID, so report the error, remove the
203203
// unique lock file, and fail.
204204
std::string S("failed to write to ");
205-
S.append(std::string(UniqueLockFileName.str()));
205+
S.append(std::string(UniqueLockFileName));
206206
setError(Out.error(), S);
207207
sys::fs::remove(UniqueLockFileName);
208208
return;
@@ -248,7 +248,7 @@ LockFileManager::LockFileManager(StringRef FileName)
248248
// ownership.
249249
if ((EC = sys::fs::remove(LockFileName))) {
250250
std::string S("failed to remove lockfile ");
251-
S.append(std::string(UniqueLockFileName.str()));
251+
S.append(std::string(UniqueLockFileName));
252252
setError(EC, S);
253253
return;
254254
}

llvm/lib/Support/Path.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1145,7 +1145,7 @@ void directory_entry::replace_filename(const Twine &Filename, file_type Type,
11451145
basic_file_status Status) {
11461146
SmallString<128> PathStr = path::parent_path(Path);
11471147
path::append(PathStr, Filename);
1148-
this->Path = std::string(PathStr.str());
1148+
this->Path = std::string(PathStr);
11491149
this->Type = Type;
11501150
this->Status = Status;
11511151
}

llvm/lib/Support/Process.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ Process::FindInEnvPath(StringRef EnvName, StringRef FileName,
5959
SmallString<128> FilePath(Dir);
6060
path::append(FilePath, FileName);
6161
if (fs::exists(Twine(FilePath))) {
62-
FoundPath = std::string(FilePath.str());
62+
FoundPath = std::string(FilePath);
6363
break;
6464
}
6565
}

llvm/lib/Support/Unix/Program.inc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ ErrorOr<std::string> sys::findProgramByName(StringRef Name,
9191
SmallString<128> FilePath(Path);
9292
sys::path::append(FilePath, Name);
9393
if (sys::fs::can_execute(FilePath.c_str()))
94-
return std::string(FilePath.str()); // Found the executable!
94+
return std::string(FilePath); // Found the executable!
9595
}
9696
return errc::no_such_file_or_directory;
9797
}

llvm/lib/Support/VirtualFileSystem.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -325,14 +325,14 @@ RealFileSystem::openFileForRead(const Twine &Name) {
325325

326326
llvm::ErrorOr<std::string> RealFileSystem::getCurrentWorkingDirectory() const {
327327
if (WD && *WD)
328-
return std::string(WD->get().Specified.str());
328+
return std::string(WD->get().Specified);
329329
if (WD)
330330
return WD->getError();
331331

332332
SmallString<128> Dir;
333333
if (std::error_code EC = llvm::sys::fs::current_path(Dir))
334334
return EC;
335-
return std::string(Dir.str());
335+
return std::string(Dir);
336336
}
337337

338338
std::error_code RealFileSystem::setCurrentWorkingDirectory(const Twine &Path) {
@@ -1091,7 +1091,7 @@ class InMemoryFileSystem::DirIterator : public llvm::vfs::detail::DirIterImpl {
10911091
}
10921092
break;
10931093
}
1094-
CurrentEntry = directory_entry(std::string(Path.str()), Type);
1094+
CurrentEntry = directory_entry(std::string(Path), Type);
10951095
} else {
10961096
// When we're at the end, make CurrentEntry invalid and DirIterImpl will
10971097
// do the rest.
@@ -1146,7 +1146,7 @@ std::error_code InMemoryFileSystem::setCurrentWorkingDirectory(const Twine &P) {
11461146
llvm::sys::path::remove_dots(Path, /*remove_dot_dot=*/true);
11471147

11481148
if (!Path.empty())
1149-
WorkingDirectory = std::string(Path.str());
1149+
WorkingDirectory = std::string(Path);
11501150
return {};
11511151
}
11521152

@@ -1252,7 +1252,7 @@ class llvm::vfs::RedirectingFSDirIterImpl
12521252
Type = sys::fs::file_type::regular_file;
12531253
break;
12541254
}
1255-
CurrentEntry = directory_entry(std::string(PathStr.str()), Type);
1255+
CurrentEntry = directory_entry(std::string(PathStr), Type);
12561256
} else {
12571257
CurrentEntry = directory_entry();
12581258
}
@@ -1328,7 +1328,7 @@ RedirectingFileSystem::setCurrentWorkingDirectory(const Twine &Path) {
13281328
Path.toVector(AbsolutePath);
13291329
if (std::error_code EC = makeAbsolute(AbsolutePath))
13301330
return EC;
1331-
WorkingDirectory = std::string(AbsolutePath.str());
1331+
WorkingDirectory = std::string(AbsolutePath);
13321332
return {};
13331333
}
13341334

0 commit comments

Comments
 (0)