Add a pointer to the owning LLVMContext to Module. This requires threading LLVMConte...
[oota-llvm.git] / tools / llvm-ranlib / llvm-ranlib.cpp
index b89b7138d734505d96e4ffad7b0f1518e2768433..7b1b413ecca852c91eed76a5cda54fe7555ca2e2 100644 (file)
@@ -2,8 +2,8 @@
 //
 //                     The LLVM Compiler Infrastructure
 //
-// This file was developed by Reid Spencer and is distributed under the
-// University of Illinois Open Source License. See LICENSE.TXT for details.
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
 //
 //===----------------------------------------------------------------------===//
 //
 //
 //===----------------------------------------------------------------------===//
 
+#include "llvm/LLVMContext.h"
 #include "llvm/Module.h"
 #include "llvm/Bitcode/Archive.h"
 #include "llvm/Support/CommandLine.h"
 #include "llvm/Support/ManagedStatic.h"
+#include "llvm/Support/PrettyStackTrace.h"
 #include "llvm/System/Signals.h"
 #include <iostream>
 #include <iomanip>
@@ -42,7 +44,12 @@ void printSymbolTable(Archive* TheArchive) {
 }
 
 int main(int argc, char **argv) {
-  llvm_shutdown_obj X;  // Call llvm_shutdown() on exit.
+  // Print a stack trace if we signal out.
+  llvm::sys::PrintStackTraceOnErrorSignal();
+  llvm::PrettyStackTraceProgram X(argc, argv);
+
+  LLVMContext Context;
+  llvm_shutdown_obj Y;  // Call llvm_shutdown() on exit.
 
   // Have the command line options parsed and handle things
   // like --help and --version.
@@ -52,9 +59,6 @@ int main(int argc, char **argv) {
     "  to an LLVM archive file."
   );
 
-  // Print a stack trace if we signal out.
-  sys::PrintStackTraceOnErrorSignal();
-
   int exitCode = 0;
 
   // Make sure we don't exit with "unhandled exception".
@@ -71,7 +75,7 @@ int main(int argc, char **argv) {
 
     std::string err_msg;
     std::auto_ptr<Archive>
-      AutoArchive(Archive::OpenAndLoad(ArchivePath,&err_msg));
+      AutoArchive(Archive::OpenAndLoad(ArchivePath, &Context, &err_msg));
     Archive* TheArchive = AutoArchive.get();
     if (!TheArchive)
       throw err_msg;
@@ -82,7 +86,7 @@ int main(int argc, char **argv) {
     if (Verbose)
       printSymbolTable(TheArchive);
 
-  } catch (const char*msg) {
+  } catch (const char* msg) {
     std::cerr << argv[0] << ": " << msg << "\n\n";
     exitCode = 1;
   } catch (const std::string& msg) {