From: Rafael Espindola Date: Mon, 31 Dec 2012 15:27:42 +0000 (+0000) Subject: Style fixes in llvm-readobj.cpp. Extracted from a patch by Sami Liedes! X-Git-Url: http://plrg.eecs.uci.edu/git/?a=commitdiff_plain;h=663cebc4ad5ac5ad77ac051cbb925a126bba2c23;p=oota-llvm.git Style fixes in llvm-readobj.cpp. Extracted from a patch by Sami Liedes! git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@171299 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/tools/llvm-readobj/llvm-readobj.cpp b/tools/llvm-readobj/llvm-readobj.cpp index 40e3b8c933b..a30b0a8a572 100644 --- a/tools/llvm-readobj/llvm-readobj.cpp +++ b/tools/llvm-readobj/llvm-readobj.cpp @@ -33,17 +33,7 @@ using namespace llvm::object; static cl::opt InputFilename(cl::Positional, cl::desc(""), cl::init("")); -void DumpSymbolHeader() { - outs() << format(" %-32s", (const char*)"Name") - << format(" %-4s", (const char*)"Type") - << format(" %-16s", (const char*)"Address") - << format(" %-16s", (const char*)"Size") - << format(" %-16s", (const char*)"FileOffset") - << format(" %-26s", (const char*)"Flags") - << "\n"; -} - -const char *GetTypeStr(SymbolRef::Type Type) { +static const char *getTypeStr(SymbolRef::Type Type) { switch (Type) { case SymbolRef::ST_Unknown: return "?"; case SymbolRef::ST_Data: return "DATA"; @@ -55,7 +45,7 @@ const char *GetTypeStr(SymbolRef::Type Type) { return "INV"; } -std::string GetFlagStr(uint32_t Flags) { +static std::string getSymbolFlagStr(uint32_t Flags) { std::string result; if (Flags & SymbolRef::SF_Undefined) result += "undef,"; @@ -79,7 +69,8 @@ std::string GetFlagStr(uint32_t Flags) { return result; } -void DumpSymbol(const SymbolRef &Sym, const ObjectFile *obj, bool IsDynamic) { +static void +dumpSymbol(const SymbolRef &Sym, const ObjectFile *obj, bool IsDynamic) { StringRef Name; SymbolRef::Type Type; uint32_t Flags; @@ -108,24 +99,23 @@ void DumpSymbol(const SymbolRef &Sym, const ObjectFile *obj, bool IsDynamic) { // format() can't handle StringRefs outs() << format(" %-32s", FullName.c_str()) - << format(" %-4s", GetTypeStr(Type)) + << format(" %-4s", getTypeStr(Type)) << format(" %16" PRIx64, Address) << format(" %16" PRIx64, Size) << format(" %16" PRIx64, FileOffset) - << " " << GetFlagStr(Flags) + << " " << getSymbolFlagStr(Flags) << "\n"; } - // Iterate through the normal symbols in the ObjectFile -void DumpSymbols(const ObjectFile *obj) { +static void dumpSymbols(const ObjectFile *obj) { error_code ec; uint32_t count = 0; outs() << "Symbols:\n"; symbol_iterator it = obj->begin_symbols(); symbol_iterator ie = obj->end_symbols(); while (it != ie) { - DumpSymbol(*it, obj, false); + dumpSymbol(*it, obj, false); it.increment(ec); if (ec) report_fatal_error("Symbol iteration failed"); @@ -135,14 +125,14 @@ void DumpSymbols(const ObjectFile *obj) { } // Iterate through the dynamic symbols in the ObjectFile. -void DumpDynamicSymbols(const ObjectFile *obj) { +static void dumpDynamicSymbols(const ObjectFile *obj) { error_code ec; uint32_t count = 0; outs() << "Dynamic Symbols:\n"; symbol_iterator it = obj->begin_dynamic_symbols(); symbol_iterator ie = obj->end_dynamic_symbols(); while (it != ie) { - DumpSymbol(*it, obj, true); + dumpSymbol(*it, obj, true); it.increment(ec); if (ec) report_fatal_error("Symbol iteration failed"); @@ -151,21 +141,21 @@ void DumpDynamicSymbols(const ObjectFile *obj) { outs() << " Total: " << count << "\n\n"; } -void DumpLibrary(const LibraryRef &lib) { +static void dumpLibrary(const LibraryRef &lib) { StringRef path; lib.getPath(path); outs() << " " << path << "\n"; } // Iterate through needed libraries -void DumpLibrariesNeeded(const ObjectFile *obj) { +static void dumpLibrariesNeeded(const ObjectFile *obj) { error_code ec; uint32_t count = 0; library_iterator it = obj->begin_libraries_needed(); library_iterator ie = obj->end_libraries_needed(); outs() << "Libraries needed:\n"; while (it != ie) { - DumpLibrary(*it); + dumpLibrary(*it); it.increment(ec); if (ec) report_fatal_error("Needed libraries iteration failed"); @@ -174,7 +164,7 @@ void DumpLibrariesNeeded(const ObjectFile *obj) { outs() << " Total: " << count << "\n\n"; } -void DumpHeaders(const ObjectFile *obj) { +static void dumpHeaders(const ObjectFile *obj) { outs() << "File Format : " << obj->getFileFormatName() << "\n"; outs() << "Arch : " << Triple::getArchTypeName((llvm::Triple::ArchType)obj->getArch()) @@ -209,10 +199,10 @@ int main(int argc, char** argv) { errs() << InputFilename << ": Object type not recognized\n"; } - DumpHeaders(obj); - DumpSymbols(obj); - DumpDynamicSymbols(obj); - DumpLibrariesNeeded(obj); + dumpHeaders(obj); + dumpSymbols(obj); + dumpDynamicSymbols(obj); + dumpLibrariesNeeded(obj); return 0; }