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

Chris Lattner sabre at nondot.org
Tue Dec 5 17:18:55 PST 2006



Changes in directory llvm/tools/llvm-nm:

llvm-nm.cpp updated: 1.28 -> 1.29
---
Log message:

make all llvm tools call llvm_shutdown when they exit, static'ify some stuff.

With this change, I can now move -stats to print when llvm_shutdown is called.


---
Diffs of the changes:  (+16 -14)

 llvm-nm.cpp |   30 ++++++++++++++++--------------
 1 files changed, 16 insertions(+), 14 deletions(-)


Index: llvm/tools/llvm-nm/llvm-nm.cpp
diff -u llvm/tools/llvm-nm/llvm-nm.cpp:1.28 llvm/tools/llvm-nm/llvm-nm.cpp:1.29
--- llvm/tools/llvm-nm/llvm-nm.cpp:1.28	Tue Aug  1 13:22:21 2006
+++ llvm/tools/llvm-nm/llvm-nm.cpp	Tue Dec  5 19:18:01 2006
@@ -20,6 +20,7 @@
 #include "llvm/Bytecode/Reader.h"
 #include "llvm/Bytecode/Archive.h"
 #include "llvm/Support/CommandLine.h"
+#include "llvm/Support/ManagedStatic.h"
 #include "llvm/System/Signals.h"
 #include <cctype>
 #include <cerrno>
@@ -65,18 +66,18 @@
   std::string ToolName;
 }
 
-char TypeCharForSymbol (GlobalValue &GV) {
-  if (GV.isExternal ())                                     return 'U';
-  if (GV.hasLinkOnceLinkage ())                             return 'C';
-  if (GV.hasWeakLinkage ())                                 return 'W';
-  if (isa<Function> (GV) && GV.hasInternalLinkage ())       return 't';
-  if (isa<Function> (GV))                                   return 'T';
-  if (isa<GlobalVariable> (GV) && GV.hasInternalLinkage ()) return 'd';
-  if (isa<GlobalVariable> (GV))                             return 'D';
+static char TypeCharForSymbol(GlobalValue &GV) {
+  if (GV.isExternal())                                     return 'U';
+  if (GV.hasLinkOnceLinkage())                             return 'C';
+  if (GV.hasWeakLinkage())                                 return 'W';
+  if (isa<Function>(GV) && GV.hasInternalLinkage())       return 't';
+  if (isa<Function>(GV))                                   return 'T';
+  if (isa<GlobalVariable>(GV) && GV.hasInternalLinkage()) return 'd';
+  if (isa<GlobalVariable>(GV))                             return 'D';
                                                             return '?';
 }
 
-void DumpSymbolNameForGlobalValue (GlobalValue &GV) {
+static void DumpSymbolNameForGlobalValue(GlobalValue &GV) {
   const std::string SymbolAddrStr = "        "; // Not used yet...
   char TypeChar = TypeCharForSymbol (GV);
   if ((TypeChar != 'U') && UndefinedOnly)
@@ -101,7 +102,7 @@
   }
 }
 
-void DumpSymbolNamesFromModule (Module *M) {
+static void DumpSymbolNamesFromModule(Module *M) {
   const std::string &Filename = M->getModuleIdentifier ();
   if (OutputFormat == posix && MultipleFiles) {
     std::cout << Filename << ":\n";
@@ -116,7 +117,7 @@
   std::for_each (M->global_begin (), M->global_end (), DumpSymbolNameForGlobalValue);
 }
 
-void DumpSymbolNamesFromFile (std::string &Filename) {
+static void DumpSymbolNamesFromFile(std::string &Filename) {
   std::string ErrorMessage;
   sys::Path aPath(Filename);
   if (Filename != "-") {
@@ -135,16 +136,16 @@
     }
   } else if (aPath.isArchive()) {
     std::string ErrMsg;
-    Archive* archive = Archive::OpenAndLoad(sys::Path(Filename),&ErrorMessage);
+    Archive* archive = Archive::OpenAndLoad(sys::Path(Filename), &ErrorMessage);
     if (!archive)
       std::cerr << ToolName << ": " << Filename << ": " << ErrorMessage << "\n";
     std::vector<Module *> Modules;
-    if (archive->getAllModules(Modules,&ErrorMessage)) {
+    if (archive->getAllModules(Modules, &ErrorMessage)) {
       std::cerr << ToolName << ": " << Filename << ": " << ErrorMessage << "\n";
       return;
     }
     MultipleFiles = true;
-    std::for_each (Modules.begin (), Modules.end (), DumpSymbolNamesFromModule);
+    std::for_each (Modules.begin(), Modules.end(), DumpSymbolNamesFromModule);
   } else {
     std::cerr << ToolName << ": " << Filename << ": "
               << "unrecognizable file type\n";
@@ -153,6 +154,7 @@
 }
 
 int main(int argc, char **argv) {
+  llvm_shutdown_obj X;  // Call llvm_shutdown() on exit.
   try {
     cl::ParseCommandLineOptions(argc, argv, " llvm symbol table dumper\n");
     sys::PrintStackTraceOnErrorSignal();






More information about the llvm-commits mailing list