mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-07-25 13:24:46 +00:00
Use std::unique_ptr to manage the DataStreamer in bitcode parsing.
We were already deleting it, this just makes it explicit. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@239867 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -16,6 +16,7 @@
|
||||
|
||||
#include "llvm/Support/DataStream.h"
|
||||
#include "llvm/ADT/Statistic.h"
|
||||
#include "llvm/ADT/STLExtras.h"
|
||||
#include "llvm/Support/FileSystem.h"
|
||||
#include "llvm/Support/Program.h"
|
||||
#include <string>
|
||||
@@ -73,16 +74,13 @@ public:
|
||||
|
||||
}
|
||||
|
||||
namespace llvm {
|
||||
DataStreamer *getDataFileStreamer(const std::string &Filename,
|
||||
std::string *StrError) {
|
||||
DataFileStreamer *s = new DataFileStreamer();
|
||||
std::unique_ptr<DataStreamer>
|
||||
llvm::getDataFileStreamer(const std::string &Filename, std::string *StrError) {
|
||||
std::unique_ptr<DataFileStreamer> s = make_unique<DataFileStreamer>();
|
||||
if (std::error_code e = s->OpenFile(Filename)) {
|
||||
*StrError = std::string("Could not open ") + Filename + ": " +
|
||||
e.message() + "\n";
|
||||
return nullptr;
|
||||
}
|
||||
return s;
|
||||
}
|
||||
|
||||
return std::move(s);
|
||||
}
|
||||
|
@@ -123,9 +123,10 @@ MemoryObject *getNonStreamedMemoryObject(const unsigned char *Start,
|
||||
return new RawMemoryObject(Start, End);
|
||||
}
|
||||
|
||||
StreamingMemoryObject::StreamingMemoryObject(DataStreamer *streamer) :
|
||||
Bytes(kChunkSize), Streamer(streamer), BytesRead(0), BytesSkipped(0),
|
||||
ObjectSize(0), EOFReached(false) {
|
||||
BytesRead = streamer->GetBytes(&Bytes[0], kChunkSize);
|
||||
StreamingMemoryObject::StreamingMemoryObject(
|
||||
std::unique_ptr<DataStreamer> Streamer)
|
||||
: Bytes(kChunkSize), Streamer(std::move(Streamer)), BytesRead(0),
|
||||
BytesSkipped(0), ObjectSize(0), EOFReached(false) {
|
||||
BytesRead = this->Streamer->GetBytes(&Bytes[0], kChunkSize);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user