[Reproducer] Use ::rtrim() to remove trailing control characters.

Pavel correctly pointed out that removing all control characters from
the working directory is overkill. It should be sufficient to just strip
the last ones.

llvm-svn: 375259
This commit is contained in:
Jonas Devlieghere
2019-10-18 17:11:48 +00:00
parent 7f704320b0
commit ded44e220f

View File

@@ -80,12 +80,10 @@ llvm::Error SystemInitializerCommon::Initialize() {
}
if (llvm::Expected<std::string> cwd =
loader->LoadBuffer<WorkingDirectoryProvider>()) {
cwd->erase(std::remove_if(cwd->begin(), cwd->end(),
[](char c) { return std::iscntrl(c); }),
cwd->end());
llvm::StringRef working_dir = llvm::StringRef(*cwd).rtrim();
if (std::error_code ec = FileSystem::Instance()
.GetVirtualFileSystem()
->setCurrentWorkingDirectory(*cwd)) {
->setCurrentWorkingDirectory(working_dir)) {
return llvm::errorCodeToError(ec);
}
} else {