diff options
author | Duncan P. N. Exon Smith <dexonsmith@apple.com> | 2020-12-08 14:58:46 -0800 |
---|---|---|
committer | Duncan P. N. Exon Smith <dexonsmith@apple.com> | 2020-12-08 17:33:46 -0800 |
commit | a22eda548b8e1f9362018dec194af0ca91b35da0 (patch) | |
tree | deeb0af688f34dfd07446da8eea87866fefe33ba /llvm/lib/Support/VirtualFileSystem.cpp | |
parent | 5207f19d103dc3e0ec974fa64d2c031d84d497a8 (diff) | |
download | llvm-a22eda548b8e1f9362018dec194af0ca91b35da0.zip llvm-a22eda548b8e1f9362018dec194af0ca91b35da0.tar.gz llvm-a22eda548b8e1f9362018dec194af0ca91b35da0.tar.bz2 |
VFS: Return new file systems as uniquely owned when possible, almost NFC
Uniformly return uniquely-owned filesystems from VFS creation APIs. The
one exception is `getRealFileSystem`, which has a single instance and
needs to be shared.
This is almost NFC, except that it fixes a memory leak in
`vfs::collectVFSFromYAML()`.
Depends on https://reviews.llvm.org/D92888
Differential Revision: https://reviews.llvm.org/D92890
Diffstat (limited to 'llvm/lib/Support/VirtualFileSystem.cpp')
-rw-r--r-- | llvm/lib/Support/VirtualFileSystem.cpp | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/llvm/lib/Support/VirtualFileSystem.cpp b/llvm/lib/Support/VirtualFileSystem.cpp index 697383d..de24992 100644 --- a/llvm/lib/Support/VirtualFileSystem.cpp +++ b/llvm/lib/Support/VirtualFileSystem.cpp @@ -1639,7 +1639,7 @@ public: } }; -RedirectingFileSystem * +std::unique_ptr<RedirectingFileSystem> RedirectingFileSystem::create(std::unique_ptr<MemoryBuffer> Buffer, SourceMgr::DiagHandlerTy DiagHandler, StringRef YAMLFilePath, void *DiagContext, @@ -1679,7 +1679,7 @@ RedirectingFileSystem::create(std::unique_ptr<MemoryBuffer> Buffer, if (!P.parse(Root, FS.get())) return nullptr; - return FS.release(); + return FS; } ErrorOr<RedirectingFileSystem::Entry *> @@ -1861,7 +1861,7 @@ RedirectingFileSystem::getRealPath(const Twine &Path, : llvm::errc::invalid_argument; } -IntrusiveRefCntPtr<FileSystem> +std::unique_ptr<FileSystem> vfs::getVFSFromYAML(std::unique_ptr<MemoryBuffer> Buffer, SourceMgr::DiagHandlerTy DiagHandler, StringRef YAMLFilePath, void *DiagContext, @@ -1902,7 +1902,7 @@ void vfs::collectVFSFromYAML(std::unique_ptr<MemoryBuffer> Buffer, SmallVectorImpl<YAMLVFSEntry> &CollectedEntries, void *DiagContext, IntrusiveRefCntPtr<FileSystem> ExternalFS) { - RedirectingFileSystem *VFS = RedirectingFileSystem::create( + std::unique_ptr<RedirectingFileSystem> VFS = RedirectingFileSystem::create( std::move(Buffer), DiagHandler, YAMLFilePath, DiagContext, std::move(ExternalFS)); ErrorOr<RedirectingFileSystem::Entry *> RootE = VFS->lookupPath("/"); |