clang-tools  10.0.0svn
FSProvider.h
Go to the documentation of this file.
1 //===--- FSProvider.h - VFS provider for ClangdServer ------------*- C++-*-===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 
9 #ifndef LLVM_CLANG_TOOLS_EXTRA_CLANGD_FSPROVIDER_H
10 #define LLVM_CLANG_TOOLS_EXTRA_CLANGD_FSPROVIDER_H
11 
12 #include "llvm/ADT/IntrusiveRefCntPtr.h"
13 #include "llvm/Support/VirtualFileSystem.h"
14 
15 namespace clang {
16 namespace clangd {
17 
18 // Wrapper for vfs::FileSystem for use in multithreaded programs like clangd.
19 // As FileSystem is not threadsafe, concurrent threads must each obtain one.
21 public:
22  virtual ~FileSystemProvider() = default;
23  /// Called by ClangdServer to obtain a vfs::FileSystem to be used for parsing.
24  /// Context::current() will be the context passed to the clang entrypoint,
25  /// such as addDocument(), and will also be propagated to result callbacks.
26  /// Embedders may use this to isolate filesystem accesses.
27  virtual llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem>
28  getFileSystem() const = 0;
29 };
30 
32 public:
33  // FIXME: returns the single real FS instance, which is not threadsafe.
34  llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem>
35  getFileSystem() const override;
36 };
37 
38 } // namespace clangd
39 } // namespace clang
40 
41 #endif
virtual ~FileSystemProvider()=default
===– Representation.cpp - ClangDoc Representation --------—*- C++ -*-===//
virtual llvm::IntrusiveRefCntPtr< llvm::vfs::FileSystem > getFileSystem() const =0
Called by ClangdServer to obtain a vfs::FileSystem to be used for parsing.