@@ -227,10 +227,11 @@ bool runToolOnCodeWithArgs(
227227 const Twine &ToolName,
228228 std::shared_ptr<PCHContainerOperations> PCHContainerOps,
229229 const FileContentMappings &VirtualMappedFiles) {
230- llvm::IntrusiveRefCntPtr<llvm::vfs::OverlayFileSystem> OverlayFileSystem (
231- new llvm::vfs::OverlayFileSystem (llvm::vfs::getRealFileSystem ()));
232- llvm::IntrusiveRefCntPtr<llvm::vfs::InMemoryFileSystem> InMemoryFileSystem (
233- new llvm::vfs::InMemoryFileSystem);
230+ auto OverlayFileSystem =
231+ llvm::makeIntrusiveRefCnt<llvm::vfs::OverlayFileSystem>(
232+ llvm::vfs::getRealFileSystem ());
233+ auto InMemoryFileSystem =
234+ llvm::makeIntrusiveRefCnt<llvm::vfs::InMemoryFileSystem>();
234235 OverlayFileSystem->pushOverlay (InMemoryFileSystem);
235236
236237 SmallString<1024 > CodeStorage;
@@ -403,7 +404,7 @@ bool ToolInvocation::run() {
403404 }
404405
405406 const std::unique_ptr<driver::Driver> Driver (
406- newDriver (&*Diagnostics, BinaryName, & Files->getVirtualFileSystem ()));
407+ newDriver (&*Diagnostics, BinaryName, Files->getVirtualFileSystemPtr ()));
407408 // The "input file not found" diagnostics from the driver are useful.
408409 // The driver is only aware of the VFS working directory, but some clients
409410 // change this at the FileManager level instead.
@@ -473,8 +474,10 @@ ClangTool::ClangTool(const CompilationDatabase &Compilations,
473474 IntrusiveRefCntPtr<FileManager> Files)
474475 : Compilations(Compilations), SourcePaths(SourcePaths),
475476 PCHContainerOps(std::move(PCHContainerOps)),
476- OverlayFileSystem(new llvm::vfs::OverlayFileSystem(std::move(BaseFS))),
477- InMemoryFileSystem(new llvm::vfs::InMemoryFileSystem),
477+ OverlayFileSystem(llvm::makeIntrusiveRefCnt<llvm::vfs::OverlayFileSystem>(
478+ std::move (BaseFS))),
479+ InMemoryFileSystem(
480+ llvm::makeIntrusiveRefCnt<llvm::vfs::InMemoryFileSystem>()),
478481 Files(Files ? Files
479482 : new FileManager(FileSystemOptions(), OverlayFileSystem)) {
480483 OverlayFileSystem->pushOverlay (InMemoryFileSystem);
@@ -692,10 +695,11 @@ std::unique_ptr<ASTUnit> buildASTFromCodeWithArgs(
692695 IntrusiveRefCntPtr<llvm::vfs::FileSystem> BaseFS) {
693696 std::vector<std::unique_ptr<ASTUnit>> ASTs;
694697 ASTBuilderAction Action (ASTs);
695- llvm::IntrusiveRefCntPtr<llvm::vfs::OverlayFileSystem> OverlayFileSystem (
696- new llvm::vfs::OverlayFileSystem (std::move (BaseFS)));
697- llvm::IntrusiveRefCntPtr<llvm::vfs::InMemoryFileSystem> InMemoryFileSystem (
698- new llvm::vfs::InMemoryFileSystem);
698+ auto OverlayFileSystem =
699+ llvm::makeIntrusiveRefCnt<llvm::vfs::OverlayFileSystem>(
700+ std::move (BaseFS));
701+ auto InMemoryFileSystem =
702+ llvm::makeIntrusiveRefCnt<llvm::vfs::InMemoryFileSystem>();
699703 OverlayFileSystem->pushOverlay (InMemoryFileSystem);
700704 llvm::IntrusiveRefCntPtr<FileManager> Files (
701705 new FileManager (FileSystemOptions (), OverlayFileSystem));
0 commit comments