llvm-objdump: Some style cleanups to follow LLVM coding style

Rename "ec" to "EC", and rename some iterators.

Then fix whitespace using clang-format-diff.

(As requested in http://llvm-reviews.chandlerc.com/D2559)

Differential Revision: http://llvm-reviews.chandlerc.com/D2594

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@200053 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Mark Seaborn
2014-01-25 00:32:01 +00:00
parent 998052555a
commit 2760cc2967

View File

@ -149,10 +149,11 @@ YAMLCFG("yaml-cfg",
static StringRef ToolName; static StringRef ToolName;
bool llvm::error(error_code ec) { bool llvm::error(error_code EC) {
if (!ec) return false; if (!EC)
return false;
outs() << ToolName << ": error reading file: " << ec.message() << ".\n"; outs() << ToolName << ": error reading file: " << EC.message() << ".\n";
outs().flush(); outs().flush();
return true; return true;
} }
@ -381,33 +382,37 @@ static void DisassembleObject(const ObjectFile *Obj, bool InlineRelocs) {
} }
} }
error_code EC;
error_code ec; for (section_iterator I = Obj->begin_sections(), E = Obj->end_sections();
for (section_iterator i = Obj->begin_sections(), I != E; I.increment(EC)) {
e = Obj->end_sections(); if (error(EC))
i != e; i.increment(ec)) { break;
if (error(ec)) break; bool Text;
bool text; if (error(I->isText(Text)))
if (error(i->isText(text))) break; break;
if (!text) continue; if (!Text)
continue;
uint64_t SectionAddr; uint64_t SectionAddr;
if (error(i->getAddress(SectionAddr))) break; if (error(I->getAddress(SectionAddr)))
break;
// Make a list of all the symbols in this section. // Make a list of all the symbols in this section.
std::vector<std::pair<uint64_t, StringRef> > Symbols; std::vector<std::pair<uint64_t, StringRef> > Symbols;
for (symbol_iterator si = Obj->begin_symbols(), for (symbol_iterator SI = Obj->begin_symbols(), SE = Obj->end_symbols();
se = Obj->end_symbols(); SI != SE; SI.increment(EC)) {
si != se; si.increment(ec)) {
bool contains; bool contains;
if (!error(i->containsSymbol(*si, contains)) && contains) { if (!error(I->containsSymbol(*SI, contains)) && contains) {
uint64_t Address; uint64_t Address;
if (error(si->getAddress(Address))) break; if (error(SI->getAddress(Address)))
if (Address == UnknownAddressOrSize) continue; break;
if (Address == UnknownAddressOrSize)
continue;
Address -= SectionAddr; Address -= SectionAddr;
StringRef Name; StringRef Name;
if (error(si->getName(Name))) break; if (error(SI->getName(Name)))
break;
Symbols.push_back(std::make_pair(Address, Name)); Symbols.push_back(std::make_pair(Address, Name));
} }
} }
@ -418,11 +423,12 @@ static void DisassembleObject(const ObjectFile *Obj, bool InlineRelocs) {
// Make a list of all the relocations for this section. // Make a list of all the relocations for this section.
std::vector<RelocationRef> Rels; std::vector<RelocationRef> Rels;
if (InlineRelocs) { if (InlineRelocs) {
for (relocation_iterator ri = i->begin_relocations(), for (relocation_iterator RI = I->begin_relocations(),
re = i->end_relocations(); RE = I->end_relocations();
ri != re; ri.increment(ec)) { RI != RE; RI.increment(EC)) {
if (error(ec)) break; if (error(EC))
Rels.push_back(*ri); break;
Rels.push_back(*RI);
} }
} }
@ -430,13 +436,13 @@ static void DisassembleObject(const ObjectFile *Obj, bool InlineRelocs) {
std::sort(Rels.begin(), Rels.end(), RelocAddressLess); std::sort(Rels.begin(), Rels.end(), RelocAddressLess);
StringRef SegmentName = ""; StringRef SegmentName = "";
if (const MachOObjectFile *MachO = if (const MachOObjectFile *MachO = dyn_cast<const MachOObjectFile>(Obj)) {
dyn_cast<const MachOObjectFile>(Obj)) { DataRefImpl DR = I->getRawDataRefImpl();
DataRefImpl DR = i->getRawDataRefImpl();
SegmentName = MachO->getSectionFinalSegmentName(DR); SegmentName = MachO->getSectionFinalSegmentName(DR);
} }
StringRef name; StringRef name;
if (error(i->getName(name))) break; if (error(I->getName(name)))
break;
outs() << "Disassembly of section "; outs() << "Disassembly of section ";
if (!SegmentName.empty()) if (!SegmentName.empty())
outs() << SegmentName << ","; outs() << SegmentName << ",";
@ -452,12 +458,14 @@ static void DisassembleObject(const ObjectFile *Obj, bool InlineRelocs) {
raw_svector_ostream CommentStream(Comments); raw_svector_ostream CommentStream(Comments);
StringRef Bytes; StringRef Bytes;
if (error(i->getContents(Bytes))) break; if (error(I->getContents(Bytes)))
break;
StringRefMemoryObject memoryObject(Bytes, SectionAddr); StringRefMemoryObject memoryObject(Bytes, SectionAddr);
uint64_t Size; uint64_t Size;
uint64_t Index; uint64_t Index;
uint64_t SectSize; uint64_t SectSize;
if (error(i->getSize(SectSize))) break; if (error(I->getSize(SectSize)))
break;
std::vector<RelocationRef>::const_iterator rel_cur = Rels.begin(); std::vector<RelocationRef>::const_iterator rel_cur = Rels.begin();
std::vector<RelocationRef>::const_iterator rel_end = Rels.end(); std::vector<RelocationRef>::const_iterator rel_end = Rels.end();
@ -479,9 +487,9 @@ static void DisassembleObject(const ObjectFile *Obj, bool InlineRelocs) {
outs() << '\n' << Symbols[si].second << ":\n"; outs() << '\n' << Symbols[si].second << ":\n";
#ifndef NDEBUG #ifndef NDEBUG
raw_ostream &DebugOut = DebugFlag ? dbgs() : nulls(); raw_ostream &DebugOut = DebugFlag ? dbgs() : nulls();
#else #else
raw_ostream &DebugOut = nulls(); raw_ostream &DebugOut = nulls();
#endif #endif
for (Index = Start; Index < End; Index += Size) { for (Index = Start; Index < End; Index += Size) {
@ -534,10 +542,11 @@ static void DisassembleObject(const ObjectFile *Obj, bool InlineRelocs) {
} }
static void PrintRelocations(const ObjectFile *o) { static void PrintRelocations(const ObjectFile *o) {
error_code ec; error_code EC;
for (section_iterator si = o->begin_sections(), se = o->end_sections(); for (section_iterator si = o->begin_sections(), se = o->end_sections();
si != se; si.increment(ec)){ si != se; si.increment(EC)) {
if (error(ec)) return; if (error(EC))
return;
if (si->begin_relocations() == si->end_relocations()) if (si->begin_relocations() == si->end_relocations())
continue; continue;
StringRef secname; StringRef secname;
@ -545,8 +554,9 @@ static void PrintRelocations(const ObjectFile *o) {
outs() << "RELOCATION RECORDS FOR [" << secname << "]:\n"; outs() << "RELOCATION RECORDS FOR [" << secname << "]:\n";
for (relocation_iterator ri = si->begin_relocations(), for (relocation_iterator ri = si->begin_relocations(),
re = si->end_relocations(); re = si->end_relocations();
ri != re; ri.increment(ec)) { ri != re; ri.increment(EC)) {
if (error(ec)) return; if (error(EC))
return;
bool hidden; bool hidden;
uint64_t address; uint64_t address;
@ -566,13 +576,15 @@ static void PrintRelocations(const ObjectFile *o) {
static void PrintSectionHeaders(const ObjectFile *o) { static void PrintSectionHeaders(const ObjectFile *o) {
outs() << "Sections:\n" outs() << "Sections:\n"
"Idx Name Size Address Type\n"; "Idx Name Size Address Type\n";
error_code ec; error_code EC;
unsigned i = 0; unsigned i = 0;
for (section_iterator si = o->begin_sections(), se = o->end_sections(); for (section_iterator si = o->begin_sections(), se = o->end_sections();
si != se; si.increment(ec)) { si != se; si.increment(EC)) {
if (error(ec)) return; if (error(EC))
return;
StringRef Name; StringRef Name;
if (error(si->getName(Name))) return; if (error(si->getName(Name)))
return;
uint64_t Address; uint64_t Address;
if (error(si->getAddress(Address))) return; if (error(si->getAddress(Address))) return;
uint64_t Size; uint64_t Size;
@ -590,11 +602,11 @@ static void PrintSectionHeaders(const ObjectFile *o) {
} }
static void PrintSectionContents(const ObjectFile *o) { static void PrintSectionContents(const ObjectFile *o) {
error_code ec; error_code EC;
for (section_iterator si = o->begin_sections(), for (section_iterator si = o->begin_sections(), se = o->end_sections();
se = o->end_sections(); si != se; si.increment(EC)) {
si != se; si.increment(ec)) { if (error(EC))
if (error(ec)) return; return;
StringRef Name; StringRef Name;
StringRef Contents; StringRef Contents;
uint64_t BaseAddr; uint64_t BaseAddr;
@ -685,10 +697,11 @@ static void PrintSymbolTable(const ObjectFile *o) {
if (const COFFObjectFile *coff = dyn_cast<const COFFObjectFile>(o)) if (const COFFObjectFile *coff = dyn_cast<const COFFObjectFile>(o))
PrintCOFFSymbolTable(coff); PrintCOFFSymbolTable(coff);
else { else {
error_code ec; error_code EC;
for (symbol_iterator si = o->begin_symbols(), for (symbol_iterator si = o->begin_symbols(), se = o->end_symbols();
se = o->end_symbols(); si != se; si.increment(ec)) { si != se; si.increment(EC)) {
if (error(ec)) return; if (error(EC))
return;
StringRef Name; StringRef Name;
uint64_t Address; uint64_t Address;
SymbolRef::Type Type; SymbolRef::Type Type;
@ -801,13 +814,13 @@ static void DumpObject(const ObjectFile *o) {
/// @brief Dump each object file in \a a; /// @brief Dump each object file in \a a;
static void DumpArchive(const Archive *a) { static void DumpArchive(const Archive *a) {
for (Archive::child_iterator i = a->child_begin(), for (Archive::child_iterator i = a->child_begin(), e = a->child_end(); i != e;
e = a->child_end(); i != e; ++i) { ++i) {
OwningPtr<Binary> child; OwningPtr<Binary> child;
if (error_code ec = i->getAsBinary(child)) { if (error_code EC = i->getAsBinary(child)) {
// Ignore non-object files. // Ignore non-object files.
if (ec != object_error::invalid_file_type) if (EC != object_error::invalid_file_type)
errs() << ToolName << ": '" << a->getFileName() << "': " << ec.message() errs() << ToolName << ": '" << a->getFileName() << "': " << EC.message()
<< ".\n"; << ".\n";
continue; continue;
} }