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 | 5af46883f27eb66ada1ca01e011e80bfb838f08e (patch) | |
tree | 0c1de1a0f8bc942352e554faaabc4f483b2d958f /lib | |
parent | 56c3ed854f0a5765ec6777b2beac99893c7e1ccc (diff) | |
download | external_llvm-5af46883f27eb66ada1ca01e011e80bfb838f08e.zip external_llvm-5af46883f27eb66ada1ca01e011e80bfb838f08e.tar.gz external_llvm-5af46883f27eb66ada1ca01e011e80bfb838f08e.tar.bz2 |
Implement error handling in OpenAndLoad* functions so the Linker can handle it.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@18853 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r-- | lib/Archive/ArchiveReader.cpp | 35 | ||||
-rw-r--r-- | lib/Bytecode/Archive/ArchiveReader.cpp | 35 |
2 files changed, 44 insertions, 26 deletions
diff --git a/lib/Archive/ArchiveReader.cpp b/lib/Archive/ArchiveReader.cpp index b00487f..a813371 100644 --- a/lib/Archive/ArchiveReader.cpp +++ b/lib/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 diff --git a/lib/Bytecode/Archive/ArchiveReader.cpp b/lib/Bytecode/Archive/ArchiveReader.cpp index b00487f..a813371 100644 --- a/lib/Bytecode/Archive/ArchiveReader.cpp +++ b/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 |