clang-tools  7.0.0
FSProvider.h
Go to the documentation of this file.
1 //===--- FSProvider.h - VFS provider for ClangdServer ------------*- C++-*-===//
2 //
3 // The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 
10 #ifndef LLVM_CLANG_TOOLS_EXTRA_CLANGD_FSPROVIDER_H
11 #define LLVM_CLANG_TOOLS_EXTRA_CLANGD_FSPROVIDER_H
12 
13 #include "clang/Basic/VirtualFileSystem.h"
14 #include "llvm/ADT/IntrusiveRefCntPtr.h"
15 
16 namespace clang {
17 namespace clangd {
18 
19 // Wrapper for vfs::FileSystem for use in multithreaded programs like clangd.
20 // As FileSystem is not threadsafe, concurrent threads must each obtain one.
22 public:
23  virtual ~FileSystemProvider() = default;
24  /// Called by ClangdServer to obtain a vfs::FileSystem to be used for parsing.
25  /// Context::current() will be the context passed to the clang entrypoint,
26  /// such as addDocument(), and will also be propagated to result callbacks.
27  /// Embedders may use this to isolate filesystem accesses.
28  virtual IntrusiveRefCntPtr<vfs::FileSystem> getFileSystem() = 0;
29 };
30 
32 public:
33  // FIXME: returns the single real FS instance, which is not threadsafe.
34  IntrusiveRefCntPtr<vfs::FileSystem> getFileSystem() override {
35  return vfs::getRealFileSystem();
36  }
37 };
38 
39 } // namespace clangd
40 } // namespace clang
41 
42 #endif
virtual IntrusiveRefCntPtr< vfs::FileSystem > getFileSystem()=0
Called by ClangdServer to obtain a vfs::FileSystem to be used for parsing.
virtual ~FileSystemProvider()=default
IntrusiveRefCntPtr< vfs::FileSystem > getFileSystem() override
Called by ClangdServer to obtain a vfs::FileSystem to be used for parsing.
Definition: FSProvider.h:34
===– Representation.cpp - ClangDoc Representation --------—*- C++ -*-===//