]> granicus.if.org Git - clang/commitdiff
[Tooling] Get working directory properly without assuming real file system.
authorEric Liu <ioeric@google.com>
Thu, 12 Jul 2018 14:54:25 +0000 (14:54 +0000)
committerEric Liu <ioeric@google.com>
Thu, 12 Jul 2018 14:54:25 +0000 (14:54 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@336910 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Tooling/Tooling.cpp

index c22ad93c7606a5a3d005bbb0b9502e3aaeadf07c..a106154f4b28a4799ad0263a8f530363e04db5a3 100644 (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.