mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-02-28 09:31:03 +00:00
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:
parent
998052555a
commit
2760cc2967
@ -149,10 +149,11 @@ YAMLCFG("yaml-cfg",
|
||||
|
||||
static StringRef ToolName;
|
||||
|
||||
bool llvm::error(error_code ec) {
|
||||
if (!ec) return false;
|
||||
bool llvm::error(error_code EC) {
|
||||
if (!EC)
|
||||
return false;
|
||||
|
||||
outs() << ToolName << ": error reading file: " << ec.message() << ".\n";
|
||||
outs() << ToolName << ": error reading file: " << EC.message() << ".\n";
|
||||
outs().flush();
|
||||
return true;
|
||||
}
|
||||
@ -381,33 +382,37 @@ static void DisassembleObject(const ObjectFile *Obj, bool InlineRelocs) {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
error_code ec;
|
||||
for (section_iterator i = Obj->begin_sections(),
|
||||
e = Obj->end_sections();
|
||||
i != e; i.increment(ec)) {
|
||||
if (error(ec)) break;
|
||||
bool text;
|
||||
if (error(i->isText(text))) break;
|
||||
if (!text) continue;
|
||||
error_code EC;
|
||||
for (section_iterator I = Obj->begin_sections(), E = Obj->end_sections();
|
||||
I != E; I.increment(EC)) {
|
||||
if (error(EC))
|
||||
break;
|
||||
bool Text;
|
||||
if (error(I->isText(Text)))
|
||||
break;
|
||||
if (!Text)
|
||||
continue;
|
||||
|
||||
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.
|
||||
std::vector<std::pair<uint64_t, StringRef> > Symbols;
|
||||
for (symbol_iterator si = Obj->begin_symbols(),
|
||||
se = Obj->end_symbols();
|
||||
si != se; si.increment(ec)) {
|
||||
for (symbol_iterator SI = Obj->begin_symbols(), SE = Obj->end_symbols();
|
||||
SI != SE; SI.increment(EC)) {
|
||||
bool contains;
|
||||
if (!error(i->containsSymbol(*si, contains)) && contains) {
|
||||
if (!error(I->containsSymbol(*SI, contains)) && contains) {
|
||||
uint64_t Address;
|
||||
if (error(si->getAddress(Address))) break;
|
||||
if (Address == UnknownAddressOrSize) continue;
|
||||
if (error(SI->getAddress(Address)))
|
||||
break;
|
||||
if (Address == UnknownAddressOrSize)
|
||||
continue;
|
||||
Address -= SectionAddr;
|
||||
|
||||
StringRef Name;
|
||||
if (error(si->getName(Name))) break;
|
||||
if (error(SI->getName(Name)))
|
||||
break;
|
||||
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.
|
||||
std::vector<RelocationRef> Rels;
|
||||
if (InlineRelocs) {
|
||||
for (relocation_iterator ri = i->begin_relocations(),
|
||||
re = i->end_relocations();
|
||||
ri != re; ri.increment(ec)) {
|
||||
if (error(ec)) break;
|
||||
Rels.push_back(*ri);
|
||||
for (relocation_iterator RI = I->begin_relocations(),
|
||||
RE = I->end_relocations();
|
||||
RI != RE; RI.increment(EC)) {
|
||||
if (error(EC))
|
||||
break;
|
||||
Rels.push_back(*RI);
|
||||
}
|
||||
}
|
||||
|
||||
@ -430,13 +436,13 @@ static void DisassembleObject(const ObjectFile *Obj, bool InlineRelocs) {
|
||||
std::sort(Rels.begin(), Rels.end(), RelocAddressLess);
|
||||
|
||||
StringRef SegmentName = "";
|
||||
if (const MachOObjectFile *MachO =
|
||||
dyn_cast<const MachOObjectFile>(Obj)) {
|
||||
DataRefImpl DR = i->getRawDataRefImpl();
|
||||
if (const MachOObjectFile *MachO = dyn_cast<const MachOObjectFile>(Obj)) {
|
||||
DataRefImpl DR = I->getRawDataRefImpl();
|
||||
SegmentName = MachO->getSectionFinalSegmentName(DR);
|
||||
}
|
||||
StringRef name;
|
||||
if (error(i->getName(name))) break;
|
||||
if (error(I->getName(name)))
|
||||
break;
|
||||
outs() << "Disassembly of section ";
|
||||
if (!SegmentName.empty())
|
||||
outs() << SegmentName << ",";
|
||||
@ -452,12 +458,14 @@ static void DisassembleObject(const ObjectFile *Obj, bool InlineRelocs) {
|
||||
raw_svector_ostream CommentStream(Comments);
|
||||
|
||||
StringRef Bytes;
|
||||
if (error(i->getContents(Bytes))) break;
|
||||
if (error(I->getContents(Bytes)))
|
||||
break;
|
||||
StringRefMemoryObject memoryObject(Bytes, SectionAddr);
|
||||
uint64_t Size;
|
||||
uint64_t Index;
|
||||
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_end = Rels.end();
|
||||
@ -534,10 +542,11 @@ static void DisassembleObject(const ObjectFile *Obj, bool InlineRelocs) {
|
||||
}
|
||||
|
||||
static void PrintRelocations(const ObjectFile *o) {
|
||||
error_code ec;
|
||||
error_code EC;
|
||||
for (section_iterator si = o->begin_sections(), se = o->end_sections();
|
||||
si != se; si.increment(ec)){
|
||||
if (error(ec)) return;
|
||||
si != se; si.increment(EC)) {
|
||||
if (error(EC))
|
||||
return;
|
||||
if (si->begin_relocations() == si->end_relocations())
|
||||
continue;
|
||||
StringRef secname;
|
||||
@ -545,8 +554,9 @@ static void PrintRelocations(const ObjectFile *o) {
|
||||
outs() << "RELOCATION RECORDS FOR [" << secname << "]:\n";
|
||||
for (relocation_iterator ri = si->begin_relocations(),
|
||||
re = si->end_relocations();
|
||||
ri != re; ri.increment(ec)) {
|
||||
if (error(ec)) return;
|
||||
ri != re; ri.increment(EC)) {
|
||||
if (error(EC))
|
||||
return;
|
||||
|
||||
bool hidden;
|
||||
uint64_t address;
|
||||
@ -566,13 +576,15 @@ static void PrintRelocations(const ObjectFile *o) {
|
||||
static void PrintSectionHeaders(const ObjectFile *o) {
|
||||
outs() << "Sections:\n"
|
||||
"Idx Name Size Address Type\n";
|
||||
error_code ec;
|
||||
error_code EC;
|
||||
unsigned i = 0;
|
||||
for (section_iterator si = o->begin_sections(), se = o->end_sections();
|
||||
si != se; si.increment(ec)) {
|
||||
if (error(ec)) return;
|
||||
si != se; si.increment(EC)) {
|
||||
if (error(EC))
|
||||
return;
|
||||
StringRef Name;
|
||||
if (error(si->getName(Name))) return;
|
||||
if (error(si->getName(Name)))
|
||||
return;
|
||||
uint64_t Address;
|
||||
if (error(si->getAddress(Address))) return;
|
||||
uint64_t Size;
|
||||
@ -590,11 +602,11 @@ static void PrintSectionHeaders(const ObjectFile *o) {
|
||||
}
|
||||
|
||||
static void PrintSectionContents(const ObjectFile *o) {
|
||||
error_code ec;
|
||||
for (section_iterator si = o->begin_sections(),
|
||||
se = o->end_sections();
|
||||
si != se; si.increment(ec)) {
|
||||
if (error(ec)) return;
|
||||
error_code EC;
|
||||
for (section_iterator si = o->begin_sections(), se = o->end_sections();
|
||||
si != se; si.increment(EC)) {
|
||||
if (error(EC))
|
||||
return;
|
||||
StringRef Name;
|
||||
StringRef Contents;
|
||||
uint64_t BaseAddr;
|
||||
@ -685,10 +697,11 @@ static void PrintSymbolTable(const ObjectFile *o) {
|
||||
if (const COFFObjectFile *coff = dyn_cast<const COFFObjectFile>(o))
|
||||
PrintCOFFSymbolTable(coff);
|
||||
else {
|
||||
error_code ec;
|
||||
for (symbol_iterator si = o->begin_symbols(),
|
||||
se = o->end_symbols(); si != se; si.increment(ec)) {
|
||||
if (error(ec)) return;
|
||||
error_code EC;
|
||||
for (symbol_iterator si = o->begin_symbols(), se = o->end_symbols();
|
||||
si != se; si.increment(EC)) {
|
||||
if (error(EC))
|
||||
return;
|
||||
StringRef Name;
|
||||
uint64_t Address;
|
||||
SymbolRef::Type Type;
|
||||
@ -801,13 +814,13 @@ static void DumpObject(const ObjectFile *o) {
|
||||
|
||||
/// @brief Dump each object file in \a a;
|
||||
static void DumpArchive(const Archive *a) {
|
||||
for (Archive::child_iterator i = a->child_begin(),
|
||||
e = a->child_end(); i != e; ++i) {
|
||||
for (Archive::child_iterator i = a->child_begin(), e = a->child_end(); i != e;
|
||||
++i) {
|
||||
OwningPtr<Binary> child;
|
||||
if (error_code ec = i->getAsBinary(child)) {
|
||||
if (error_code EC = i->getAsBinary(child)) {
|
||||
// Ignore non-object files.
|
||||
if (ec != object_error::invalid_file_type)
|
||||
errs() << ToolName << ": '" << a->getFileName() << "': " << ec.message()
|
||||
if (EC != object_error::invalid_file_type)
|
||||
errs() << ToolName << ": '" << a->getFileName() << "': " << EC.message()
|
||||
<< ".\n";
|
||||
continue;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user