aboutsummaryrefslogtreecommitdiff
path: root/llvm/tools/llvm-objdump/llvm-objdump.cpp
diff options
context:
space:
mode:
authorFangrui Song <maskray@google.com>2020-05-30 18:00:14 -0700
committerFangrui Song <maskray@google.com>2020-05-30 18:00:15 -0700
commit439d27d79f58282b618881142244bbdcb1f28345 (patch)
tree705defe9deec8c81c99bf2053fac1f5f93604ca7 /llvm/tools/llvm-objdump/llvm-objdump.cpp
parenta23d1e9aff4d8cb752e227b3e16f887cf49c15d4 (diff)
downloadllvm-439d27d79f58282b618881142244bbdcb1f28345.zip
llvm-439d27d79f58282b618881142244bbdcb1f28345.tar.gz
llvm-439d27d79f58282b618881142244bbdcb1f28345.tar.bz2
[llvm-objdump] Move llvm:: to llvm::objdump:: and qualifying definitions with objdump::
Or adding `static`. Qualifying definitions with `objdump::` comforms to the coding standards https://llvm.org/docs/CodingStandards.html#use-namespace-qualifiers-to-implement-previously-declared-functions
Diffstat (limited to 'llvm/tools/llvm-objdump/llvm-objdump.cpp')
-rw-r--r--llvm/tools/llvm-objdump/llvm-objdump.cpp48
1 files changed, 26 insertions, 22 deletions
diff --git a/llvm/tools/llvm-objdump/llvm-objdump.cpp b/llvm/tools/llvm-objdump/llvm-objdump.cpp
index d62839a..2416ffc 100644
--- a/llvm/tools/llvm-objdump/llvm-objdump.cpp
+++ b/llvm/tools/llvm-objdump/llvm-objdump.cpp
@@ -388,7 +388,8 @@ static FilterResult checkSectionFilter(object::SectionRef S) {
namespace llvm {
-SectionFilter ToolSectionFilter(object::ObjectFile const &O, uint64_t *Idx) {
+SectionFilter objdump::ToolSectionFilter(object::ObjectFile const &O,
+ uint64_t *Idx) {
// Start at UINT64_MAX so that the first index returned after an increment is
// zero (after the unsigned wrap).
if (Idx)
@@ -403,8 +404,8 @@ SectionFilter ToolSectionFilter(object::ObjectFile const &O, uint64_t *Idx) {
O);
}
-std::string getFileNameForError(const object::Archive::Child &C,
- unsigned Index) {
+std::string objdump::getFileNameForError(const object::Archive::Child &C,
+ unsigned Index) {
Expected<StringRef> NameOrErr = C.getName();
if (NameOrErr)
return std::string(NameOrErr.get());
@@ -414,7 +415,7 @@ std::string getFileNameForError(const object::Archive::Child &C,
return "<file index: " + std::to_string(Index) + ">";
}
-void reportWarning(Twine Message, StringRef File) {
+void objdump::reportWarning(Twine Message, StringRef File) {
// Output order between errs() and outs() matters especially for archive
// files where the output is per member object.
outs().flush();
@@ -422,15 +423,16 @@ void reportWarning(Twine Message, StringRef File) {
<< "'" << File << "': " << Message << "\n";
}
-LLVM_ATTRIBUTE_NORETURN void reportError(StringRef File, Twine Message) {
+LLVM_ATTRIBUTE_NORETURN void objdump::reportError(StringRef File,
+ Twine Message) {
outs().flush();
WithColor::error(errs(), ToolName) << "'" << File << "': " << Message << "\n";
exit(1);
}
-LLVM_ATTRIBUTE_NORETURN void reportError(Error E, StringRef FileName,
- StringRef ArchiveName,
- StringRef ArchitectureName) {
+LLVM_ATTRIBUTE_NORETURN void objdump::reportError(Error E, StringRef FileName,
+ StringRef ArchiveName,
+ StringRef ArchitectureName) {
assert(E);
outs().flush();
WithColor::error(errs(), ToolName);
@@ -495,7 +497,7 @@ static const Target *getTarget(const ObjectFile *Obj) {
return TheTarget;
}
-bool isRelocAddressLess(RelocationRef A, RelocationRef B) {
+bool objdump::isRelocAddressLess(RelocationRef A, RelocationRef B) {
return A.getOffset() < B.getOffset();
}
@@ -1149,7 +1151,8 @@ static void dumpELFData(uint64_t SectionAddr, uint64_t Index, uint64_t End,
}
}
-SymbolInfoTy createSymbolInfo(const ObjectFile *Obj, const SymbolRef &Symbol) {
+SymbolInfoTy objdump::createSymbolInfo(const ObjectFile *Obj,
+ const SymbolRef &Symbol) {
const StringRef FileName = Obj->getFileName();
const uint64_t Addr = unwrapOrError(Symbol.getAddress(), FileName);
const StringRef Name = unwrapOrError(Symbol.getName(), FileName);
@@ -1169,8 +1172,9 @@ SymbolInfoTy createSymbolInfo(const ObjectFile *Obj, const SymbolRef &Symbol) {
: (uint8_t)ELF::STT_NOTYPE);
}
-SymbolInfoTy createDummySymbolInfo(const ObjectFile *Obj, const uint64_t Addr,
- StringRef &Name, uint8_t Type) {
+static SymbolInfoTy createDummySymbolInfo(const ObjectFile *Obj,
+ const uint64_t Addr, StringRef &Name,
+ uint8_t Type) {
if (Obj->isXCOFF() && SymbolDescription)
return SymbolInfoTy(Addr, Name, None, None, false);
else
@@ -1713,7 +1717,7 @@ static void disassembleObject(const ObjectFile *Obj, bool InlineRelocs) {
SP, InlineRelocs);
}
-void printRelocations(const ObjectFile *Obj) {
+void objdump::printRelocations(const ObjectFile *Obj) {
StringRef Fmt = Obj->getBytesInAddress() > 4 ? "%016" PRIx64 :
"%08" PRIx64;
// Regular objdump doesn't print relocations in non-relocatable object
@@ -1767,7 +1771,7 @@ void printRelocations(const ObjectFile *Obj) {
}
}
-void printDynamicRelocations(const ObjectFile *Obj) {
+void objdump::printDynamicRelocations(const ObjectFile *Obj) {
// For the moment, this option is for ELF only
if (!Obj->isELF())
return;
@@ -1819,7 +1823,7 @@ static size_t getMaxSectionNameWidth(const ObjectFile *Obj) {
return MaxWidth;
}
-void printSectionHeaders(const ObjectFile *Obj) {
+void objdump::printSectionHeaders(const ObjectFile *Obj) {
size_t NameWidth = getMaxSectionNameWidth(Obj);
size_t AddressWidth = 2 * Obj->getBytesInAddress();
bool HasLMAColumn = shouldDisplayLMA(Obj);
@@ -1864,7 +1868,7 @@ void printSectionHeaders(const ObjectFile *Obj) {
outs() << "\n";
}
-void printSectionContents(const ObjectFile *Obj) {
+void objdump::printSectionContents(const ObjectFile *Obj) {
for (const SectionRef &Section : ToolSectionFilter(*Obj)) {
StringRef Name = unwrapOrError(Section.getName(), Obj->getFileName());
uint64_t BaseAddr = Section.getAddress();
@@ -1908,8 +1912,8 @@ void printSectionContents(const ObjectFile *Obj) {
}
}
-void printSymbolTable(const ObjectFile *O, StringRef ArchiveName,
- StringRef ArchitectureName, bool DumpDynamic) {
+void objdump::printSymbolTable(const ObjectFile *O, StringRef ArchiveName,
+ StringRef ArchitectureName, bool DumpDynamic) {
if (O->isCOFF() && !DumpDynamic) {
outs() << "SYMBOL TABLE:\n";
printCOFFSymbolTable(cast<const COFFObjectFile>(O));
@@ -1939,9 +1943,9 @@ void printSymbolTable(const ObjectFile *O, StringRef ArchiveName,
printSymbol(O, *I, FileName, ArchiveName, ArchitectureName, DumpDynamic);
}
-void printSymbol(const ObjectFile *O, const SymbolRef &Symbol,
- StringRef FileName, StringRef ArchiveName,
- StringRef ArchitectureName, bool DumpDynamic) {
+void objdump::printSymbol(const ObjectFile *O, const SymbolRef &Symbol,
+ StringRef FileName, StringRef ArchiveName,
+ StringRef ArchitectureName, bool DumpDynamic) {
const MachOObjectFile *MachO = dyn_cast<const MachOObjectFile>(O);
uint64_t Address = unwrapOrError(Symbol.getAddress(), FileName, ArchiveName,
ArchitectureName);
@@ -2089,7 +2093,7 @@ static void printUnwindInfo(const ObjectFile *O) {
/// Dump the raw contents of the __clangast section so the output can be piped
/// into llvm-bcanalyzer.
-void printRawClangAST(const ObjectFile *Obj) {
+static void printRawClangAST(const ObjectFile *Obj) {
if (outs().is_displayed()) {
WithColor::error(errs(), ToolName)
<< "The -raw-clang-ast option will dump the raw binary contents of "