[llvm-commits] [poolalloc] r104894 - /poolalloc/trunk/tools/Pa/pa.cpp
Will Dietz
wdietz2 at illinois.edu
Thu May 27 15:27:59 PDT 2010
Author: wdietz2
Date: Thu May 27 17:27:59 2010
New Revision: 104894
URL: http://llvm.org/viewvc/llvm-project?rev=104894&view=rev
Log:
tools/pa: remove try/catch block since we're exception-free
Modified:
poolalloc/trunk/tools/Pa/pa.cpp
Modified: poolalloc/trunk/tools/Pa/pa.cpp
URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/tools/Pa/pa.cpp?rev=104894&r1=104893&r2=104894&view=diff
==============================================================================
--- poolalloc/trunk/tools/Pa/pa.cpp (original)
+++ poolalloc/trunk/tools/Pa/pa.cpp Thu May 27 17:27:59 2010
@@ -68,104 +68,95 @@
// main - Entry point for the sc compiler.
//
int main(int argc, char **argv) {
- std::string mt;
- std::string & msg = mt;
- try {
- cl::ParseCommandLineOptions(argc, argv, " llvm system compiler\n");
- sys::PrintStackTraceOnErrorSignal();
-
- // Load the module to be compiled...
- std::auto_ptr<Module> M;
- std::string ErrorMessage;
- if (MemoryBuffer *Buffer
- = MemoryBuffer::getFileOrSTDIN(InputFilename, &ErrorMessage)) {
- M.reset(ParseBitcodeFile(Buffer, getGlobalContext(), &ErrorMessage));
- delete Buffer;
- }
+ cl::ParseCommandLineOptions(argc, argv, " llvm system compiler\n");
+ sys::PrintStackTraceOnErrorSignal();
- if (M.get() == 0) {
- std::cerr << argv[0] << ": bytecode didn't read correctly.\n";
- return 1;
- }
+ // Load the module to be compiled...
+ std::auto_ptr<Module> M;
+ std::string ErrorMessage;
+ if (MemoryBuffer *Buffer
+ = MemoryBuffer::getFileOrSTDIN(InputFilename, &ErrorMessage)) {
+ M.reset(ParseBitcodeFile(Buffer, getGlobalContext(), &ErrorMessage));
+ delete Buffer;
+ }
- // Build up all of the passes that we want to do to the module...
- PassManager Passes;
+ if (M.get() == 0) {
+ std::cerr << argv[0] << ": bytecode didn't read correctly.\n";
+ return 1;
+ }
- Passes.add(new TargetData(M.get()));
+ // Build up all of the passes that we want to do to the module...
+ PassManager Passes;
- // Currently deactiviated
- Passes.add(new PoolAllocate());
+ Passes.add(new TargetData(M.get()));
- // Verify the final result
- Passes.add(createVerifierPass());
-
- // Figure out where we are going to send the output...
- raw_fd_ostream *Out = 0;
- std::string error;
- if (OutputFilename != "") {
- if (OutputFilename != "-") {
- // Specified an output filename?
- if (!Force && std::ifstream(OutputFilename.c_str())) {
- // If force is not specified, make sure not to overwrite a file!
- std::cerr << argv[0] << ": error opening '" << OutputFilename
- << "': file exists!\n"
- << "Use -f command line argument to force output\n";
- return 1;
- }
- Out = new raw_fd_ostream (OutputFilename.c_str(), error);
-
- // Make sure that the Out file gets unlinked from the disk if we get a
- // SIGINT
- sys::RemoveFileOnSignal(sys::Path(OutputFilename));
- } else {
- Out = new raw_stdout_ostream();
- }
- } else {
- if (InputFilename == "-") {
- OutputFilename = "-";
- Out = new raw_stdout_ostream();
- } else {
- OutputFilename = GetFileNameRoot(InputFilename);
-
- OutputFilename += ".abc.bc";
- }
+ // Currently deactiviated
+ Passes.add(new PoolAllocate());
+ // Verify the final result
+ Passes.add(createVerifierPass());
+
+ // Figure out where we are going to send the output...
+ raw_fd_ostream *Out = 0;
+ std::string error;
+ if (OutputFilename != "") {
+ if (OutputFilename != "-") {
+ // Specified an output filename?
if (!Force && std::ifstream(OutputFilename.c_str())) {
// If force is not specified, make sure not to overwrite a file!
- std::cerr << argv[0] << ": error opening '" << OutputFilename
- << "': file exists!\n"
- << "Use -f command line argument to force output\n";
- return 1;
- }
-
- Out = new raw_fd_ostream(OutputFilename.c_str(), error);
- if (error.length()) {
- std::cerr << argv[0] << ": error opening " << OutputFilename << "!\n";
- delete Out;
+ std::cerr << argv[0] << ": error opening '" << OutputFilename
+ << "': file exists!\n"
+ << "Use -f command line argument to force output\n";
return 1;
}
+ Out = new raw_fd_ostream (OutputFilename.c_str(), error);
// Make sure that the Out file gets unlinked from the disk if we get a
// SIGINT
sys::RemoveFileOnSignal(sys::Path(OutputFilename));
+ } else {
+ Out = new raw_stdout_ostream();
}
-
- // Add the writing of the output file to the list of passes
- Passes.add (createBitcodeWriterPass(*Out));
-
- // Run our queue of passes all at once now, efficiently.
- Passes.run(*M.get());
-
- // Delete the ostream
- delete Out;
-
- return 0;
- } catch (msg) {
- std::cerr << argv[0] << ": " << msg << "\n";
- } catch (...) {
- std::cerr << argv[0] << ": Unexpected unknown exception occurred.\n";
+ } else {
+ if (InputFilename == "-") {
+ OutputFilename = "-";
+ Out = new raw_stdout_ostream();
+ } else {
+ OutputFilename = GetFileNameRoot(InputFilename);
+
+ OutputFilename += ".abc.bc";
+ }
+
+ if (!Force && std::ifstream(OutputFilename.c_str())) {
+ // If force is not specified, make sure not to overwrite a file!
+ std::cerr << argv[0] << ": error opening '" << OutputFilename
+ << "': file exists!\n"
+ << "Use -f command line argument to force output\n";
+ return 1;
+ }
+
+ Out = new raw_fd_ostream(OutputFilename.c_str(), error);
+ if (error.length()) {
+ std::cerr << argv[0] << ": error opening " << OutputFilename << "!\n";
+ delete Out;
+ return 1;
+ }
+
+ // Make sure that the Out file gets unlinked from the disk if we get a
+ // SIGINT
+ sys::RemoveFileOnSignal(sys::Path(OutputFilename));
}
- return 1;
+
+ // Add the writing of the output file to the list of passes
+ Passes.add (createBitcodeWriterPass(*Out));
+
+ // Run our queue of passes all at once now, efficiently.
+ Passes.run(*M.get());
+
+ // Delete the ostream
+ delete Out;
+
+ return 0;
}
More information about the llvm-commits
mailing list