From 1d0cf8aa79a6542390f7e2ecc74dff3f10970c2a Mon Sep 17 00:00:00 2001 From: Eric Liu Date: Thu, 12 Jul 2018 14:54:25 +0000 Subject: [PATCH] [Tooling] Get working directory properly without assuming real file system. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@336910 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Tooling/Tooling.cpp | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/lib/Tooling/Tooling.cpp b/lib/Tooling/Tooling.cpp index c22ad93c76..a106154f4b 100644 --- a/lib/Tooling/Tooling.cpp +++ b/lib/Tooling/Tooling.cpp @@ -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 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. -- 2.40.0