[llvm-commits] CVS: llvm/lib/Bytecode/Reader/ReaderWrappers.cpp

Reid Spencer reid at x10sys.com
Tue Aug 22 09:10:26 PDT 2006



Changes in directory llvm/lib/Bytecode/Reader:

ReaderWrappers.cpp updated: 1.55 -> 1.56
---
Log message:

For PR797: http://llvm.org/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.


---
Diffs of the changes:  (+16 -8)

 ReaderWrappers.cpp |   24 ++++++++++++++++--------
 1 files changed, 16 insertions(+), 8 deletions(-)


Index: llvm/lib/Bytecode/Reader/ReaderWrappers.cpp
diff -u llvm/lib/Bytecode/Reader/ReaderWrappers.cpp:1.55 llvm/lib/Bytecode/Reader/ReaderWrappers.cpp:1.56
--- llvm/lib/Bytecode/Reader/ReaderWrappers.cpp:1.55	Thu Jul  6 16:35:01 2006
+++ llvm/lib/Bytecode/Reader/ReaderWrappers.cpp	Tue Aug 22 11:10:12 2006
@@ -48,11 +48,17 @@
 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 @@
     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 @@
     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;
+  }
 }
 
 //===----------------------------------------------------------------------===//






More information about the llvm-commits mailing list