[Tooling] Get working directory properly without assuming real file system.

llvm-svn: 336910
This commit is contained in:
Eric Liu 2018-07-12 14:54:25 +00:00
parent 6316e0d322
commit 0fbeae7a2e
1 changed files with 7 additions and 3 deletions

View File

@ -411,10 +411,14 @@ int ClangTool::run(ToolAction *Action) {
// This just needs to be some symbol in the binary.
static int StaticSymbol;
llvm::SmallString<128> InitialDirectory;
if (std::error_code EC = llvm::sys::fs::current_path(InitialDirectory))
std::string InitialDirectory;
if (llvm::ErrorOr<std::string> CWD =
OverlayFileSystem->getCurrentWorkingDirectory()) {
InitialDirectory = std::move(*CWD);
} else {
llvm::report_fatal_error("Cannot detect current path: " +
Twine(EC.message()));
Twine(CWD.getError().message()));
}
// First insert all absolute paths into the in-memory VFS. These are global
// for all compile commands.