mirror of
https://github.com/MaskRay/ccls.git
synced 2024-11-22 07:35:08 +00:00
Add namespace alias clang::vfs = llvm::vfs to adapt D52783
vfs::x should be written as llvm::vfs::x to work around a [namepace.udir] bug before GCC 8 when namespace alias is used
This commit is contained in:
parent
7b19c87485
commit
82deedf8c3
@ -72,20 +72,21 @@ lsTextEdit ToTextEdit(const clang::SourceManager &SM,
|
||||
}
|
||||
|
||||
struct PreambleStatCache {
|
||||
llvm::StringMap<ErrorOr<vfs::Status>> Cache;
|
||||
llvm::StringMap<ErrorOr<llvm::vfs::Status>> Cache;
|
||||
|
||||
void Update(Twine Path, ErrorOr<vfs::Status> S) {
|
||||
void Update(Twine Path, ErrorOr<llvm::vfs::Status> S) {
|
||||
Cache.try_emplace(Path.str(), std::move(S));
|
||||
}
|
||||
|
||||
IntrusiveRefCntPtr<vfs::FileSystem>
|
||||
Producer(IntrusiveRefCntPtr<vfs::FileSystem> FS) {
|
||||
struct VFS : vfs::ProxyFileSystem {
|
||||
IntrusiveRefCntPtr<llvm::vfs::FileSystem>
|
||||
Producer(IntrusiveRefCntPtr<llvm::vfs::FileSystem> FS) {
|
||||
struct VFS : llvm::vfs::ProxyFileSystem {
|
||||
PreambleStatCache &Cache;
|
||||
|
||||
VFS(IntrusiveRefCntPtr<vfs::FileSystem> FS, PreambleStatCache &Cache)
|
||||
VFS(IntrusiveRefCntPtr<llvm::vfs::FileSystem> FS,
|
||||
PreambleStatCache &Cache)
|
||||
: ProxyFileSystem(std::move(FS)), Cache(Cache) {}
|
||||
llvm::ErrorOr<std::unique_ptr<vfs::File>>
|
||||
llvm::ErrorOr<std::unique_ptr<llvm::vfs::File>>
|
||||
openFileForRead(const Twine &Path) override {
|
||||
auto File = getUnderlyingFS().openFileForRead(Path);
|
||||
if (!File || !*File)
|
||||
@ -93,7 +94,7 @@ struct PreambleStatCache {
|
||||
Cache.Update(Path, File->get()->status());
|
||||
return File;
|
||||
}
|
||||
llvm::ErrorOr<vfs::Status> status(const Twine &Path) override {
|
||||
llvm::ErrorOr<llvm::vfs::Status> status(const Twine &Path) override {
|
||||
auto S = getUnderlyingFS().status(Path);
|
||||
Cache.Update(Path, S);
|
||||
return S;
|
||||
@ -102,14 +103,14 @@ struct PreambleStatCache {
|
||||
return new VFS(std::move(FS), *this);
|
||||
}
|
||||
|
||||
IntrusiveRefCntPtr<vfs::FileSystem>
|
||||
Consumer(IntrusiveRefCntPtr<vfs::FileSystem> FS) {
|
||||
struct VFS : vfs::ProxyFileSystem {
|
||||
IntrusiveRefCntPtr<llvm::vfs::FileSystem>
|
||||
Consumer(IntrusiveRefCntPtr<llvm::vfs::FileSystem> FS) {
|
||||
struct VFS : llvm::vfs::ProxyFileSystem {
|
||||
const PreambleStatCache &Cache;
|
||||
VFS(IntrusiveRefCntPtr<vfs::FileSystem> FS,
|
||||
VFS(IntrusiveRefCntPtr<llvm::vfs::FileSystem> FS,
|
||||
const PreambleStatCache &Cache)
|
||||
: ProxyFileSystem(std::move(FS)), Cache(Cache) {}
|
||||
llvm::ErrorOr<vfs::Status> status(const Twine &Path) override {
|
||||
llvm::ErrorOr<llvm::vfs::Status> status(const Twine &Path) override {
|
||||
auto I = Cache.Cache.find(Path.str());
|
||||
if (I != Cache.Cache.end())
|
||||
return I->getValue();
|
||||
@ -259,7 +260,7 @@ public:
|
||||
|
||||
std::unique_ptr<CompilerInstance> BuildCompilerInstance(
|
||||
CompletionSession &session, std::unique_ptr<CompilerInvocation> CI,
|
||||
IntrusiveRefCntPtr<vfs::FileSystem> FS, DiagnosticConsumer &DC,
|
||||
IntrusiveRefCntPtr<llvm::vfs::FileSystem> FS, DiagnosticConsumer &DC,
|
||||
const PreambleData *preamble, const WorkingFiles::Snapshot &snapshot,
|
||||
std::vector<std::unique_ptr<llvm::MemoryBuffer>> &Bufs) {
|
||||
std::string main = ResolveIfRelative(
|
||||
@ -307,7 +308,7 @@ bool Parse(CompilerInstance &Clang) {
|
||||
}
|
||||
|
||||
void BuildPreamble(CompletionSession &session, CompilerInvocation &CI,
|
||||
IntrusiveRefCntPtr<vfs::FileSystem> FS,
|
||||
IntrusiveRefCntPtr<llvm::vfs::FileSystem> FS,
|
||||
const std::string &main,
|
||||
std::unique_ptr<PreambleStatCache> stat_cache) {
|
||||
std::shared_ptr<PreambleData> OldP = session.GetPreamble();
|
||||
@ -353,7 +354,8 @@ void *CompletionPreloadMain(void *manager_) {
|
||||
WorkingFiles::Snapshot snapshot =
|
||||
session->wfiles->AsSnapshot({StripFileType(session->file.filename)});
|
||||
auto stat_cache = std::make_unique<PreambleStatCache>();
|
||||
IntrusiveRefCntPtr<vfs::FileSystem> FS = stat_cache->Producer(session->FS);
|
||||
IntrusiveRefCntPtr<llvm::vfs::FileSystem> FS =
|
||||
stat_cache->Producer(session->FS);
|
||||
if (std::unique_ptr<CompilerInvocation> CI =
|
||||
BuildCompilerInvocation(args, FS))
|
||||
BuildPreamble(*session, *CI, FS, request.path, std::move(stat_cache));
|
||||
@ -391,7 +393,7 @@ void *CompletionMain(void *manager_) {
|
||||
std::shared_ptr<CompletionSession> session =
|
||||
manager->TryGetSession(path, false);
|
||||
std::shared_ptr<PreambleData> preamble = session->GetPreamble();
|
||||
IntrusiveRefCntPtr<vfs::FileSystem> FS =
|
||||
IntrusiveRefCntPtr<llvm::vfs::FileSystem> FS =
|
||||
preamble ? preamble->stat_cache->Consumer(session->FS) : session->FS;
|
||||
std::unique_ptr<CompilerInvocation> CI =
|
||||
BuildCompilerInvocation(session->file.args, FS);
|
||||
@ -471,7 +473,7 @@ void *DiagnosticMain(void *manager_) {
|
||||
std::shared_ptr<CompletionSession> session =
|
||||
manager->TryGetSession(path, false);
|
||||
std::shared_ptr<PreambleData> preamble = session->GetPreamble();
|
||||
IntrusiveRefCntPtr<vfs::FileSystem> FS =
|
||||
IntrusiveRefCntPtr<llvm::vfs::FileSystem> FS =
|
||||
preamble ? preamble->stat_cache->Consumer(session->FS) : session->FS;
|
||||
std::unique_ptr<CompilerInvocation> CI =
|
||||
BuildCompilerInvocation(session->file.args, FS);
|
||||
|
@ -51,8 +51,8 @@ struct CompletionSession
|
||||
bool inferred = false;
|
||||
|
||||
// TODO share
|
||||
llvm::IntrusiveRefCntPtr<clang::vfs::FileSystem> FS =
|
||||
clang::vfs::getRealFileSystem();
|
||||
llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem> FS =
|
||||
llvm::vfs::getRealFileSystem();
|
||||
std::shared_ptr<clang::PCHContainerOperations> PCH;
|
||||
|
||||
CompletionSession(const Project::Entry &file, WorkingFiles *wfiles,
|
||||
|
@ -71,7 +71,7 @@ Range FromTokenRange(const SourceManager &SM, const LangOptions &LangOpts,
|
||||
|
||||
std::unique_ptr<CompilerInvocation>
|
||||
BuildCompilerInvocation(std::vector<const char *> args,
|
||||
IntrusiveRefCntPtr<vfs::FileSystem> VFS) {
|
||||
IntrusiveRefCntPtr<llvm::vfs::FileSystem> VFS) {
|
||||
std::string save = "-resource-dir=" + g_config->clang.resourceDir;
|
||||
args.push_back(save.c_str());
|
||||
IntrusiveRefCntPtr<DiagnosticsEngine> Diags(
|
||||
|
@ -10,6 +10,13 @@
|
||||
#include <clang/Basic/SourceManager.h>
|
||||
#include <clang/Frontend/CompilerInstance.h>
|
||||
|
||||
#if LLVM_VERSION_MAJOR < 8
|
||||
// D52783 Lift VFS from clang to llvm
|
||||
namespace llvm {
|
||||
namespace vfs = clang::vfs;
|
||||
}
|
||||
#endif
|
||||
|
||||
std::string PathFromFileEntry(const clang::FileEntry &file);
|
||||
|
||||
Range FromCharSourceRange(const clang::SourceManager &SM,
|
||||
@ -27,6 +34,6 @@ Range FromTokenRange(const clang::SourceManager &SM,
|
||||
|
||||
std::unique_ptr<clang::CompilerInvocation>
|
||||
BuildCompilerInvocation(std::vector<const char *> args,
|
||||
llvm::IntrusiveRefCntPtr<clang::vfs::FileSystem> VFS);
|
||||
llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem> VFS);
|
||||
|
||||
const char *ClangBuiltinTypeName(int);
|
||||
|
@ -1211,7 +1211,7 @@ Index(CompletionManager *completion, WorkingFiles *wfiles, VFS *vfs,
|
||||
const std::vector<std::pair<std::string, std::string>> &remapped, bool &ok) {
|
||||
ok = true;
|
||||
auto PCH = std::make_shared<PCHContainerOperations>();
|
||||
llvm::IntrusiveRefCntPtr<vfs::FileSystem> FS = vfs::getRealFileSystem();
|
||||
llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem> FS = llvm::vfs::getRealFileSystem();
|
||||
std::shared_ptr<CompilerInvocation> CI = BuildCompilerInvocation(args, FS);
|
||||
// e.g. .s
|
||||
if (!CI)
|
||||
|
Loading…
Reference in New Issue
Block a user