Added error messages when failed to open files for .bc and .ll output, instead of just trying to write to the stream, pretty similar to the #281 problem.

This commit is contained in:
Tomas Lindquist Olsen
2009-05-17 14:40:09 +02:00
parent 0a77bd9fa6
commit 9be5694168

View File

@@ -210,6 +210,11 @@ void writeModule(llvm::Module* m, std::string filename)
bcpath.appendSuffix(std::string(global.bc_ext));
Logger::println("Writing LLVM bitcode to: %s\n", bcpath.c_str());
std::ofstream bos(bcpath.c_str(), std::ios::binary);
if (bos.fail())
{
error("cannot write LLVM bitcode, failed to open file '%s'", bcpath.c_str());
fatal();
}
llvm::WriteBitcodeToFile(m, bos);
}
@@ -220,6 +225,11 @@ void writeModule(llvm::Module* m, std::string filename)
llpath.appendSuffix(std::string(global.ll_ext));
Logger::println("Writing LLVM asm to: %s\n", llpath.c_str());
std::ofstream aos(llpath.c_str());
if (aos.fail())
{
error("cannot write LLVM asm, failed to open file '%s'", llpath.c_str());
fatal();
}
m->print(aos, NULL);
}