[llvm-commits] CVS: llvm/tools/analyze/analyze.cpp
Reid Spencer
reid at x10sys.com
Wed Dec 29 21:36:23 PST 2004
Changes in directory llvm/tools/analyze:
analyze.cpp updated: 1.62 -> 1.63
---
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: (+54 -46)
Index: llvm/tools/analyze/analyze.cpp
diff -u llvm/tools/analyze/analyze.cpp:1.62 llvm/tools/analyze/analyze.cpp:1.63
--- llvm/tools/analyze/analyze.cpp:1.62 Sun Sep 19 23:48:03 2004
+++ llvm/tools/analyze/analyze.cpp Wed Dec 29 23:36:07 2004
@@ -116,58 +116,66 @@
}
int main(int argc, char **argv) {
- cl::ParseCommandLineOptions(argc, argv, " llvm analysis printer tool\n");
- sys::PrintStackTraceOnErrorSignal();
-
- Module *CurMod = 0;
try {
+ cl::ParseCommandLineOptions(argc, argv, " llvm analysis printer tool\n");
+ sys::PrintStackTraceOnErrorSignal();
+
+ Module *CurMod = 0;
+ try {
#if 0
- TimeRegion RegionTimer(BytecodeLoadTimer);
+ TimeRegion RegionTimer(BytecodeLoadTimer);
#endif
- CurMod = ParseBytecodeFile(InputFilename);
- if (!CurMod && !(CurMod = ParseAssemblyFile(InputFilename))){
- std::cerr << argv[0] << ": input file didn't read correctly.\n";
+ CurMod = ParseBytecodeFile(InputFilename);
+ if (!CurMod && !(CurMod = ParseAssemblyFile(InputFilename))){
+ std::cerr << argv[0] << ": input file didn't read correctly.\n";
+ return 1;
+ }
+ } catch (const ParseException &E) {
+ std::cerr << argv[0] << ": " << E.getMessage() << "\n";
return 1;
}
- } catch (const ParseException &E) {
- std::cerr << argv[0] << ": " << E.getMessage() << "\n";
- return 1;
- }
- // Create a PassManager to hold and optimize the collection of passes we are
- // about to build...
- //
- PassManager Passes;
-
- // Add an appropriate TargetData instance for this module...
- Passes.add(new TargetData("analyze", CurMod));
-
- // Make sure the input LLVM is well formed.
- if (!NoVerify)
- Passes.add(createVerifierPass());
-
- // Create a new optimization pass for each one specified on the command line
- for (unsigned i = 0; i < AnalysesList.size(); ++i) {
- const PassInfo *Analysis = AnalysesList[i];
-
- if (Analysis->getNormalCtor()) {
- Pass *P = Analysis->getNormalCtor()();
- Passes.add(P);
-
- if (BasicBlockPass *BBP = dynamic_cast<BasicBlockPass*>(P))
- Passes.add(new BasicBlockPassPrinter(Analysis));
- else if (FunctionPass *FP = dynamic_cast<FunctionPass*>(P))
- Passes.add(new FunctionPassPrinter(Analysis));
- else
- Passes.add(new ModulePassPrinter(Analysis));
-
- } else
- std::cerr << argv[0] << ": cannot create pass: "
- << Analysis->getPassName() << "\n";
- }
+ // Create a PassManager to hold and optimize the collection of passes we are
+ // about to build...
+ //
+ PassManager Passes;
+
+ // Add an appropriate TargetData instance for this module...
+ Passes.add(new TargetData("analyze", CurMod));
+
+ // Make sure the input LLVM is well formed.
+ if (!NoVerify)
+ Passes.add(createVerifierPass());
+
+ // Create a new optimization pass for each one specified on the command line
+ for (unsigned i = 0; i < AnalysesList.size(); ++i) {
+ const PassInfo *Analysis = AnalysesList[i];
+
+ if (Analysis->getNormalCtor()) {
+ Pass *P = Analysis->getNormalCtor()();
+ Passes.add(P);
+
+ if (BasicBlockPass *BBP = dynamic_cast<BasicBlockPass*>(P))
+ Passes.add(new BasicBlockPassPrinter(Analysis));
+ else if (FunctionPass *FP = dynamic_cast<FunctionPass*>(P))
+ Passes.add(new FunctionPassPrinter(Analysis));
+ else
+ Passes.add(new ModulePassPrinter(Analysis));
+
+ } else
+ std::cerr << argv[0] << ": cannot create pass: "
+ << Analysis->getPassName() << "\n";
+ }
+
+ Passes.run(*CurMod);
- Passes.run(*CurMod);
+ delete CurMod;
+ return 0;
- delete CurMod;
- 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