clang-tools  11.0.0git
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_SUPPORT_FSPROVIDER_H
10 #define LLVM_CLANG_TOOLS_EXTRA_CLANGD_SUPPORT_FSPROVIDER_H
11 
12 #include "llvm/ADT/IntrusiveRefCntPtr.h"
13 #include "llvm/Support/VirtualFileSystem.h"
14 #include <memory>
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 llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem>
29  getFileSystem() const = 0;
30 };
31 
33 public:
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.