[llvm] r215855 - Convert an ownership comment with std::uinque_ptr.
Rafael Espindola
rafael.espindola at gmail.com
Sun Aug 17 15:20:33 PDT 2014
Author: rafael
Date: Sun Aug 17 17:20:33 2014
New Revision: 215855
URL: http://llvm.org/viewvc/llvm-project?rev=215855&view=rev
Log:
Convert an ownership comment with std::uinque_ptr.
Modified:
llvm/trunk/include/llvm/Support/YAMLParser.h
llvm/trunk/lib/Support/YAMLParser.cpp
llvm/trunk/unittests/Support/YAMLParserTest.cpp
Modified: llvm/trunk/include/llvm/Support/YAMLParser.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/YAMLParser.h?rev=215855&r1=215854&r2=215855&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Support/YAMLParser.h (original)
+++ llvm/trunk/include/llvm/Support/YAMLParser.h Sun Aug 17 17:20:33 2014
@@ -79,8 +79,7 @@ public:
/// \brief This keeps a reference to the string referenced by \p Input.
Stream(StringRef Input, SourceMgr &);
- /// \brief This takes ownership of \p InputBuffer.
- Stream(MemoryBuffer *InputBuffer, SourceMgr &);
+ Stream(std::unique_ptr<MemoryBuffer> InputBuffer, SourceMgr &);
~Stream();
document_iterator begin();
Modified: llvm/trunk/lib/Support/YAMLParser.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/YAMLParser.cpp?rev=215855&r1=215854&r2=215855&view=diff
==============================================================================
--- llvm/trunk/lib/Support/YAMLParser.cpp (original)
+++ llvm/trunk/lib/Support/YAMLParser.cpp Sun Aug 17 17:20:33 2014
@@ -260,7 +260,7 @@ namespace yaml {
class Scanner {
public:
Scanner(const StringRef Input, SourceMgr &SM);
- Scanner(MemoryBuffer *Buffer, SourceMgr &SM_);
+ Scanner(std::unique_ptr<MemoryBuffer> Buffer, SourceMgr &SM_);
/// @brief Parse the next token and return it without popping it.
Token &peekNext();
@@ -714,19 +714,12 @@ Scanner::Scanner(StringRef Input, Source
End = InputBuffer->getBufferEnd();
}
-Scanner::Scanner(MemoryBuffer *Buffer, SourceMgr &SM_)
- : SM(SM_)
- , InputBuffer(Buffer)
- , Current(InputBuffer->getBufferStart())
- , End(InputBuffer->getBufferEnd())
- , Indent(-1)
- , Column(0)
- , Line(0)
- , FlowLevel(0)
- , IsStartOfStream(true)
- , IsSimpleKeyAllowed(true)
- , Failed(false) {
- SM.AddNewSourceBuffer(InputBuffer, SMLoc());
+Scanner::Scanner(std::unique_ptr<MemoryBuffer> Buffer, SourceMgr &SM_)
+ : SM(SM_), InputBuffer(Buffer.get()),
+ 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());
}
Token &Scanner::peekNext() {
@@ -1524,8 +1517,8 @@ bool Scanner::fetchMoreTokens() {
Stream::Stream(StringRef Input, SourceMgr &SM)
: scanner(new Scanner(Input, SM)), CurrentDoc() {}
-Stream::Stream(MemoryBuffer *InputBuffer, SourceMgr &SM)
- : scanner(new Scanner(InputBuffer, SM)), CurrentDoc() {}
+Stream::Stream(std::unique_ptr<MemoryBuffer> InputBuffer, SourceMgr &SM)
+ : scanner(new Scanner(std::move(InputBuffer), SM)), CurrentDoc() {}
Stream::~Stream() {}
Modified: llvm/trunk/unittests/Support/YAMLParserTest.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/unittests/Support/YAMLParserTest.cpp?rev=215855&r1=215854&r2=215855&view=diff
==============================================================================
--- llvm/trunk/unittests/Support/YAMLParserTest.cpp (original)
+++ llvm/trunk/unittests/Support/YAMLParserTest.cpp Sun Aug 17 17:20:33 2014
@@ -210,8 +210,9 @@ TEST(YAMLParser, DiagnosticFilenameFromB
// When we construct a YAML stream over a named buffer,
// we get its ID as filename in diagnostics.
- MemoryBuffer* Buffer = MemoryBuffer::getMemBuffer("[]", "buffername.yaml");
- yaml::Stream Stream(Buffer, SM);
+ std::unique_ptr<MemoryBuffer> Buffer(
+ MemoryBuffer::getMemBuffer("[]", "buffername.yaml"));
+ yaml::Stream Stream(std::move(Buffer), SM);
Stream.printError(Stream.begin()->getRoot(), "Hello, World!");
EXPECT_EQ("buffername.yaml", GeneratedDiag.getFilename());
}
More information about the llvm-commits
mailing list