[llvm-commits] CVS: llvm/tools/llvm-nm/llvm-nm.cpp
Reid Spencer
reid at x10sys.com
Wed Dec 29 21:36:22 PST 2004
Changes in directory llvm/tools/llvm-nm:
llvm-nm.cpp updated: 1.21 -> 1.22
---
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: (+20 -13)
Index: llvm/tools/llvm-nm/llvm-nm.cpp
diff -u llvm/tools/llvm-nm/llvm-nm.cpp:1.21 llvm/tools/llvm-nm/llvm-nm.cpp:1.22
--- llvm/tools/llvm-nm/llvm-nm.cpp:1.21 Tue Dec 14 19:53:50 2004
+++ llvm/tools/llvm-nm/llvm-nm.cpp Wed Dec 29 23:36:07 2004
@@ -152,20 +152,27 @@
}
int main(int argc, char **argv) {
- cl::ParseCommandLineOptions(argc, argv, " llvm symbol table dumper\n");
- sys::PrintStackTraceOnErrorSignal();
+ try {
+ cl::ParseCommandLineOptions(argc, argv, " llvm symbol table dumper\n");
+ sys::PrintStackTraceOnErrorSignal();
- ToolName = argv[0];
- if (BSDFormat) OutputFormat = bsd;
- if (POSIXFormat) OutputFormat = posix;
+ ToolName = argv[0];
+ if (BSDFormat) OutputFormat = bsd;
+ if (POSIXFormat) OutputFormat = posix;
- switch (InputFilenames.size()) {
- case 0: InputFilenames.push_back("-");
- case 1: break;
- default: MultipleFiles = true;
- }
+ switch (InputFilenames.size()) {
+ case 0: InputFilenames.push_back("-");
+ case 1: break;
+ default: MultipleFiles = true;
+ }
- std::for_each (InputFilenames.begin (), InputFilenames.end (),
- DumpSymbolNamesFromFile);
- return 0;
+ std::for_each (InputFilenames.begin (), InputFilenames.end (),
+ DumpSymbolNamesFromFile);
+ return 0;
+ } catch (const std::string& msg) {
+ std::cerr << argv[0] << ": " << msg << "\n";
+ } catch (...) {
+ std::cerr << argv[0] << ": Unexpected unknown exception occurred.\n";
+ }
+ return 1;
}
More information about the llvm-commits
mailing list