Replace throw 0 with real exceptions or assertions.
This commit is contained in:
@@ -103,12 +103,12 @@ void output_llvm(llvm_context& ctx, const std::string& filename) {
|
||||
std::error_code ec;
|
||||
llvm::raw_fd_ostream file(filename, ec, llvm::sys::fs::F_None);
|
||||
if (ec) {
|
||||
throw 0;
|
||||
throw std::runtime_error("failed to open object file for writing");
|
||||
} else {
|
||||
llvm::CodeGenFileType type = llvm::CGFT_ObjectFile;
|
||||
llvm::legacy::PassManager pm;
|
||||
if (targetMachine->addPassesToEmitFile(pm, file, NULL, type)) {
|
||||
throw 0;
|
||||
throw std::runtime_error("failed to add passes to pass manager");
|
||||
} else {
|
||||
pm.run(ctx.module);
|
||||
file.close();
|
||||
@@ -132,10 +132,13 @@ void gen_llvm(global_scope& scope) {
|
||||
|
||||
int main(int argc, char** argv) {
|
||||
if(argc != 2) {
|
||||
std::cout << "please enter a file to compile." << std::endl;
|
||||
std::cerr << "please enter a file to compile." << std::endl;
|
||||
}
|
||||
parse_driver driver(argv[1]);
|
||||
driver.run_parse();
|
||||
if(!driver.run_parse()) {
|
||||
std::cerr << "failed to open file " << argv[1] << std::endl;
|
||||
exit(1);
|
||||
}
|
||||
|
||||
type_mgr mgr;
|
||||
type_env_ptr env(new type_env);
|
||||
@@ -154,8 +157,10 @@ int main(int argc, char** argv) {
|
||||
scope.compile();
|
||||
gen_llvm(scope);
|
||||
} catch(unification_error& err) {
|
||||
err.pretty_print(std::cout, driver, mgr);
|
||||
err.pretty_print(std::cerr, driver, mgr);
|
||||
} catch(type_error& err) {
|
||||
err.pretty_print(std::cout, driver);
|
||||
err.pretty_print(std::cerr, driver);
|
||||
} catch(std::runtime_error& err) {
|
||||
std::cerr << err.what() << std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user