Index: include/clang/Basic/FileManager.h =================================================================== --- include/clang/Basic/FileManager.h +++ include/clang/Basic/FileManager.h @@ -19,7 +19,6 @@ #include "clang/Basic/LLVM.h" #include "clang/Basic/VirtualFileSystem.h" #include "llvm/ADT/DenseMap.h" -#include "llvm/ADT/IntrusiveRefCntPtr.h" #include "llvm/ADT/SmallVector.h" #include "llvm/ADT/StringMap.h" #include "llvm/ADT/StringRef.h" @@ -113,7 +112,7 @@ /// as a single file. /// class FileManager : public RefCountedBase { - IntrusiveRefCntPtr FS; + std::shared_ptr FS; FileSystemOptions FileSystemOpts; /// \brief Cache for existing real directories. @@ -172,7 +171,7 @@ public: FileManager(const FileSystemOptions &FileSystemOpts, - IntrusiveRefCntPtr FS = nullptr); + std::shared_ptr FS = nullptr); ~FileManager(); /// \brief Installs the provided FileSystemStatCache object within @@ -221,7 +220,7 @@ FileSystemOptions &getFileSystemOpts() { return FileSystemOpts; } const FileSystemOptions &getFileSystemOpts() const { return FileSystemOpts; } - IntrusiveRefCntPtr getVirtualFileSystem() const { + std::shared_ptr getVirtualFileSystem() const { return FS; } Index: include/clang/Basic/VirtualFileSystem.h =================================================================== --- include/clang/Basic/VirtualFileSystem.h +++ include/clang/Basic/VirtualFileSystem.h @@ -14,7 +14,6 @@ #define LLVM_CLANG_BASIC_VIRTUALFILESYSTEM_H #include "clang/Basic/LLVM.h" -#include "llvm/ADT/IntrusiveRefCntPtr.h" #include "llvm/ADT/Optional.h" #include "llvm/Support/ErrorOr.h" #include "llvm/Support/FileSystem.h" @@ -179,7 +178,7 @@ }; /// \brief The virtual file system interface. -class FileSystem : public llvm::ThreadSafeRefCountedBase { +class FileSystem { public: virtual ~FileSystem(); @@ -225,7 +224,7 @@ /// \brief Gets an \p vfs::FileSystem for the 'real' file system, as seen by /// the operating system. -IntrusiveRefCntPtr getRealFileSystem(); +std::shared_ptr getRealFileSystem(); /// \brief A file system that allows overlaying one \p AbstractFileSystem on top /// of another. @@ -238,15 +237,15 @@ /// that exists in more than one file system, the file in the top-most file /// system overrides the other(s). class OverlayFileSystem : public FileSystem { - typedef SmallVector, 1> FileSystemList; + typedef SmallVector, 1> FileSystemList; /// \brief The stack of file systems, implemented as a list in order of /// their addition. FileSystemList FSList; public: - OverlayFileSystem(IntrusiveRefCntPtr Base); + OverlayFileSystem(std::shared_ptr Base); /// \brief Pushes a file system on top of the stack. - void pushOverlay(IntrusiveRefCntPtr FS); + void pushOverlay(std::shared_ptr FS); llvm::ErrorOr status(const Twine &Path) override; llvm::ErrorOr> @@ -307,11 +306,11 @@ /// \brief Gets a \p FileSystem for a virtual file system described in YAML /// format. -IntrusiveRefCntPtr +std::shared_ptr getVFSFromYAML(std::unique_ptr Buffer, llvm::SourceMgr::DiagHandlerTy DiagHandler, void *DiagContext = nullptr, - IntrusiveRefCntPtr ExternalFS = getRealFileSystem()); + std::shared_ptr ExternalFS = getRealFileSystem()); struct YAMLVFSEntry { template YAMLVFSEntry(T1 &&VPath, T2 &&RPath) Index: include/clang/Driver/Driver.h =================================================================== --- include/clang/Driver/Driver.h +++ include/clang/Driver/Driver.h @@ -67,7 +67,7 @@ DiagnosticsEngine &Diags; - IntrusiveRefCntPtr VFS; + std::shared_ptr VFS; enum DriverMode { GCCMode, @@ -221,7 +221,7 @@ public: Driver(StringRef ClangExecutable, StringRef DefaultTargetTriple, DiagnosticsEngine &Diags, - IntrusiveRefCntPtr VFS = nullptr); + std::shared_ptr VFS = nullptr); ~Driver(); /// @name Accessors Index: include/clang/Frontend/CompilerInstance.h =================================================================== --- include/clang/Frontend/CompilerInstance.h +++ include/clang/Frontend/CompilerInstance.h @@ -82,7 +82,7 @@ IntrusiveRefCntPtr AuxTarget; /// The virtual file system. - IntrusiveRefCntPtr VirtualFileSystem; + std::shared_ptr VirtualFileSystem; /// The file manager. IntrusiveRefCntPtr FileMgr; @@ -369,17 +369,17 @@ bool hasVirtualFileSystem() const { return VirtualFileSystem != nullptr; } - vfs::FileSystem &getVirtualFileSystem() const { + std::shared_ptr getVirtualFileSystem() const { assert(hasVirtualFileSystem() && "Compiler instance has no virtual file system"); - return *VirtualFileSystem; + return VirtualFileSystem; } /// \brief Replace the current virtual file system. /// /// \note Most clients should use setFileManager, which will implicitly reset /// the virtual file system to the one contained in the file manager. - void setVirtualFileSystem(IntrusiveRefCntPtr FS) { + void setVirtualFileSystem(std::shared_ptr FS) { VirtualFileSystem = FS; } Index: include/clang/Frontend/CompilerInvocation.h =================================================================== --- include/clang/Frontend/CompilerInvocation.h +++ include/clang/Frontend/CompilerInvocation.h @@ -210,7 +210,7 @@ class FileSystem; } -IntrusiveRefCntPtr +std::shared_ptr createVFSFromCompilerInvocation(const CompilerInvocation &CI, DiagnosticsEngine &Diags); Index: include/clang/Tooling/Tooling.h =================================================================== --- include/clang/Tooling/Tooling.h +++ include/clang/Tooling/Tooling.h @@ -332,8 +332,8 @@ std::vector SourcePaths; std::shared_ptr PCHContainerOps; - llvm::IntrusiveRefCntPtr OverlayFileSystem; - llvm::IntrusiveRefCntPtr InMemoryFileSystem; + std::shared_ptr OverlayFileSystem; + std::shared_ptr InMemoryFileSystem; llvm::IntrusiveRefCntPtr Files; // Contains a list of pairs (, ). std::vector< std::pair > MappedFileContents; Index: lib/Basic/FileManager.cpp =================================================================== --- lib/Basic/FileManager.cpp +++ lib/Basic/FileManager.cpp @@ -47,7 +47,7 @@ //===----------------------------------------------------------------------===// FileManager::FileManager(const FileSystemOptions &FSO, - IntrusiveRefCntPtr FS) + std::shared_ptr FS) : FS(FS), FileSystemOpts(FSO), SeenDirEntries(64), SeenFileEntries(64), NextFileUID(0) { NumDirLookups = NumFileLookups = 0; Index: lib/Basic/VirtualFileSystem.cpp =================================================================== --- lib/Basic/VirtualFileSystem.cpp +++ lib/Basic/VirtualFileSystem.cpp @@ -225,8 +225,8 @@ return std::error_code(); } -IntrusiveRefCntPtr vfs::getRealFileSystem() { - static IntrusiveRefCntPtr FS = new RealFileSystem(); +std::shared_ptr vfs::getRealFileSystem() { + static std::shared_ptr FS(new RealFileSystem()); return FS; } @@ -270,11 +270,11 @@ //===-----------------------------------------------------------------------===/ // OverlayFileSystem implementation //===-----------------------------------------------------------------------===/ -OverlayFileSystem::OverlayFileSystem(IntrusiveRefCntPtr BaseFS) { +OverlayFileSystem::OverlayFileSystem(std::shared_ptr BaseFS) { FSList.push_back(BaseFS); } -void OverlayFileSystem::pushOverlay(IntrusiveRefCntPtr FS) { +void OverlayFileSystem::pushOverlay(std::shared_ptr FS) { FSList.push_back(FS); // Synchronize added file systems by duplicating the working directory from // the first one in the list. @@ -814,7 +814,7 @@ /// The root(s) of the virtual file system. std::vector> Roots; /// \brief The file system to use for external references. - IntrusiveRefCntPtr ExternalFS; + std::shared_ptr ExternalFS; /// @name Configuration /// @{ @@ -832,7 +832,7 @@ friend class RedirectingFileSystemParser; private: - RedirectingFileSystem(IntrusiveRefCntPtr ExternalFS) + RedirectingFileSystem(std::shared_ptr ExternalFS) : ExternalFS(ExternalFS), CaseSensitive(true), UseExternalNames(true) {} /// \brief Looks up \p Path in \c Roots. @@ -852,7 +852,7 @@ static RedirectingFileSystem * create(std::unique_ptr Buffer, SourceMgr::DiagHandlerTy DiagHandler, void *DiagContext, - IntrusiveRefCntPtr ExternalFS); + std::shared_ptr ExternalFS); ErrorOr status(const Twine &Path) override; ErrorOr> openFileForRead(const Twine &Path) override; @@ -1207,7 +1207,7 @@ RedirectingFileSystem *RedirectingFileSystem::create( std::unique_ptr Buffer, SourceMgr::DiagHandlerTy DiagHandler, - void *DiagContext, IntrusiveRefCntPtr ExternalFS) { + void *DiagContext, std::shared_ptr ExternalFS) { SourceMgr SM; yaml::Stream Stream(Buffer->getMemBufferRef(), SM); @@ -1360,12 +1360,14 @@ llvm::make_unique(std::move(*Result), S)); } -IntrusiveRefCntPtr +std::shared_ptr vfs::getVFSFromYAML(std::unique_ptr Buffer, SourceMgr::DiagHandlerTy DiagHandler, void *DiagContext, - IntrusiveRefCntPtr ExternalFS) { - return RedirectingFileSystem::create(std::move(Buffer), DiagHandler, - DiagContext, ExternalFS); + std::shared_ptr ExternalFS) { + std::shared_ptr FS( + RedirectingFileSystem::create(std::move(Buffer), DiagHandler, + DiagContext, ExternalFS)); + return FS; } UniqueID vfs::getNextVirtualUniqueID() { Index: lib/Driver/Driver.cpp =================================================================== --- lib/Driver/Driver.cpp +++ lib/Driver/Driver.cpp @@ -48,7 +48,7 @@ Driver::Driver(StringRef ClangExecutable, StringRef DefaultTargetTriple, DiagnosticsEngine &Diags, - IntrusiveRefCntPtr VFS) + std::shared_ptr VFS) : Opts(createDriverOptTable()), Diags(Diags), VFS(VFS), Mode(GCCMode), SaveTemps(SaveTempsNone), LTOMode(LTOK_None), ClangExecutable(ClangExecutable), Index: lib/Format/Format.cpp =================================================================== --- lib/Format/Format.cpp +++ lib/Format/Format.cpp @@ -1897,7 +1897,7 @@ if (Style.DisableFormat) return tooling::Replacements(); - IntrusiveRefCntPtr InMemoryFileSystem( + std::shared_ptr InMemoryFileSystem( new vfs::InMemoryFileSystem); FileManager Files(FileSystemOptions(), InMemoryFileSystem); DiagnosticsEngine Diagnostics( Index: lib/Frontend/ASTUnit.cpp =================================================================== --- lib/Frontend/ASTUnit.cpp +++ lib/Frontend/ASTUnit.cpp @@ -670,7 +670,7 @@ AST->OnlyLocalDecls = OnlyLocalDecls; AST->CaptureDiagnostics = CaptureDiagnostics; AST->Diagnostics = Diags; - IntrusiveRefCntPtr VFS = vfs::getRealFileSystem(); + std::shared_ptr VFS = vfs::getRealFileSystem(); AST->FileMgr = new FileManager(FileSystemOpts, VFS); AST->UserFilesAreVolatile = UserFilesAreVolatile; AST->SourceMgr = new SourceManager(AST->getDiagnostics(), @@ -1550,7 +1550,7 @@ TopLevelDeclsInPreamble.clear(); PreambleDiagnostics.clear(); - IntrusiveRefCntPtr VFS = + std::shared_ptr VFS = createVFSFromCompilerInvocation(Clang->getInvocation(), getDiagnostics()); if (!VFS) return nullptr; @@ -1708,7 +1708,7 @@ AST->Diagnostics = Diags; AST->Invocation = CI; AST->FileSystemOpts = CI->getFileSystemOpts(); - IntrusiveRefCntPtr VFS = + std::shared_ptr VFS = createVFSFromCompilerInvocation(*CI, *Diags); if (!VFS) return nullptr; @@ -1979,7 +1979,7 @@ ConfigureDiags(Diags, *AST, CaptureDiagnostics); AST->Diagnostics = Diags; AST->FileSystemOpts = CI->getFileSystemOpts(); - IntrusiveRefCntPtr VFS = + std::shared_ptr VFS = createVFSFromCompilerInvocation(*CI, *Diags); if (!VFS) return nullptr; Index: lib/Frontend/CompilerInstance.cpp =================================================================== --- lib/Frontend/CompilerInstance.cpp +++ lib/Frontend/CompilerInstance.cpp @@ -953,7 +953,7 @@ ImportingInstance.getDiagnosticClient()), /*ShouldOwnClient=*/true); - Instance.setVirtualFileSystem(&ImportingInstance.getVirtualFileSystem()); + Instance.setVirtualFileSystem(ImportingInstance.getVirtualFileSystem()); // Note that this module is part of the module build stack, so that we // can detect cycles in the module graph. Index: lib/Frontend/CompilerInvocation.cpp =================================================================== --- lib/Frontend/CompilerInvocation.cpp +++ lib/Frontend/CompilerInvocation.cpp @@ -2289,13 +2289,13 @@ GraveYard[Idx] = Ptr; } -IntrusiveRefCntPtr +std::shared_ptr createVFSFromCompilerInvocation(const CompilerInvocation &CI, DiagnosticsEngine &Diags) { if (CI.getHeaderSearchOpts().VFSOverlayFiles.empty()) return vfs::getRealFileSystem(); - IntrusiveRefCntPtr + std::shared_ptr Overlay(new vfs::OverlayFileSystem(vfs::getRealFileSystem())); // earlier vfs files are on the bottom for (const std::string &File : CI.getHeaderSearchOpts().VFSOverlayFiles) { @@ -2303,14 +2303,14 @@ llvm::MemoryBuffer::getFile(File); if (!Buffer) { Diags.Report(diag::err_missing_vfs_overlay_file) << File; - return IntrusiveRefCntPtr(); + return std::shared_ptr(); } - IntrusiveRefCntPtr FS = + std::shared_ptr FS = vfs::getVFSFromYAML(std::move(Buffer.get()), /*DiagHandler*/ nullptr); if (!FS.get()) { Diags.Report(diag::err_invalid_vfs_overlay) << File; - return IntrusiveRefCntPtr(); + return std::shared_ptr(); } Overlay->pushOverlay(FS); } Index: lib/Frontend/FrontendAction.cpp =================================================================== --- lib/Frontend/FrontendAction.cpp +++ lib/Frontend/FrontendAction.cpp @@ -223,7 +223,7 @@ } if (!CI.hasVirtualFileSystem()) { - if (IntrusiveRefCntPtr VFS = + if (std::shared_ptr VFS = createVFSFromCompilerInvocation(CI.getInvocation(), CI.getDiagnostics())) CI.setVirtualFileSystem(VFS); Index: lib/Index/SimpleFormatContext.h =================================================================== --- lib/Index/SimpleFormatContext.h +++ lib/Index/SimpleFormatContext.h @@ -63,7 +63,7 @@ IntrusiveRefCntPtr DiagOpts; IntrusiveRefCntPtr Diagnostics; - IntrusiveRefCntPtr InMemoryFileSystem; + std::shared_ptr InMemoryFileSystem; FileManager Files; SourceManager Sources; Rewriter Rewrite; Index: lib/StaticAnalyzer/Frontend/ModelInjector.cpp =================================================================== --- lib/StaticAnalyzer/Frontend/ModelInjector.cpp +++ lib/StaticAnalyzer/Frontend/ModelInjector.cpp @@ -84,7 +84,7 @@ Instance.getDiagnostics().setSourceManager(&SM); - Instance.setVirtualFileSystem(&CI.getVirtualFileSystem()); + Instance.setVirtualFileSystem(CI.getVirtualFileSystem()); // The instance wants to take ownership, however DisableFree frontend option // is set to true to avoid double free issues Index: lib/Tooling/Core/Replacement.cpp =================================================================== --- lib/Tooling/Core/Replacement.cpp +++ lib/Tooling/Core/Replacement.cpp @@ -255,7 +255,7 @@ } std::string applyAllReplacements(StringRef Code, const Replacements &Replaces) { - IntrusiveRefCntPtr InMemoryFileSystem( + std::shared_ptr InMemoryFileSystem( new vfs::InMemoryFileSystem); FileManager Files(FileSystemOptions(), InMemoryFileSystem); DiagnosticsEngine Diagnostics( Index: lib/Tooling/Tooling.cpp =================================================================== --- lib/Tooling/Tooling.cpp +++ lib/Tooling/Tooling.cpp @@ -48,7 +48,7 @@ /// \brief Builds a clang driver initialized for running clang tools. static clang::driver::Driver *newDriver( clang::DiagnosticsEngine *Diagnostics, const char *BinaryName, - IntrusiveRefCntPtr VFS) { + std::shared_ptr VFS) { clang::driver::Driver *CompilerDriver = new clang::driver::Driver( BinaryName, llvm::sys::getDefaultTargetTriple(), *Diagnostics, VFS); CompilerDriver->setTitle("clang_based_tool"); @@ -125,9 +125,9 @@ SmallString<16> FileNameStorage; StringRef FileNameRef = FileName.toNullTerminatedStringRef(FileNameStorage); - llvm::IntrusiveRefCntPtr OverlayFileSystem( + std::shared_ptr OverlayFileSystem( new vfs::OverlayFileSystem(vfs::getRealFileSystem())); - llvm::IntrusiveRefCntPtr InMemoryFileSystem( + std::shared_ptr InMemoryFileSystem( new vfs::InMemoryFileSystem); OverlayFileSystem->pushOverlay(InMemoryFileSystem); llvm::IntrusiveRefCntPtr Files( @@ -482,9 +482,9 @@ std::vector> ASTs; ASTBuilderAction Action(ASTs); - llvm::IntrusiveRefCntPtr OverlayFileSystem( + std::shared_ptr OverlayFileSystem( new vfs::OverlayFileSystem(vfs::getRealFileSystem())); - llvm::IntrusiveRefCntPtr InMemoryFileSystem( + std::shared_ptr InMemoryFileSystem( new vfs::InMemoryFileSystem); OverlayFileSystem->pushOverlay(InMemoryFileSystem); llvm::IntrusiveRefCntPtr Files( Index: tools/clang-format/ClangFormat.cpp =================================================================== --- tools/clang-format/ClangFormat.cpp +++ tools/clang-format/ClangFormat.cpp @@ -129,7 +129,7 @@ static bool fillRanges(MemoryBuffer *Code, std::vector &Ranges) { - IntrusiveRefCntPtr InMemoryFileSystem( + std::shared_ptr InMemoryFileSystem( new vfs::InMemoryFileSystem); FileManager Files(FileSystemOptions(), InMemoryFileSystem); DiagnosticsEngine Diagnostics( @@ -278,7 +278,7 @@ outputReplacementsXML(Replaces); outs() << "\n"; } else { - IntrusiveRefCntPtr InMemoryFileSystem( + std::shared_ptr InMemoryFileSystem( new vfs::InMemoryFileSystem); FileManager Files(FileSystemOptions(), InMemoryFileSystem); DiagnosticsEngine Diagnostics( Index: unittests/Basic/VirtualFileSystemTest.cpp =================================================================== --- unittests/Basic/VirtualFileSystemTest.cpp +++ unittests/Basic/VirtualFileSystemTest.cpp @@ -134,7 +134,7 @@ } // end anonymous namespace TEST(VirtualFileSystemTest, StatusQueries) { - IntrusiveRefCntPtr D(new DummyFileSystem()); + std::shared_ptr D(new DummyFileSystem()); ErrorOr Status((std::error_code())); D->addRegularFile("/foo"); @@ -174,11 +174,11 @@ } TEST(VirtualFileSystemTest, BaseOnlyOverlay) { - IntrusiveRefCntPtr D(new DummyFileSystem()); + std::shared_ptr D(new DummyFileSystem()); ErrorOr Status((std::error_code())); EXPECT_FALSE(Status = D->status("/foo")); - IntrusiveRefCntPtr O(new vfs::OverlayFileSystem(D)); + std::shared_ptr O(new vfs::OverlayFileSystem(D)); EXPECT_FALSE(Status = O->status("/foo")); D->addRegularFile("/foo"); @@ -192,10 +192,10 @@ } TEST(VirtualFileSystemTest, OverlayFiles) { - IntrusiveRefCntPtr Base(new DummyFileSystem()); - IntrusiveRefCntPtr Middle(new DummyFileSystem()); - IntrusiveRefCntPtr Top(new DummyFileSystem()); - IntrusiveRefCntPtr O( + std::shared_ptr Base(new DummyFileSystem()); + std::shared_ptr Middle(new DummyFileSystem()); + std::shared_ptr Top(new DummyFileSystem()); + std::shared_ptr O( new vfs::OverlayFileSystem(Base)); O->pushOverlay(Middle); O->pushOverlay(Top); @@ -231,9 +231,9 @@ } TEST(VirtualFileSystemTest, OverlayDirsNonMerged) { - IntrusiveRefCntPtr Lower(new DummyFileSystem()); - IntrusiveRefCntPtr Upper(new DummyFileSystem()); - IntrusiveRefCntPtr O( + std::shared_ptr Lower(new DummyFileSystem()); + std::shared_ptr Upper(new DummyFileSystem()); + std::shared_ptr O( new vfs::OverlayFileSystem(Lower)); O->pushOverlay(Upper); @@ -256,9 +256,9 @@ TEST(VirtualFileSystemTest, MergedDirPermissions) { // merged directories get the permissions of the upper dir - IntrusiveRefCntPtr Lower(new DummyFileSystem()); - IntrusiveRefCntPtr Upper(new DummyFileSystem()); - IntrusiveRefCntPtr O( + std::shared_ptr Lower(new DummyFileSystem()); + std::shared_ptr Upper(new DummyFileSystem()); + std::shared_ptr O( new vfs::OverlayFileSystem(Lower)); O->pushOverlay(Upper); @@ -305,7 +305,7 @@ TEST(VirtualFileSystemTest, BasicRealFSIteration) { ScopedDir TestDirectory("virtual-file-system-test", /*Unique*/true); - IntrusiveRefCntPtr FS = vfs::getRealFileSystem(); + std::shared_ptr FS = vfs::getRealFileSystem(); std::error_code EC; vfs::directory_iterator I = FS->dir_begin(Twine(TestDirectory), EC); @@ -332,7 +332,7 @@ TEST(VirtualFileSystemTest, BasicRealFSRecursiveIteration) { ScopedDir TestDirectory("virtual-file-system-test", /*Unique*/true); - IntrusiveRefCntPtr FS = vfs::getRealFileSystem(); + std::shared_ptr FS = vfs::getRealFileSystem(); std::error_code EC; auto I = vfs::recursive_directory_iterator(*FS, Twine(TestDirectory), EC); @@ -384,9 +384,9 @@ } TEST(VirtualFileSystemTest, OverlayIteration) { - IntrusiveRefCntPtr Lower(new DummyFileSystem()); - IntrusiveRefCntPtr Upper(new DummyFileSystem()); - IntrusiveRefCntPtr O( + std::shared_ptr Lower(new DummyFileSystem()); + std::shared_ptr Upper(new DummyFileSystem()); + std::shared_ptr O( new vfs::OverlayFileSystem(Lower)); O->pushOverlay(Upper); @@ -408,10 +408,10 @@ } TEST(VirtualFileSystemTest, OverlayRecursiveIteration) { - IntrusiveRefCntPtr Lower(new DummyFileSystem()); - IntrusiveRefCntPtr Middle(new DummyFileSystem()); - IntrusiveRefCntPtr Upper(new DummyFileSystem()); - IntrusiveRefCntPtr O( + std::shared_ptr Lower(new DummyFileSystem()); + std::shared_ptr Middle(new DummyFileSystem()); + std::shared_ptr Upper(new DummyFileSystem()); + std::shared_ptr O( new vfs::OverlayFileSystem(Lower)); O->pushOverlay(Middle); O->pushOverlay(Upper); @@ -450,10 +450,10 @@ } TEST(VirtualFileSystemTest, ThreeLevelIteration) { - IntrusiveRefCntPtr Lower(new DummyFileSystem()); - IntrusiveRefCntPtr Middle(new DummyFileSystem()); - IntrusiveRefCntPtr Upper(new DummyFileSystem()); - IntrusiveRefCntPtr O( + std::shared_ptr Lower(new DummyFileSystem()); + std::shared_ptr Middle(new DummyFileSystem()); + std::shared_ptr Upper(new DummyFileSystem()); + std::shared_ptr O( new vfs::OverlayFileSystem(Lower)); O->pushOverlay(Middle); O->pushOverlay(Upper); @@ -470,10 +470,10 @@ } TEST(VirtualFileSystemTest, HiddenInIteration) { - IntrusiveRefCntPtr Lower(new DummyFileSystem()); - IntrusiveRefCntPtr Middle(new DummyFileSystem()); - IntrusiveRefCntPtr Upper(new DummyFileSystem()); - IntrusiveRefCntPtr O( + std::shared_ptr Lower(new DummyFileSystem()); + std::shared_ptr Middle(new DummyFileSystem()); + std::shared_ptr Upper(new DummyFileSystem()); + std::shared_ptr O( new vfs::OverlayFileSystem(Lower)); O->pushOverlay(Middle); O->pushOverlay(Upper); @@ -659,17 +659,18 @@ ++Test->NumDiagnostics; } - IntrusiveRefCntPtr + std::shared_ptr getFromYAMLRawString(StringRef Content, - IntrusiveRefCntPtr ExternalFS) { + std::shared_ptr ExternalFS) { std::unique_ptr Buffer = MemoryBuffer::getMemBuffer(Content); return getVFSFromYAML(std::move(Buffer), CountingDiagHandler, this, ExternalFS); } - IntrusiveRefCntPtr getFromYAMLString( + std::shared_ptr getFromYAMLString( StringRef Content, - IntrusiveRefCntPtr ExternalFS = new DummyFileSystem()) { + std::shared_ptr ExternalFS = + std::make_shared()) { std::string VersionPlusContent("{\n 'version':0,\n"); VersionPlusContent += Content.slice(Content.find('{') + 1, StringRef::npos); return getFromYAMLRawString(VersionPlusContent, ExternalFS); @@ -677,7 +678,7 @@ }; TEST_F(VFSFromYAMLTest, BasicVFSFromYAML) { - IntrusiveRefCntPtr FS; + std::shared_ptr FS; FS = getFromYAMLString(""); EXPECT_EQ(nullptr, FS.get()); FS = getFromYAMLString("[]"); @@ -688,9 +689,9 @@ } TEST_F(VFSFromYAMLTest, MappedFiles) { - IntrusiveRefCntPtr Lower(new DummyFileSystem()); + std::shared_ptr Lower(new DummyFileSystem()); Lower->addRegularFile("//root/foo/bar/a"); - IntrusiveRefCntPtr FS = + std::shared_ptr FS = getFromYAMLString("{ 'roots': [\n" "{\n" " 'type': 'directory',\n" @@ -712,7 +713,7 @@ Lower); ASSERT_TRUE(FS.get() != nullptr); - IntrusiveRefCntPtr O( + std::shared_ptr O( new vfs::OverlayFileSystem(Lower)); O->pushOverlay(FS); @@ -748,9 +749,9 @@ } TEST_F(VFSFromYAMLTest, CaseInsensitive) { - IntrusiveRefCntPtr Lower(new DummyFileSystem()); + std::shared_ptr Lower(new DummyFileSystem()); Lower->addRegularFile("//root/foo/bar/a"); - IntrusiveRefCntPtr FS = + std::shared_ptr FS = getFromYAMLString("{ 'case-sensitive': 'false',\n" " 'roots': [\n" "{\n" @@ -766,7 +767,7 @@ Lower); ASSERT_TRUE(FS.get() != nullptr); - IntrusiveRefCntPtr O( + std::shared_ptr O( new vfs::OverlayFileSystem(Lower)); O->pushOverlay(FS); @@ -784,9 +785,9 @@ } TEST_F(VFSFromYAMLTest, CaseSensitive) { - IntrusiveRefCntPtr Lower(new DummyFileSystem()); + std::shared_ptr Lower(new DummyFileSystem()); Lower->addRegularFile("//root/foo/bar/a"); - IntrusiveRefCntPtr FS = + std::shared_ptr FS = getFromYAMLString("{ 'case-sensitive': 'true',\n" " 'roots': [\n" "{\n" @@ -802,7 +803,7 @@ Lower); ASSERT_TRUE(FS.get() != nullptr); - IntrusiveRefCntPtr O( + std::shared_ptr O( new vfs::OverlayFileSystem(Lower)); O->pushOverlay(FS); @@ -816,10 +817,10 @@ } TEST_F(VFSFromYAMLTest, IllegalVFSFile) { - IntrusiveRefCntPtr Lower(new DummyFileSystem()); + std::shared_ptr Lower(new DummyFileSystem()); // invalid YAML at top-level - IntrusiveRefCntPtr FS = getFromYAMLString("{]", Lower); + std::shared_ptr FS = getFromYAMLString("{]", Lower); EXPECT_EQ(nullptr, FS.get()); // invalid YAML in roots FS = getFromYAMLString("{ 'roots':[}", Lower); @@ -907,10 +908,10 @@ } TEST_F(VFSFromYAMLTest, UseExternalName) { - IntrusiveRefCntPtr Lower(new DummyFileSystem()); + std::shared_ptr Lower(new DummyFileSystem()); Lower->addRegularFile("//root/external/file"); - IntrusiveRefCntPtr FS = getFromYAMLString( + std::shared_ptr FS = getFromYAMLString( "{ 'roots': [\n" " { 'type': 'file', 'name': '//root/A',\n" " 'external-contents': '//root/external/file'\n" @@ -958,11 +959,11 @@ } TEST_F(VFSFromYAMLTest, MultiComponentPath) { - IntrusiveRefCntPtr Lower(new DummyFileSystem()); + std::shared_ptr Lower(new DummyFileSystem()); Lower->addRegularFile("//root/other"); // file in roots - IntrusiveRefCntPtr FS = getFromYAMLString( + std::shared_ptr FS = getFromYAMLString( "{ 'roots': [\n" " { 'type': 'file', 'name': '//root/path/to/file',\n" " 'external-contents': '//root/other' }]\n" @@ -1001,11 +1002,11 @@ } TEST_F(VFSFromYAMLTest, TrailingSlashes) { - IntrusiveRefCntPtr Lower(new DummyFileSystem()); + std::shared_ptr Lower(new DummyFileSystem()); Lower->addRegularFile("//root/other"); // file in roots - IntrusiveRefCntPtr FS = getFromYAMLString( + std::shared_ptr FS = getFromYAMLString( "{ 'roots': [\n" " { 'type': 'directory', 'name': '//root/path/to////',\n" " 'contents': [ { 'type': 'file', 'name': 'file',\n" @@ -1019,14 +1020,14 @@ } TEST_F(VFSFromYAMLTest, DirectoryIteration) { - IntrusiveRefCntPtr Lower(new DummyFileSystem()); + std::shared_ptr Lower(new DummyFileSystem()); Lower->addDirectory("//root/"); Lower->addDirectory("//root/foo"); Lower->addDirectory("//root/foo/bar"); Lower->addRegularFile("//root/foo/bar/a"); Lower->addRegularFile("//root/foo/bar/b"); Lower->addRegularFile("//root/file3"); - IntrusiveRefCntPtr FS = + std::shared_ptr FS = getFromYAMLString("{ 'use-external-names': false,\n" " 'roots': [\n" "{\n" @@ -1049,7 +1050,7 @@ Lower); ASSERT_TRUE(FS.get() != nullptr); - IntrusiveRefCntPtr O( + std::shared_ptr O( new vfs::OverlayFileSystem(Lower)); O->pushOverlay(FS); Index: unittests/Driver/ToolChainTest.cpp =================================================================== --- unittests/Driver/ToolChainTest.cpp +++ unittests/Driver/ToolChainTest.cpp @@ -31,7 +31,7 @@ IntrusiveRefCntPtr DiagID(new DiagnosticIDs()); struct TestDiagnosticConsumer : public DiagnosticConsumer {}; DiagnosticsEngine Diags(DiagID, &*DiagOpts, new TestDiagnosticConsumer); - IntrusiveRefCntPtr InMemoryFileSystem( + std::shared_ptr InMemoryFileSystem( new vfs::InMemoryFileSystem); Driver TheDriver("/bin/clang", "arm-linux-gnueabihf", Diags, InMemoryFileSystem); @@ -84,7 +84,7 @@ IntrusiveRefCntPtr DiagID(new DiagnosticIDs()); struct TestDiagnosticConsumer : public DiagnosticConsumer {}; DiagnosticsEngine Diags(DiagID, &*DiagOpts, new TestDiagnosticConsumer); - IntrusiveRefCntPtr InMemoryFileSystem( + std::shared_ptr InMemoryFileSystem( new vfs::InMemoryFileSystem); Driver TheDriver("/home/test/bin/clang", "arm-linux-gnueabi", Diags, InMemoryFileSystem); Index: unittests/Lex/PPCallbacksTest.cpp =================================================================== --- unittests/Lex/PPCallbacksTest.cpp +++ unittests/Lex/PPCallbacksTest.cpp @@ -119,7 +119,7 @@ Target = TargetInfo::CreateTargetInfo(Diags, TargetOpts); } - IntrusiveRefCntPtr InMemoryFileSystem; + std::shared_ptr InMemoryFileSystem; FileManager FileMgr; IntrusiveRefCntPtr DiagID; IntrusiveRefCntPtr DiagOpts; Index: unittests/Tooling/RewriterTestContext.h =================================================================== --- unittests/Tooling/RewriterTestContext.h +++ unittests/Tooling/RewriterTestContext.h @@ -114,8 +114,8 @@ IntrusiveRefCntPtr DiagOpts; DiagnosticsEngine Diagnostics; TextDiagnosticPrinter DiagnosticPrinter; - IntrusiveRefCntPtr InMemoryFileSystem; - IntrusiveRefCntPtr OverlayFileSystem; + std::shared_ptr InMemoryFileSystem; + std::shared_ptr OverlayFileSystem; FileManager Files; SourceManager Sources; LangOptions Options; Index: unittests/Tooling/ToolingTest.cpp =================================================================== --- unittests/Tooling/ToolingTest.cpp +++ unittests/Tooling/ToolingTest.cpp @@ -149,9 +149,9 @@ } TEST(ToolInvocation, TestMapVirtualFile) { - llvm::IntrusiveRefCntPtr OverlayFileSystem( + std::shared_ptr OverlayFileSystem( new vfs::OverlayFileSystem(vfs::getRealFileSystem())); - llvm::IntrusiveRefCntPtr InMemoryFileSystem( + std::shared_ptr InMemoryFileSystem( new vfs::InMemoryFileSystem); OverlayFileSystem->pushOverlay(InMemoryFileSystem); llvm::IntrusiveRefCntPtr Files( @@ -175,9 +175,9 @@ // mapped module.map is found on the include path. In the future, expand this // test to run a full modules enabled compilation, so we make sure we can // rerun modules compilations with a virtual file system. - llvm::IntrusiveRefCntPtr OverlayFileSystem( + std::shared_ptr OverlayFileSystem( new vfs::OverlayFileSystem(vfs::getRealFileSystem())); - llvm::IntrusiveRefCntPtr InMemoryFileSystem( + std::shared_ptr InMemoryFileSystem( new vfs::InMemoryFileSystem); OverlayFileSystem->pushOverlay(InMemoryFileSystem); llvm::IntrusiveRefCntPtr Files(