Skip to content

Commit

Permalink
Adapt clang rC357037: removal of setVirtualFileSystem
Browse files Browse the repository at this point in the history
  • Loading branch information
MaskRay committed May 13, 2019
1 parent 0846c12 commit a41b976
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
7 changes: 6 additions & 1 deletion src/indexer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1251,12 +1251,17 @@ Index(SemaManager *manager, WorkingFiles *wfiles, VFS *vfs,
DiagnosticConsumer DC;
auto Clang = std::make_unique<CompilerInstance>(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<IndexDataConsumer>(param);
Expand Down
6 changes: 5 additions & 1 deletion src/sema_manager.cc
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,6 @@ std::unique_ptr<CompilerInstance> BuildCompilerInstance(

auto Clang = std::make_unique<CompilerInstance>(session.PCH);
Clang->setInvocation(std::move(CI));
Clang->setVirtualFileSystem(FS);
Clang->createDiagnostics(&DC, false);
Clang->setTarget(TargetInfo::CreateTargetInfo(
Clang->getDiagnostics(), Clang->getInvocation().TargetOpts));
Expand All @@ -317,7 +316,12 @@ std::unique_ptr<CompilerInstance> 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;
Expand Down

0 comments on commit a41b976

Please sign in to comment.