clang-tools 8.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 "llvm/ADT/IntrusiveRefCntPtr.h"
14 #include "llvm/Support/VirtualFileSystem.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.
21 class FileSystemProvider {
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
32 class RealFileSystemProvider : public FileSystemProvider {
33 public:
34 // FIXME: returns the single real FS instance, which is not threadsafe.
35 llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem>
36 getFileSystem() const override;
37 };
38
39 } // namespace clangd
40 } // namespace clang
41
42 #endif
clang::clangd::FileSystemProvider
Definition: FSProvider.h:21
clang::clangd::FileSystemProvider::~FileSystemProvider
virtual ~FileSystemProvider()=default
clang
===– Representation.cpp - ClangDoc Representation --------—*- C++ -*-===//
Definition: ChangeNamespace.cpp:18
clang::clangd::RealFileSystemProvider
Definition: FSProvider.h:32
clang::clangd::FileSystemProvider::getFileSystem
virtual llvm::IntrusiveRefCntPtr< llvm::vfs::FileSystem > getFileSystem() const =0
Called by ClangdServer to obtain a vfs::FileSystem to be used for parsing.