[llvm-commits] CVS: llvm/lib/Bytecode/Archive/ArchiveReader.cpp

Reid Spencer reid at x10sys.com
Sun Dec 12 18:59:14 PST 2004



Changes in directory llvm/lib/Bytecode/Archive:

ArchiveReader.cpp updated: 1.34 -> 1.35
---
Log message:

Implement error handling in OpenAndLoad* functions so the Linker can handle it.

---
Diffs of the changes:  (+22 -13)

Index: llvm/lib/Bytecode/Archive/ArchiveReader.cpp
diff -u llvm/lib/Bytecode/Archive/ArchiveReader.cpp:1.34 llvm/lib/Bytecode/Archive/ArchiveReader.cpp:1.35
--- llvm/lib/Bytecode/Archive/ArchiveReader.cpp:1.34	Fri Dec 10 18:14:15 2004
+++ llvm/lib/Bytecode/Archive/ArchiveReader.cpp	Sun Dec 12 20:59:03 2004
@@ -280,13 +280,17 @@
 
 // Open and completely load the archive file.
 Archive*
-Archive::OpenAndLoad(const sys::Path& file) {
-
-  Archive* result = new Archive(file, true);
-
-  result->loadArchive();
-  
-  return result;
+Archive::OpenAndLoad(const sys::Path& file, std::string* ErrorMessage) {
+  try {
+    Archive* result = new Archive(file, true);
+    result->loadArchive();
+    return result;
+  } catch (const std::string& msg) {
+    if (ErrorMessage) {
+      *ErrorMessage = msg;
+    }
+    return 0;
+  }
 }
 
 // Get all the bytecode modules from the archive
@@ -371,12 +375,17 @@
 
 // Open the archive and load just the symbol tables
 Archive*
-Archive::OpenAndLoadSymbols(const sys::Path& file) {
-  Archive* result = new Archive(file, true);
-
-  result->loadSymbolTable();
-
-  return result;
+Archive::OpenAndLoadSymbols(const sys::Path& file, std::string* ErrorMessage) {
+  try {
+    Archive* result = new Archive(file, true);
+    result->loadSymbolTable();
+    return result;
+  } catch (const std::string& msg) {
+    if (ErrorMessage) {
+      *ErrorMessage = msg;
+    }
+    return 0;
+  }
 }
 
 // Look up one symbol in the symbol table and return a ModuleProvider for the






More information about the llvm-commits mailing list