From a41b976a77f2130ef0e8470e2d0f5b8dba772a1e Mon Sep 17 00:00:00 2001 From: Fangrui Song Date: Tue, 26 Mar 2019 18:42:48 -0700 Subject: [PATCH] Adapt clang rC357037: removal of setVirtualFileSystem --- src/indexer.cc | 7 ++++++- src/sema_manager.cc | 6 +++++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/src/indexer.cc b/src/indexer.cc index 82674998..c96032f0 100644 --- a/src/indexer.cc +++ b/src/indexer.cc @@ -1251,12 +1251,17 @@ Index(SemaManager *manager, WorkingFiles *wfiles, VFS *vfs, DiagnosticConsumer DC; auto Clang = std::make_unique(PCH); Clang->setInvocation(std::move(CI)); - Clang->setVirtualFileSystem(FS); Clang->createDiagnostics(&DC, false); Clang->setTarget(TargetInfo::CreateTargetInfo( Clang->getDiagnostics(), Clang->getInvocation().TargetOpts)); if (!Clang->hasTarget()) return {}; +#if LLVM_VERSION_MAJOR >= 9 // rC357037 + Clang->createFileManager(FS); +#else + Clang->setVirtualFileSystem(FS); + Clang->createFileManager(); +#endif IndexParam param(*vfs, no_linkage); auto DataConsumer = std::make_shared(param); diff --git a/src/sema_manager.cc b/src/sema_manager.cc index d78b5e06..deb6b153 100644 --- a/src/sema_manager.cc +++ b/src/sema_manager.cc @@ -308,7 +308,6 @@ std::unique_ptr BuildCompilerInstance( auto Clang = std::make_unique(session.PCH); Clang->setInvocation(std::move(CI)); - Clang->setVirtualFileSystem(FS); Clang->createDiagnostics(&DC, false); Clang->setTarget(TargetInfo::CreateTargetInfo( Clang->getDiagnostics(), Clang->getInvocation().TargetOpts)); @@ -317,7 +316,12 @@ std::unique_ptr BuildCompilerInstance( // Construct SourceManager with UserFilesAreVolatile: true because otherwise // RequiresNullTerminator: true may cause out-of-bounds read when a file is // mmap'ed but is saved concurrently. +#if LLVM_VERSION_MAJOR >= 9 // rC357037 + Clang->createFileManager(FS); +#else + Clang->setVirtualFileSystem(FS); Clang->createFileManager(); +#endif Clang->setSourceManager(new SourceManager(Clang->getDiagnostics(), Clang->getFileManager(), true)); auto &IS = Clang->getFrontendOpts().Inputs;