X-Git-Url: http://demsky.eecs.uci.edu/git/?a=blobdiff_plain;f=lib%2FAsmParser%2FParser.cpp;h=dfe8d559a44cd526c8c28ea788e3bd907be9cc39;hb=c53544af06acf3fba1788613a364f1f40317869e;hp=626fe263ad49c7936321193f4b2cbd651351fdc8;hpb=a28504313d4c3fe87173a71b511dd4c8e25c3312;p=oota-llvm.git diff --git a/lib/AsmParser/Parser.cpp b/lib/AsmParser/Parser.cpp index 626fe263ad4..dfe8d559a44 100644 --- a/lib/AsmParser/Parser.cpp +++ b/lib/AsmParser/Parser.cpp @@ -7,40 +7,32 @@ #include "llvm/Analysis/Verifier.h" #include "llvm/Module.h" #include "ParserInternals.h" -#include // for sprintf +using std::string; // The useful interface defined by this file... Parse an ascii file, and return // the internal representation in a nice slice'n'dice'able representation. // -Module *ParseAssemblyFile(const string &Filename) throw (ParseException) { +Module *ParseAssemblyFile(const string &Filename) { // throw (ParseException) FILE *F = stdin; - if (Filename != "-") + if (Filename != "-") { F = fopen(Filename.c_str(), "r"); - if (F == 0) { - throw ParseException(Filename, string("Could not open file '") + - Filename + "'"); + if (F == 0) + throw ParseException(Filename, "Could not open file '" + Filename + "'"); } - // TODO: If this throws an exception, F is not closed. - Module *Result = RunVMAsmParser(Filename, F); + Module *Result; + try { + Result = RunVMAsmParser(Filename, F); + } catch (...) { + if (F != stdin) fclose(F); // Make sure to close file descriptor if an + throw; // exception is thrown + } if (F != stdin) fclose(F); - if (Result) { // Check to see that it is valid... - vector Errors; - if (verify(Result, Errors)) { - delete Result; Result = 0; - string Message; - - for (unsigned i = 0; i < Errors.size(); i++) - Message += Errors[i] + "\n"; - - throw ParseException(Filename, Message); - } - } return Result; }