[clangd] Change FSProvider::getFileSystem to take CurrentWorkingDirectory

Summary:
We've faced a couple of problems when the returned FS didn't have the
proper working directory. New signature makes the API safer against such
problems.

Reviewers: sammccall

Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, usaxena95, cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D81920
diff --git a/clang-tools-extra/clangd/SourceCode.cpp b/clang-tools-extra/clangd/SourceCode.cpp
index c8502c5..1054791 100644
--- a/clang-tools-extra/clangd/SourceCode.cpp
+++ b/clang-tools-extra/clangd/SourceCode.cpp
@@ -12,6 +12,7 @@
 #include "Protocol.h"
 #include "refactor/Tweak.h"
 #include "support/Context.h"
+#include "support/FSProvider.h"
 #include "support/Logger.h"
 #include "clang/AST/ASTContext.h"
 #include "clang/Basic/LangOptions.h"
@@ -574,11 +575,12 @@
   return digest(Content);
 }
 
-format::FormatStyle getFormatStyleForFile(llvm::StringRef File,
-                                          llvm::StringRef Content,
-                                          llvm::vfs::FileSystem *FS) {
-  auto Style = format::getStyle(format::DefaultFormatStyle, File,
-                                format::DefaultFallbackStyle, Content, FS);
+format::FormatStyle
+getFormatStyleForFile(llvm::StringRef File, llvm::StringRef Content,
+                      const FileSystemProvider &FSProvider) {
+  auto Style = format::getStyle(
+      format::DefaultFormatStyle, File, format::DefaultFallbackStyle, Content,
+      FSProvider.getFileSystem(/*CWD=*/llvm::None).get());
   if (!Style) {
     log("getStyle() failed for file {0}: {1}. Fallback is LLVM style.", File,
         Style.takeError());