Explicitly pass ownership of the MemoryBuffer to AddNewSourceBuffer using std::unique_ptr

llvm-svn: 216223
This commit is contained in:
David Blaikie
2014-08-21 20:44:56 +00:00
parent e423ed36f0
commit 1961f14cf9
12 changed files with 55 additions and 57 deletions

View File

@@ -141,14 +141,15 @@ static void parseMCMarkup(StringRef Filename) {
errs() << ToolName << ": " << EC.message() << '\n';
return;
}
MemoryBuffer *Buffer = BufferPtr->release();
std::unique_ptr<MemoryBuffer> &Buffer = BufferPtr.get();
SourceMgr SrcMgr;
// Tell SrcMgr about this buffer, which is what the parser will pick up.
SrcMgr.AddNewSourceBuffer(Buffer, SMLoc());
StringRef InputSource = Buffer->getBuffer();
// Tell SrcMgr about this buffer, which is what the parser will pick up.
SrcMgr.AddNewSourceBuffer(std::move(Buffer), SMLoc());
MarkupLexer Lex(InputSource);
MarkupParser Parser(Lex, SrcMgr);