Changes in directory llvm/lib/Bytecode/Reader:
Reader.h updated: 1.28 -> 1.29 ReaderWrappers.cpp updated: 1.54 -> 1.55 --- Log message: Change the ModuleProvider interface to not throw exceptions. --- Diffs of the changes: (+32 -19) Reader.h | 25 ++++++++++++++++++++----- ReaderWrappers.cpp | 26 ++++++++++++-------------- 2 files changed, 32 insertions(+), 19 deletions(-) Index: llvm/lib/Bytecode/Reader/Reader.h diff -u llvm/lib/Bytecode/Reader/Reader.h:1.28 llvm/lib/Bytecode/Reader/Reader.h:1.29 --- llvm/lib/Bytecode/Reader/Reader.h:1.28 Fri Jan 27 05:49:27 2006 +++ llvm/lib/Bytecode/Reader/Reader.h Thu Jul 6 16:35:01 2006 @@ -153,18 +153,33 @@ /// implementation is identical to the ParseFunction method. /// @see ParseFunction /// @brief Make a specific function materialize. - virtual void materializeFunction(Function *F) { + virtual bool materializeFunction(Function *F, std::string *ErrInfo = 0) { LazyFunctionMap::iterator Fi = LazyFunctionLoadMap.find(F); - if (Fi == LazyFunctionLoadMap.end()) return; - ParseFunction(F); + if (Fi == LazyFunctionLoadMap.end()) return false; + try { + ParseFunction(F); + } catch (std::string &ErrStr) { + if (ErrInfo) *ErrInfo = ErrStr; + return true; + } catch (...) { + return true; + } + return false; } /// This method is abstract in the parent ModuleProvider class. Its /// implementation is identical to ParseAllFunctionBodies. /// @see ParseAllFunctionBodies /// @brief Make the whole module materialize - virtual Module* materializeModule() { - ParseAllFunctionBodies(); + virtual Module* materializeModule(std::string *ErrInfo = 0) { + try { + ParseAllFunctionBodies(); + } catch (std::string &ErrStr) { + if (ErrInfo) *ErrInfo = ErrStr; + return 0; + } catch (...) { + return 0; + } return TheModule; } Index: llvm/lib/Bytecode/Reader/ReaderWrappers.cpp diff -u llvm/lib/Bytecode/Reader/ReaderWrappers.cpp:1.54 llvm/lib/Bytecode/Reader/ReaderWrappers.cpp:1.55 --- llvm/lib/Bytecode/Reader/ReaderWrappers.cpp:1.54 Wed Jun 7 18:18:33 2006 +++ llvm/lib/Bytecode/Reader/ReaderWrappers.cpp Thu Jul 6 16:35:01 2006 @@ -170,7 +170,8 @@ // If we get to this point, we know that we have an old-style module. // Materialize the whole thing to perform the rewriting. - MP->materializeModule(); + if (MP->materializeModule() == 0) + return 0; if(Function* F = M->getNamedFunction("llvm.va_start")) { assert(F->arg_size() == 0 && "Obsolete va_start takes 0 argument!"); @@ -376,22 +377,18 @@ // Get just the externally visible defined symbols from the bytecode bool llvm::GetBytecodeSymbols(const sys::Path& fName, std::vector<std::string>& symbols) { - try { - std::auto_ptr<ModuleProvider> AMP( - getBytecodeModuleProvider(fName.toString())); + std::auto_ptr<ModuleProvider> AMP( + getBytecodeModuleProvider(fName.toString())); - // Get the module from the provider - Module* M = AMP->materializeModule(); + // Get the module from the provider + Module* M = AMP->materializeModule(); + if (M == 0) return false; - // Get the symbols - getSymbols(M, symbols); + // Get the symbols + getSymbols(M, symbols); - // Done with the module - return true; - - } catch (...) { - return false; - } + // Done with the module + return true; } ModuleProvider* @@ -406,6 +403,7 @@ // Get the module from the provider Module* M = MP->materializeModule(); + if (M == 0) return 0; // Get the symbols getSymbols(M, symbols); _______________________________________________ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits