mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-12-14 11:32:34 +00:00
Provide exception handling
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@17787 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
5e081fb74a
commit
4c1af902ad
@ -157,6 +157,9 @@ int main(int argc, char **argv, char **envp) {
|
||||
cl::ParseCommandLineOptions(argc, argv, " llvm linker for GCC\n");
|
||||
sys::PrintStackTraceOnErrorSignal();
|
||||
|
||||
int exitCode = 0;
|
||||
|
||||
try {
|
||||
std::string ModuleID("gccld-output");
|
||||
std::auto_ptr<Module> Composite(new Module(ModuleID));
|
||||
|
||||
@ -192,7 +195,7 @@ int main(int argc, char **argv, char **envp) {
|
||||
|
||||
// Ensure that the bytecode file gets removed from the disk if we get a
|
||||
// SIGINT signal.
|
||||
sys::RemoveFileOnSignal(RealBytecodeOutput);
|
||||
sys::RemoveFileOnSignal(sys::Path(RealBytecodeOutput));
|
||||
|
||||
// Generate the bytecode file.
|
||||
if (GenerateBytecode(Composite.get(), Strip, !NoInternalize, &Out)) {
|
||||
@ -215,8 +218,8 @@ int main(int argc, char **argv, char **envp) {
|
||||
std::string AssemblyFile = OutputFilename + ".s";
|
||||
|
||||
// Mark the output files for removal if we get an interrupt.
|
||||
sys::RemoveFileOnSignal(AssemblyFile);
|
||||
sys::RemoveFileOnSignal(OutputFilename);
|
||||
sys::RemoveFileOnSignal(sys::Path(AssemblyFile));
|
||||
sys::RemoveFileOnSignal(sys::Path(OutputFilename));
|
||||
|
||||
// Determine the locations of the llc and gcc programs.
|
||||
std::string llc = FindExecutable("llc", argv[0]);
|
||||
@ -240,8 +243,8 @@ int main(int argc, char **argv, char **envp) {
|
||||
std::string CFile = OutputFilename + ".cbe.c";
|
||||
|
||||
// Mark the output files for removal if we get an interrupt.
|
||||
sys::RemoveFileOnSignal(CFile);
|
||||
sys::RemoveFileOnSignal(OutputFilename);
|
||||
sys::RemoveFileOnSignal(sys::Path(CFile));
|
||||
sys::RemoveFileOnSignal(sys::Path(OutputFilename));
|
||||
|
||||
// Determine the locations of the llc and gcc programs.
|
||||
std::string llc = FindExecutable("llc", argv[0]);
|
||||
@ -271,6 +274,17 @@ int main(int argc, char **argv, char **envp) {
|
||||
MakeFileExecutable(RealBytecodeOutput);
|
||||
MakeFileReadable(RealBytecodeOutput);
|
||||
}
|
||||
|
||||
return 0;
|
||||
} catch (const char*msg) {
|
||||
std::cerr << argv[0] << ": " << msg << "\n";
|
||||
exitCode = 1;
|
||||
} catch (const std::string& msg) {
|
||||
std::cerr << argv[0] << ": " << msg << "\n";
|
||||
exitCode = 2;
|
||||
} catch (...) {
|
||||
// This really shouldn't happen, but just in case ....
|
||||
std::cerr << argv[0] << ": An nexpected unknown exception occurred.\n";
|
||||
exitCode = 3;
|
||||
}
|
||||
|
||||
return exitCode;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user