mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2025-02-23 14:03:14 +00:00
For PR797:
Adjust the use of MappedFile to its new non-throwing interface. We just propagate the exceptions if an error occurs. This will get cleaned up later, incrementally. llvm-svn: 29820
This commit is contained in:
parent
d00c37651a
commit
2ee33a6305
@ -48,11 +48,17 @@ namespace {
|
|||||||
BytecodeFileReader::BytecodeFileReader(const std::string &Filename,
|
BytecodeFileReader::BytecodeFileReader(const std::string &Filename,
|
||||||
llvm::BytecodeHandler* H )
|
llvm::BytecodeHandler* H )
|
||||||
: BytecodeReader(H)
|
: BytecodeReader(H)
|
||||||
, mapFile( sys::Path(Filename))
|
, mapFile()
|
||||||
{
|
{
|
||||||
mapFile.map();
|
std::string ErrMsg;
|
||||||
|
if (mapFile.open(sys::Path(Filename), sys::MappedFile::READ_ACCESS, &ErrMsg))
|
||||||
|
throw ErrMsg;
|
||||||
|
if (!mapFile.map(&ErrMsg))
|
||||||
|
throw ErrMsg;
|
||||||
unsigned char* buffer = reinterpret_cast<unsigned char*>(mapFile.base());
|
unsigned char* buffer = reinterpret_cast<unsigned char*>(mapFile.base());
|
||||||
ParseBytecode(buffer, mapFile.size(), Filename);
|
if (ParseBytecode(buffer, mapFile.size(), Filename, &ErrMsg)) {
|
||||||
|
throw ErrMsg;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//===----------------------------------------------------------------------===//
|
//===----------------------------------------------------------------------===//
|
||||||
@ -98,11 +104,10 @@ BytecodeBufferReader::BytecodeBufferReader(const unsigned char *Buf,
|
|||||||
ParseBegin = Buffer = Buf;
|
ParseBegin = Buffer = Buf;
|
||||||
MustDelete = false;
|
MustDelete = false;
|
||||||
}
|
}
|
||||||
try {
|
std::string ErrMsg;
|
||||||
ParseBytecode(ParseBegin, Length, ModuleID);
|
if (ParseBytecode(ParseBegin, Length, ModuleID, &ErrMsg)) {
|
||||||
} catch (...) {
|
|
||||||
if (MustDelete) delete [] Buffer;
|
if (MustDelete) delete [] Buffer;
|
||||||
throw;
|
throw ErrMsg;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -149,7 +154,10 @@ BytecodeStdinReader::BytecodeStdinReader( BytecodeHandler* H )
|
|||||||
throw std::string("Standard Input empty!");
|
throw std::string("Standard Input empty!");
|
||||||
|
|
||||||
FileBuf = &FileData[0];
|
FileBuf = &FileData[0];
|
||||||
ParseBytecode(FileBuf, FileData.size(), "<stdin>");
|
std::string ErrMsg;
|
||||||
|
if (ParseBytecode(FileBuf, FileData.size(), "<stdin>", &ErrMsg)) {
|
||||||
|
throw ErrMsg;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//===----------------------------------------------------------------------===//
|
//===----------------------------------------------------------------------===//
|
||||||
|
Loading…
x
Reference in New Issue
Block a user