1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2025-01-31 12:41:49 +01:00

Add MemoryBufferRef(MemoryBuffer&) constructor.

patch by Jonathan Anderson!

llvm-svn: 253311
This commit is contained in:
Rafael Espindola 2015-11-17 05:11:44 +00:00
parent 192e197bb7
commit b080f6e9fc
2 changed files with 11 additions and 0 deletions

View File

@ -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) {}

View File

@ -170,6 +170,15 @@ TEST_F(MemoryBufferTest, getOpenFileReopened) {
}
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;