diff options
author | Reid Spencer <rspencer@reidspencer.com> | 2006-08-22 16:10:12 +0000 |
---|---|---|
committer | Reid Spencer <rspencer@reidspencer.com> | 2006-08-22 16:10:12 +0000 |
commit | b152fd247c16d7401f406db42cbb35cd649cdb4b (patch) | |
tree | 03b07c6bd708d23079a70f8700a450f4a4479789 /lib/Bytecode | |
parent | 233fe721c5489a32b8b5aaf4e6b43e4383d75400 (diff) | |
download | external_llvm-b152fd247c16d7401f406db42cbb35cd649cdb4b.zip external_llvm-b152fd247c16d7401f406db42cbb35cd649cdb4b.tar.gz external_llvm-b152fd247c16d7401f406db42cbb35cd649cdb4b.tar.bz2 |
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.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@29820 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Bytecode')
-rw-r--r-- | lib/Bytecode/Reader/ReaderWrappers.cpp | 24 |
1 files changed, 16 insertions, 8 deletions
diff --git a/lib/Bytecode/Reader/ReaderWrappers.cpp b/lib/Bytecode/Reader/ReaderWrappers.cpp index b9e7cd2..1767159 100644 --- a/lib/Bytecode/Reader/ReaderWrappers.cpp +++ b/lib/Bytecode/Reader/ReaderWrappers.cpp @@ -48,11 +48,17 @@ namespace { BytecodeFileReader::BytecodeFileReader(const std::string &Filename, llvm::BytecodeHandler* 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()); - 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; MustDelete = false; } - try { - ParseBytecode(ParseBegin, Length, ModuleID); - } catch (...) { + std::string ErrMsg; + if (ParseBytecode(ParseBegin, Length, ModuleID, &ErrMsg)) { if (MustDelete) delete [] Buffer; - throw; + throw ErrMsg; } } @@ -149,7 +154,10 @@ BytecodeStdinReader::BytecodeStdinReader( BytecodeHandler* H ) throw std::string("Standard Input empty!"); FileBuf = &FileData[0]; - ParseBytecode(FileBuf, FileData.size(), "<stdin>"); + std::string ErrMsg; + if (ParseBytecode(FileBuf, FileData.size(), "<stdin>", &ErrMsg)) { + throw ErrMsg; + } } //===----------------------------------------------------------------------===// |