diff options
author | Reid Spencer <rspencer@reidspencer.com> | 2004-12-13 02:59:03 +0000 |
---|---|---|
committer | Reid Spencer <rspencer@reidspencer.com> | 2004-12-13 02:59:03 +0000 |
commit | a204547e325734b75b412eeb5a3019cbedc47f03 (patch) | |
tree | 77e1635307d7b1c9582cc4cf91ce08cb3df0090c /llvm/lib/Bytecode/Archive/ArchiveReader.cpp | |
parent | 35f16dd40bfa0c23748cec78bc04323dc78fd6d3 (diff) | |
download | bcm5719-llvm-a204547e325734b75b412eeb5a3019cbedc47f03.tar.gz bcm5719-llvm-a204547e325734b75b412eeb5a3019cbedc47f03.zip |
Implement error handling in OpenAndLoad* functions so the Linker can handle it.
llvm-svn: 18853
Diffstat (limited to 'llvm/lib/Bytecode/Archive/ArchiveReader.cpp')
-rw-r--r-- | llvm/lib/Bytecode/Archive/ArchiveReader.cpp | 35 |
1 files changed, 22 insertions, 13 deletions
diff --git a/llvm/lib/Bytecode/Archive/ArchiveReader.cpp b/llvm/lib/Bytecode/Archive/ArchiveReader.cpp index b00487f0ded..a813371958d 100644 --- a/llvm/lib/Bytecode/Archive/ArchiveReader.cpp +++ b/llvm/lib/Bytecode/Archive/ArchiveReader.cpp @@ -280,13 +280,17 @@ Archive::loadArchive() { // 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 @@ Archive::loadSymbolTable() { // 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 |