summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Support/YAMLParser.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'llvm/lib/Support/YAMLParser.cpp')
-rw-r--r--llvm/lib/Support/YAMLParser.cpp8
1 files changed, 5 insertions, 3 deletions
diff --git a/llvm/lib/Support/YAMLParser.cpp b/llvm/lib/Support/YAMLParser.cpp
index 01cd926297a..07a326ee554 100644
--- a/llvm/lib/Support/YAMLParser.cpp
+++ b/llvm/lib/Support/YAMLParser.cpp
@@ -708,8 +708,10 @@ Scanner::Scanner(StringRef Input, SourceMgr &sm)
, IsStartOfStream(true)
, IsSimpleKeyAllowed(true)
, Failed(false) {
- InputBuffer = MemoryBuffer::getMemBuffer(Input, "YAML");
- SM.AddNewSourceBuffer(InputBuffer, SMLoc());
+ std::unique_ptr<MemoryBuffer> InputBufferOwner(
+ MemoryBuffer::getMemBuffer(Input, "YAML"));
+ InputBuffer = InputBufferOwner.get();
+ SM.AddNewSourceBuffer(std::move(InputBufferOwner), SMLoc());
Current = InputBuffer->getBufferStart();
End = InputBuffer->getBufferEnd();
}
@@ -719,7 +721,7 @@ Scanner::Scanner(std::unique_ptr<MemoryBuffer> Buffer, SourceMgr &SM_)
Current(InputBuffer->getBufferStart()), End(InputBuffer->getBufferEnd()),
Indent(-1), Column(0), Line(0), FlowLevel(0), IsStartOfStream(true),
IsSimpleKeyAllowed(true), Failed(false) {
- SM.AddNewSourceBuffer(Buffer.release(), SMLoc());
+ SM.AddNewSourceBuffer(std::move(Buffer), SMLoc());
}
Token &Scanner::peekNext() {
OpenPOWER on IntegriCloud