[llvm] r253311 - Add MemoryBufferRef(MemoryBuffer&) constructor.
Rafael Espindola via llvm-commits
llvm-commits at lists.llvm.org
Mon Nov 16 21:11:44 PST 2015
Author: rafael
Date: Mon Nov 16 23:11:44 2015
New Revision: 253311
URL: http://llvm.org/viewvc/llvm-project?rev=253311&view=rev
Log:
Add MemoryBufferRef(MemoryBuffer&) constructor.
patch by Jonathan Anderson!
Modified:
llvm/trunk/include/llvm/Support/MemoryBuffer.h
llvm/trunk/unittests/Support/MemoryBufferTest.cpp
Modified: llvm/trunk/include/llvm/Support/MemoryBuffer.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/MemoryBuffer.h?rev=253311&r1=253310&r2=253311&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Support/MemoryBuffer.h (original)
+++ llvm/trunk/include/llvm/Support/MemoryBuffer.h Mon Nov 16 23:11:44 2015
@@ -152,6 +152,8 @@ class MemoryBufferRef {
public:
MemoryBufferRef() {}
+ MemoryBufferRef(MemoryBuffer& Buffer)
+ : Buffer(Buffer.getBuffer()), Identifier(Buffer.getBufferIdentifier()) {}
MemoryBufferRef(StringRef Buffer, StringRef Identifier)
: Buffer(Buffer), Identifier(Identifier) {}
Modified: llvm/trunk/unittests/Support/MemoryBufferTest.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/unittests/Support/MemoryBufferTest.cpp?rev=253311&r1=253310&r2=253311&view=diff
==============================================================================
--- llvm/trunk/unittests/Support/MemoryBufferTest.cpp (original)
+++ llvm/trunk/unittests/Support/MemoryBufferTest.cpp Mon Nov 16 23:11:44 2015
@@ -170,6 +170,15 @@ TEST_F(MemoryBufferTest, getOpenFileReop
}
+TEST_F(MemoryBufferTest, reference) {
+ OwningBuffer MB(MemoryBuffer::getMemBuffer(data));
+ MemoryBufferRef MBR(*MB);
+
+ EXPECT_EQ(MB->getBufferStart(), MBR.getBufferStart());
+ EXPECT_EQ(MB->getBufferIdentifier(), MBR.getBufferIdentifier());
+}
+
+
TEST_F(MemoryBufferTest, slice) {
// Create a file that is six pages long with different data on each page.
int FD;
More information about the llvm-commits
mailing list