diff options
-rw-r--r-- | clang/include/clang/Basic/VirtualFileSystem.h | 4 | ||||
-rw-r--r-- | clang/lib/Basic/VirtualFileSystem.cpp | 15 | ||||
-rw-r--r-- | clang/lib/Frontend/CompilerInvocation.cpp | 2 | ||||
-rw-r--r-- | clang/unittests/Basic/VirtualFileSystemTest.cpp | 3 |
4 files changed, 11 insertions, 13 deletions
diff --git a/clang/include/clang/Basic/VirtualFileSystem.h b/clang/include/clang/Basic/VirtualFileSystem.h index 92b84047150..86f8dd66fdf 100644 --- a/clang/include/clang/Basic/VirtualFileSystem.h +++ b/clang/include/clang/Basic/VirtualFileSystem.h @@ -250,10 +250,8 @@ llvm::sys::fs::UniqueID getNextVirtualUniqueID(); /// \brief Gets a \p FileSystem for a virtual file system described in YAML /// format. -/// -/// Takes ownership of \p Buffer. IntrusiveRefCntPtr<FileSystem> -getVFSFromYAML(llvm::MemoryBuffer *Buffer, +getVFSFromYAML(std::unique_ptr<llvm::MemoryBuffer> Buffer, llvm::SourceMgr::DiagHandlerTy DiagHandler, void *DiagContext = nullptr, IntrusiveRefCntPtr<FileSystem> ExternalFS = getRealFileSystem()); diff --git a/clang/lib/Basic/VirtualFileSystem.cpp b/clang/lib/Basic/VirtualFileSystem.cpp index a5c83b88af5..60c3052bddf 100644 --- a/clang/lib/Basic/VirtualFileSystem.cpp +++ b/clang/lib/Basic/VirtualFileSystem.cpp @@ -514,9 +514,7 @@ public: /// \brief Parses \p Buffer, which is expected to be in YAML format and /// returns a virtual file system representing its contents. - /// - /// Takes ownership of \p Buffer. - static VFSFromYAML *create(MemoryBuffer *Buffer, + static VFSFromYAML *create(std::unique_ptr<MemoryBuffer> Buffer, SourceMgr::DiagHandlerTy DiagHandler, void *DiagContext, IntrusiveRefCntPtr<FileSystem> ExternalFS); @@ -865,13 +863,13 @@ DirectoryEntry::~DirectoryEntry() { llvm::DeleteContainerPointers(Contents); } VFSFromYAML::~VFSFromYAML() { llvm::DeleteContainerPointers(Roots); } -VFSFromYAML *VFSFromYAML::create(MemoryBuffer *Buffer, +VFSFromYAML *VFSFromYAML::create(std::unique_ptr<MemoryBuffer> Buffer, SourceMgr::DiagHandlerTy DiagHandler, void *DiagContext, IntrusiveRefCntPtr<FileSystem> ExternalFS) { SourceMgr SM; - yaml::Stream Stream(Buffer, SM); + yaml::Stream Stream(Buffer.release(), SM); SM.setDiagHandler(DiagHandler, DiagContext); yaml::document_iterator DI = Stream.begin(); @@ -993,10 +991,11 @@ VFSFromYAML::openFileForRead(const Twine &Path, } IntrusiveRefCntPtr<FileSystem> -vfs::getVFSFromYAML(MemoryBuffer *Buffer, SourceMgr::DiagHandlerTy DiagHandler, - void *DiagContext, +vfs::getVFSFromYAML(std::unique_ptr<MemoryBuffer> Buffer, + SourceMgr::DiagHandlerTy DiagHandler, void *DiagContext, IntrusiveRefCntPtr<FileSystem> ExternalFS) { - return VFSFromYAML::create(Buffer, DiagHandler, DiagContext, ExternalFS); + return VFSFromYAML::create(std::move(Buffer), DiagHandler, DiagContext, + ExternalFS); } UniqueID vfs::getNextVirtualUniqueID() { diff --git a/clang/lib/Frontend/CompilerInvocation.cpp b/clang/lib/Frontend/CompilerInvocation.cpp index 070b00c63af..fbfad94ec3c 100644 --- a/clang/lib/Frontend/CompilerInvocation.cpp +++ b/clang/lib/Frontend/CompilerInvocation.cpp @@ -2034,7 +2034,7 @@ createVFSFromCompilerInvocation(const CompilerInvocation &CI, } IntrusiveRefCntPtr<vfs::FileSystem> FS = - vfs::getVFSFromYAML(Buffer->release(), /*DiagHandler*/ nullptr); + vfs::getVFSFromYAML(std::move(Buffer.get()), /*DiagHandler*/ nullptr); if (!FS.get()) { Diags.Report(diag::err_invalid_vfs_overlay) << File; return IntrusiveRefCntPtr<vfs::FileSystem>(); diff --git a/clang/unittests/Basic/VirtualFileSystemTest.cpp b/clang/unittests/Basic/VirtualFileSystemTest.cpp index e7d361e252b..89836816e8c 100644 --- a/clang/unittests/Basic/VirtualFileSystemTest.cpp +++ b/clang/unittests/Basic/VirtualFileSystemTest.cpp @@ -540,7 +540,8 @@ public: getFromYAMLRawString(StringRef Content, IntrusiveRefCntPtr<vfs::FileSystem> ExternalFS) { MemoryBuffer *Buffer = MemoryBuffer::getMemBuffer(Content); - return getVFSFromYAML(Buffer, CountingDiagHandler, this, ExternalFS); + return getVFSFromYAML(std::unique_ptr<MemoryBuffer>(Buffer), + CountingDiagHandler, this, ExternalFS); } IntrusiveRefCntPtr<vfs::FileSystem> getFromYAMLString( |