diff options
author | Chris Lattner <sabre@nondot.org> | 2006-12-06 01:18:01 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2006-12-06 01:18:01 +0000 |
commit | c30598bc3ad792eb8cc75b188eb872a28c62ab71 (patch) | |
tree | 5636751bdd38ad434648958a350bfab3dd45a0fb /tools/llvm-nm | |
parent | bdbf5fd1c9cfa30a348596b127394fa1f4caf033 (diff) | |
download | external_llvm-c30598bc3ad792eb8cc75b188eb872a28c62ab71.zip external_llvm-c30598bc3ad792eb8cc75b188eb872a28c62ab71.tar.gz external_llvm-c30598bc3ad792eb8cc75b188eb872a28c62ab71.tar.bz2 |
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.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@32250 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'tools/llvm-nm')
-rw-r--r-- | tools/llvm-nm/llvm-nm.cpp | 30 |
1 files changed, 16 insertions, 14 deletions
diff --git a/tools/llvm-nm/llvm-nm.cpp b/tools/llvm-nm/llvm-nm.cpp index 3e43953..422cdda 100644 --- a/tools/llvm-nm/llvm-nm.cpp +++ b/tools/llvm-nm/llvm-nm.cpp @@ -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 @@ namespace { 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 DumpSymbolNameForGlobalValue (GlobalValue &GV) { } } -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 @@ void DumpSymbolNamesFromModule (Module *M) { 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 @@ void DumpSymbolNamesFromFile (std::string &Filename) { } } 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 @@ void DumpSymbolNamesFromFile (std::string &Filename) { } 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(); |