mirror of
https://github.com/RPCS3/llvm.git
synced 2024-11-27 21:50:29 +00:00
[Support] Remove MemoryBuffer::getNewUninitMemBuffer
There is nothing useful that can be done with a read-only uninitialized buffer without const_casting its contents to initialize it. A better solution is to obtain a writable buffer (WritableMemoryBuffer::getNewUninitMemBuffer), and then convert it to a read-only buffer after initialization. All callers of this function have already been updated to do this, so this function is now unused. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@321257 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
dacebdf03d
commit
2a379e0e27
@ -123,15 +123,6 @@ public:
|
||||
static std::unique_ptr<MemoryBuffer>
|
||||
getNewMemBuffer(size_t Size, StringRef BufferName = "");
|
||||
|
||||
/// Allocate a new MemoryBuffer of the specified size that is not initialized.
|
||||
/// Note that the caller should initialize the memory allocated by this
|
||||
/// method. The memory is owned by the MemoryBuffer object.
|
||||
//
|
||||
// TODO: Remove this and migrate callers to
|
||||
// WritableMemoryBuffer::getNewUninitMemBuffer
|
||||
static std::unique_ptr<MemoryBuffer>
|
||||
getNewUninitMemBuffer(size_t Size, const Twine &BufferName = "");
|
||||
|
||||
/// Read all of stdin into a file buffer, and return it.
|
||||
static ErrorOr<std::unique_ptr<MemoryBuffer>> getSTDIN();
|
||||
|
||||
@ -199,6 +190,9 @@ public:
|
||||
getFileSlice(const Twine &Filename, uint64_t MapSize, uint64_t Offset,
|
||||
bool IsVolatile = false);
|
||||
|
||||
/// Allocate a new MemoryBuffer of the specified size that is not initialized.
|
||||
/// Note that the caller should initialize the memory allocated by this
|
||||
/// method. The memory is owned by the MemoryBuffer object.
|
||||
static std::unique_ptr<WritableMemoryBuffer>
|
||||
getNewUninitMemBuffer(size_t Size, const Twine &BufferName = "");
|
||||
|
||||
|
@ -139,18 +139,13 @@ MemoryBuffer::getMemBufferCopy(StringRef InputData, const Twine &BufferName) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
std::unique_ptr<MemoryBuffer>
|
||||
MemoryBuffer::getNewUninitMemBuffer(size_t Size, const Twine &BufferName) {
|
||||
return WritableMemoryBuffer::getNewUninitMemBuffer(Size, BufferName);
|
||||
}
|
||||
|
||||
std::unique_ptr<MemoryBuffer>
|
||||
MemoryBuffer::getNewMemBuffer(size_t Size, StringRef BufferName) {
|
||||
std::unique_ptr<MemoryBuffer> SB = getNewUninitMemBuffer(Size, BufferName);
|
||||
auto SB = WritableMemoryBuffer::getNewUninitMemBuffer(Size, BufferName);
|
||||
if (!SB)
|
||||
return nullptr;
|
||||
memset(const_cast<char*>(SB->getBufferStart()), 0, Size);
|
||||
return SB;
|
||||
memset(SB->getBufferStart(), 0, Size);
|
||||
return std::move(SB);
|
||||
}
|
||||
|
||||
ErrorOr<std::unique_ptr<MemoryBuffer>>
|
||||
|
@ -104,15 +104,15 @@ TEST_F(MemoryBufferTest, copy) {
|
||||
|
||||
TEST_F(MemoryBufferTest, make_new) {
|
||||
// 0-sized buffer
|
||||
OwningBuffer Zero(MemoryBuffer::getNewUninitMemBuffer(0));
|
||||
OwningBuffer Zero(WritableMemoryBuffer::getNewUninitMemBuffer(0));
|
||||
EXPECT_TRUE(nullptr != Zero.get());
|
||||
|
||||
// uninitialized buffer with no name
|
||||
OwningBuffer One(MemoryBuffer::getNewUninitMemBuffer(321));
|
||||
OwningBuffer One(WritableMemoryBuffer::getNewUninitMemBuffer(321));
|
||||
EXPECT_TRUE(nullptr != One.get());
|
||||
|
||||
// uninitialized buffer with name
|
||||
OwningBuffer Two(MemoryBuffer::getNewUninitMemBuffer(123, "bla"));
|
||||
OwningBuffer Two(WritableMemoryBuffer::getNewUninitMemBuffer(123, "bla"));
|
||||
EXPECT_TRUE(nullptr != Two.get());
|
||||
|
||||
// 0-initialized buffer with no name
|
||||
|
Loading…
Reference in New Issue
Block a user