[llvm-commits] CVS: llvm/tools/llvm-as/llvm-as.cpp

Reid Spencer reid at x10sys.com
Wed Dec 29 21:36:23 PST 2004



Changes in directory llvm/tools/llvm-as:

llvm-as.cpp updated: 1.38 -> 1.39
---
Log message:

For PR351: http://llvm.cs.uiuc.edu/PR351 :
* Place a try/catch block around the entire tool to Make sure std::string 
  exceptions are caught and printed before exiting the tool.
* Make sure we catch unhandled exceptions at the top level so that we don't
  abort with a useless message but indicate than an unhandled exception was
  generated.


---
Diffs of the changes:  (+9 -2)

Index: llvm/tools/llvm-as/llvm-as.cpp
diff -u llvm/tools/llvm-as/llvm-as.cpp:1.38 llvm/tools/llvm-as/llvm-as.cpp:1.39
--- llvm/tools/llvm-as/llvm-as.cpp:1.38	Sun Nov 14 16:20:53 2004
+++ llvm/tools/llvm-as/llvm-as.cpp	Wed Dec 29 23:36:07 2004
@@ -52,6 +52,7 @@
   cl::ParseCommandLineOptions(argc, argv, " llvm .ll -> .bc assembler\n");
   sys::PrintStackTraceOnErrorSignal();
 
+  int exitCode = 0;
   std::ostream *Out = 0;
   try {
     // Parse the file now...
@@ -126,10 +127,16 @@
     WriteBytecodeToFile(M.get(), *Out, !NoCompress);
   } catch (const ParseException &E) {
     std::cerr << argv[0] << ": " << E.getMessage() << "\n";
-    return 1;
+    exitCode = 1;
+  } catch (const std::string& msg) {
+    std::cerr << argv[0] << ": " << msg << "\n";
+    exitCode = 1;
+  } catch (...) {
+    std::cerr << argv[0] << ": Unexpected unknown exception occurred.\n";
+    exitCode = 1;
   }
 
   if (Out != &std::cout) delete Out;
-  return 0;
+  return exitCode;
 }
 






More information about the llvm-commits mailing list