diff options
-rw-r--r-- | clang/include/clang/Basic/SourceManager.h | 6 | ||||
-rw-r--r-- | clang/lib/Format/Format.cpp | 2 | ||||
-rw-r--r-- | clang/lib/Frontend/CompilerInstance.cpp | 6 | ||||
-rw-r--r-- | clang/lib/Index/SimpleFormatContext.h | 2 | ||||
-rw-r--r-- | clang/lib/Lex/Preprocessor.cpp | 2 | ||||
-rw-r--r-- | clang/lib/Serialization/ASTReader.cpp | 2 | ||||
-rw-r--r-- | clang/lib/Tooling/Refactoring.cpp | 2 | ||||
-rw-r--r-- | clang/unittests/Basic/SourceManagerTest.cpp | 4 | ||||
-rw-r--r-- | clang/unittests/Tooling/RewriterTestContext.h | 2 |
9 files changed, 16 insertions, 12 deletions
diff --git a/clang/include/clang/Basic/SourceManager.h b/clang/include/clang/Basic/SourceManager.h index fb65c4b28d0..8addde9d155 100644 --- a/clang/include/clang/Basic/SourceManager.h +++ b/clang/include/clang/Basic/SourceManager.h @@ -832,7 +832,11 @@ public: /// \param DoNotFree If true, then the buffer will not be freed when the /// source manager is destroyed. void overrideFileContents(const FileEntry *SourceFile, - llvm::MemoryBuffer *Buffer, bool DoNotFree = false); + llvm::MemoryBuffer *Buffer, bool DoNotFree); + void overrideFileContents(const FileEntry *SourceFile, + std::unique_ptr<llvm::MemoryBuffer> Buffer) { + overrideFileContents(SourceFile, Buffer.release(), /*DoNotFree*/ false); + } /// \brief Override the given source file with another one. /// diff --git a/clang/lib/Format/Format.cpp b/clang/lib/Format/Format.cpp index 32808b519af..432da61d85a 100644 --- a/clang/lib/Format/Format.cpp +++ b/clang/lib/Format/Format.cpp @@ -1996,7 +1996,7 @@ tooling::Replacements reformat(const FormatStyle &Style, StringRef Code, llvm::MemoryBuffer::getMemBuffer(Code, FileName); const clang::FileEntry *Entry = Files.getVirtualFile(FileName, Buf->getBufferSize(), 0); - SourceMgr.overrideFileContents(Entry, Buf.release()); + SourceMgr.overrideFileContents(Entry, std::move(Buf)); FileID ID = SourceMgr.createFileID(Entry, SourceLocation(), clang::SrcMgr::C_User); Lexer Lex(ID, SourceMgr.getBuffer(ID), SourceMgr, diff --git a/clang/lib/Frontend/CompilerInstance.cpp b/clang/lib/Frontend/CompilerInstance.cpp index a535afdc056..4cba26cc632 100644 --- a/clang/lib/Frontend/CompilerInstance.cpp +++ b/clang/lib/Frontend/CompilerInstance.cpp @@ -727,7 +727,7 @@ bool CompilerInstance::InitializeSourceManager(const FrontendInputFile &Input, FileMgr.getBufferForFile(File, &ErrorStr, /*isVolatile=*/true)) { // Create a new virtual file that will have the correct size. File = FileMgr.getVirtualFile(InputFile, MB->getBufferSize(), 0); - SourceMgr.overrideFileContents(File, MB.release()); + SourceMgr.overrideFileContents(File, std::move(MB)); } else { Diags.Report(diag::err_cannot_open_file) << InputFile << ErrorStr; return false; @@ -749,7 +749,7 @@ bool CompilerInstance::InitializeSourceManager(const FrontendInputFile &Input, SB->getBufferSize(), 0); SourceMgr.setMainFileID( SourceMgr.createFileID(File, SourceLocation(), Kind)); - SourceMgr.overrideFileContents(File, SB.release()); + SourceMgr.overrideFileContents(File, std::move(SB)); } assert(!SourceMgr.getMainFileID().isInvalid() && @@ -951,7 +951,7 @@ static bool compileModuleImpl(CompilerInstance &ImportingInstance, llvm::MemoryBuffer::getMemBuffer(InferredModuleMapContent); ModuleMapFile = Instance.getFileManager().getVirtualFile( "__inferred_module.map", InferredModuleMapContent.size(), 0); - SourceMgr.overrideFileContents(ModuleMapFile, ModuleMapBuffer.release()); + SourceMgr.overrideFileContents(ModuleMapFile, std::move(ModuleMapBuffer)); } // Construct a module-generating action. Passing through the module map is diff --git a/clang/lib/Index/SimpleFormatContext.h b/clang/lib/Index/SimpleFormatContext.h index faf865786a5..080a4ad04dd 100644 --- a/clang/lib/Index/SimpleFormatContext.h +++ b/clang/lib/Index/SimpleFormatContext.h @@ -51,7 +51,7 @@ public: llvm::MemoryBuffer::getMemBuffer(Content); const FileEntry *Entry = Files.getVirtualFile(Name, Source->getBufferSize(), 0); - Sources.overrideFileContents(Entry, Source.release()); + Sources.overrideFileContents(Entry, std::move(Source)); assert(Entry != nullptr); return Sources.createFileID(Entry, SourceLocation(), SrcMgr::C_User); } diff --git a/clang/lib/Lex/Preprocessor.cpp b/clang/lib/Lex/Preprocessor.cpp index 29956c9f584..1dd46b0de9b 100644 --- a/clang/lib/Lex/Preprocessor.cpp +++ b/clang/lib/Lex/Preprocessor.cpp @@ -406,7 +406,7 @@ bool Preprocessor::SetCodeCompletionPoint(const FileEntry *File, char *NewPos = std::copy(Buffer->getBufferStart(), Position, NewBuf); *NewPos = '\0'; std::copy(Position, Buffer->getBufferEnd(), NewPos+1); - SourceMgr.overrideFileContents(File, NewBuffer.release()); + SourceMgr.overrideFileContents(File, std::move(NewBuffer)); } return false; diff --git a/clang/lib/Serialization/ASTReader.cpp b/clang/lib/Serialization/ASTReader.cpp index 1bee2a026b8..68faeed6a20 100644 --- a/clang/lib/Serialization/ASTReader.cpp +++ b/clang/lib/Serialization/ASTReader.cpp @@ -1226,7 +1226,7 @@ bool ASTReader::ReadSLocEntry(int ID) { std::unique_ptr<llvm::MemoryBuffer> Buffer = llvm::MemoryBuffer::getMemBuffer(Blob.drop_back(1), File->getName()); - SourceMgr.overrideFileContents(File, Buffer.release()); + SourceMgr.overrideFileContents(File, std::move(Buffer)); } break; diff --git a/clang/lib/Tooling/Refactoring.cpp b/clang/lib/Tooling/Refactoring.cpp index ab16dfd35f8..b2a02cb0964 100644 --- a/clang/lib/Tooling/Refactoring.cpp +++ b/clang/lib/Tooling/Refactoring.cpp @@ -186,7 +186,7 @@ std::string applyAllReplacements(StringRef Code, const Replacements &Replaces) { llvm::MemoryBuffer::getMemBuffer(Code, "<stdin>"); const clang::FileEntry *Entry = Files.getVirtualFile("<stdin>", Buf->getBufferSize(), 0); - SourceMgr.overrideFileContents(Entry, Buf.release()); + SourceMgr.overrideFileContents(Entry, std::move(Buf)); FileID ID = SourceMgr.createFileID(Entry, SourceLocation(), clang::SrcMgr::C_User); for (Replacements::const_iterator I = Replaces.begin(), E = Replaces.end(); diff --git a/clang/unittests/Basic/SourceManagerTest.cpp b/clang/unittests/Basic/SourceManagerTest.cpp index dc27560b3a8..540a8051e60 100644 --- a/clang/unittests/Basic/SourceManagerTest.cpp +++ b/clang/unittests/Basic/SourceManagerTest.cpp @@ -193,7 +193,7 @@ TEST_F(SourceManagerTest, getMacroArgExpandedLocation) { const FileEntry *headerFile = FileMgr.getVirtualFile("/test-header.h", HeaderBuf->getBufferSize(), 0); - SourceMgr.overrideFileContents(headerFile, HeaderBuf.release()); + SourceMgr.overrideFileContents(headerFile, std::move(HeaderBuf)); VoidModuleLoader ModLoader; HeaderSearch HeaderInfo(new HeaderSearchOptions, SourceMgr, Diags, LangOpts, @@ -291,7 +291,7 @@ TEST_F(SourceManagerTest, isBeforeInTranslationUnitWithMacroInInclude) { const FileEntry *headerFile = FileMgr.getVirtualFile("/test-header.h", HeaderBuf->getBufferSize(), 0); - SourceMgr.overrideFileContents(headerFile, HeaderBuf.release()); + SourceMgr.overrideFileContents(headerFile, std::move(HeaderBuf)); VoidModuleLoader ModLoader; HeaderSearch HeaderInfo(new HeaderSearchOptions, SourceMgr, Diags, LangOpts, diff --git a/clang/unittests/Tooling/RewriterTestContext.h b/clang/unittests/Tooling/RewriterTestContext.h index bf25f8c9989..82c00582f1f 100644 --- a/clang/unittests/Tooling/RewriterTestContext.h +++ b/clang/unittests/Tooling/RewriterTestContext.h @@ -52,7 +52,7 @@ class RewriterTestContext { llvm::MemoryBuffer::getMemBuffer(Content); const FileEntry *Entry = Files.getVirtualFile(Name, Source->getBufferSize(), 0); - Sources.overrideFileContents(Entry, Source.release()); + Sources.overrideFileContents(Entry, std::move(Source)); assert(Entry != nullptr); return Sources.createFileID(Entry, SourceLocation(), SrcMgr::C_User); } |