Refactor: simplify boolean expressions in llvm-objdump

Simplify boolean expressions involving `true` and `false` with `clang-tidy`.

Actually upon inspection a bunch of these boolean variables could be
factored away entirely anyway - using find_if and then testing the
result before using it. This also helps reduce indentation in the code
anyway - and a bunch of other related simplification fell out nearby so
I just committed all of that.

Patch by Richard Thomson (legalize@xmission.com)

Differential Revision: http://reviews.llvm.org/D8517

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@232984 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
David Blaikie 2015-03-23 18:39:02 +00:00
parent 8b9cc2da07
commit c71d3d47a0
2 changed files with 230 additions and 239 deletions

View File

@ -45,7 +45,9 @@ inline bool operator<(const DataRefImpl &a, const DataRefImpl &b) {
return std::memcmp(&a, &b, sizeof(DataRefImpl)) < 0; return std::memcmp(&a, &b, sizeof(DataRefImpl)) < 0;
} }
template <class content_type> class content_iterator { template <class content_type>
class content_iterator
: public std::iterator<std::forward_iterator_tag, content_type> {
content_type Current; content_type Current;
public: public:

View File

@ -836,103 +836,103 @@ static void DumpLiteralPointerSection(MachOObjectFile *O,
} }
// First look for an external relocation entry for this literal pointer. // First look for an external relocation entry for this literal pointer.
bool reloc_found = false; auto Reloc = std::find_if(
for (unsigned j = 0, e = Relocs.size(); j != e; ++j) { Relocs.begin(), Relocs.end(),
if (Relocs[i].first == i) { [&](const std::pair<uint64_t, SymbolRef> &P) { return P.first == i; });
symbol_iterator RelocSym = Relocs[j].second; if (Reloc != Relocs.end()) {
StringRef SymName; symbol_iterator RelocSym = Reloc->second;
RelocSym->getName(SymName); StringRef SymName;
outs() << "external relocation entry for symbol:" << SymName << "\n"; RelocSym->getName(SymName);
reloc_found = true; outs() << "external relocation entry for symbol:" << SymName << "\n";
}
}
if (reloc_found == true)
continue; continue;
}
// For local references see what the section the literal pointer points to. // For local references see what the section the literal pointer points to.
bool found = false; auto Sect = std::find_if(LiteralSections.begin(), LiteralSections.end(),
for (unsigned SectIdx = 0; SectIdx != LiteralSections.size(); SectIdx++) { [&](const SectionRef &R) {
uint64_t SectAddress = LiteralSections[SectIdx].getAddress(); return lp >= R.getAddress() &&
uint64_t SectSize = LiteralSections[SectIdx].getSize(); lp < R.getAddress() + R.getSize();
if (lp >= SectAddress && lp < SectAddress + SectSize) { });
found = true; if (Sect == LiteralSections.end()) {
StringRef SectName;
LiteralSections[SectIdx].getName(SectName);
DataRefImpl Ref = LiteralSections[SectIdx].getRawDataRefImpl();
StringRef SegmentName = O->getSectionFinalSegmentName(Ref);
outs() << SegmentName << ":" << SectName << ":";
uint32_t section_type;
if (O->is64Bit()) {
const MachO::section_64 Sec = O->getSection64(Ref);
section_type = Sec.flags & MachO::SECTION_TYPE;
} else {
const MachO::section Sec = O->getSection(Ref);
section_type = Sec.flags & MachO::SECTION_TYPE;
}
StringRef BytesStr;
LiteralSections[SectIdx].getContents(BytesStr);
const char *Contents = reinterpret_cast<const char *>(BytesStr.data());
switch (section_type) {
case MachO::S_CSTRING_LITERALS:
for (uint64_t i = lp - SectAddress;
i < SectSize && Contents[i] != '\0'; i++) {
DumpCstringChar(Contents[i]);
}
outs() << "\n";
break;
case MachO::S_4BYTE_LITERALS:
float f;
memcpy(&f, Contents + (lp - SectAddress), sizeof(float));
uint32_t l;
memcpy(&l, Contents + (lp - SectAddress), sizeof(uint32_t));
if (O->isLittleEndian() != sys::IsLittleEndianHost) {
sys::swapByteOrder(f);
sys::swapByteOrder(l);
}
DumpLiteral4(l, f);
break;
case MachO::S_8BYTE_LITERALS: {
double d;
memcpy(&d, Contents + (lp - SectAddress), sizeof(double));
uint32_t l0, l1;
memcpy(&l0, Contents + (lp - SectAddress), sizeof(uint32_t));
memcpy(&l1, Contents + (lp - SectAddress) + sizeof(uint32_t),
sizeof(uint32_t));
if (O->isLittleEndian() != sys::IsLittleEndianHost) {
sys::swapByteOrder(f);
sys::swapByteOrder(l0);
sys::swapByteOrder(l1);
}
DumpLiteral8(O, l0, l1, d);
break;
}
case MachO::S_16BYTE_LITERALS: {
uint32_t l0, l1, l2, l3;
memcpy(&l0, Contents + (lp - SectAddress), sizeof(uint32_t));
memcpy(&l1, Contents + (lp - SectAddress) + sizeof(uint32_t),
sizeof(uint32_t));
memcpy(&l2, Contents + (lp - SectAddress) + 2 * sizeof(uint32_t),
sizeof(uint32_t));
memcpy(&l3, Contents + (lp - SectAddress) + 3 * sizeof(uint32_t),
sizeof(uint32_t));
if (O->isLittleEndian() != sys::IsLittleEndianHost) {
sys::swapByteOrder(l0);
sys::swapByteOrder(l1);
sys::swapByteOrder(l2);
sys::swapByteOrder(l3);
}
DumpLiteral16(l0, l1, l2, l3);
break;
}
}
}
}
if (found == false)
outs() << format("0x%" PRIx64, lp) << " (not in a literal section)\n"; outs() << format("0x%" PRIx64, lp) << " (not in a literal section)\n";
continue;
}
uint64_t SectAddress = Sect->getAddress();
uint64_t SectSize = Sect->getSize();
StringRef SectName;
Sect->getName(SectName);
DataRefImpl Ref = Sect->getRawDataRefImpl();
StringRef SegmentName = O->getSectionFinalSegmentName(Ref);
outs() << SegmentName << ":" << SectName << ":";
uint32_t section_type;
if (O->is64Bit()) {
const MachO::section_64 Sec = O->getSection64(Ref);
section_type = Sec.flags & MachO::SECTION_TYPE;
} else {
const MachO::section Sec = O->getSection(Ref);
section_type = Sec.flags & MachO::SECTION_TYPE;
}
StringRef BytesStr;
Sect->getContents(BytesStr);
const char *Contents = reinterpret_cast<const char *>(BytesStr.data());
switch (section_type) {
case MachO::S_CSTRING_LITERALS:
for (uint64_t i = lp - SectAddress; i < SectSize && Contents[i] != '\0';
i++) {
DumpCstringChar(Contents[i]);
}
outs() << "\n";
break;
case MachO::S_4BYTE_LITERALS:
float f;
memcpy(&f, Contents + (lp - SectAddress), sizeof(float));
uint32_t l;
memcpy(&l, Contents + (lp - SectAddress), sizeof(uint32_t));
if (O->isLittleEndian() != sys::IsLittleEndianHost) {
sys::swapByteOrder(f);
sys::swapByteOrder(l);
}
DumpLiteral4(l, f);
break;
case MachO::S_8BYTE_LITERALS: {
double d;
memcpy(&d, Contents + (lp - SectAddress), sizeof(double));
uint32_t l0, l1;
memcpy(&l0, Contents + (lp - SectAddress), sizeof(uint32_t));
memcpy(&l1, Contents + (lp - SectAddress) + sizeof(uint32_t),
sizeof(uint32_t));
if (O->isLittleEndian() != sys::IsLittleEndianHost) {
sys::swapByteOrder(f);
sys::swapByteOrder(l0);
sys::swapByteOrder(l1);
}
DumpLiteral8(O, l0, l1, d);
break;
}
case MachO::S_16BYTE_LITERALS: {
uint32_t l0, l1, l2, l3;
memcpy(&l0, Contents + (lp - SectAddress), sizeof(uint32_t));
memcpy(&l1, Contents + (lp - SectAddress) + sizeof(uint32_t),
sizeof(uint32_t));
memcpy(&l2, Contents + (lp - SectAddress) + 2 * sizeof(uint32_t),
sizeof(uint32_t));
memcpy(&l3, Contents + (lp - SectAddress) + 3 * sizeof(uint32_t),
sizeof(uint32_t));
if (O->isLittleEndian() != sys::IsLittleEndianHost) {
sys::swapByteOrder(l0);
sys::swapByteOrder(l1);
sys::swapByteOrder(l2);
sys::swapByteOrder(l3);
}
DumpLiteral16(l0, l1, l2, l3);
break;
}
}
} }
} }
@ -1736,7 +1736,7 @@ static int SymbolizerGetOpInfo(void *DisInfo, uint64_t Pc, uint64_t Offset,
// If the TagType is not the value 1 which it code knows about or if no // If the TagType is not the value 1 which it code knows about or if no
// verbose symbolic information is wanted then just return 0, indicating no // verbose symbolic information is wanted then just return 0, indicating no
// information is being returned. // information is being returned.
if (TagType != 1 || info->verbose == false) if (TagType != 1 || !info->verbose)
return 0; return 0;
unsigned int Arch = info->O->getArch(); unsigned int Arch = info->O->getArch();
@ -1819,7 +1819,8 @@ static int SymbolizerGetOpInfo(void *DisInfo, uint64_t Pc, uint64_t Offset,
// (if any) for an entry that matches this segment offset. // (if any) for an entry that matches this segment offset.
// uint32_t seg_offset = (Pc + Offset); // uint32_t seg_offset = (Pc + Offset);
return 0; return 0;
} else if (Arch == Triple::x86_64) { }
if (Arch == Triple::x86_64) {
if (Size != 1 && Size != 2 && Size != 4 && Size != 0) if (Size != 1 && Size != 2 && Size != 4 && Size != 0)
return 0; return 0;
// First search the section's relocation entries (if any) for an entry // First search the section's relocation entries (if any) for an entry
@ -1885,56 +1886,60 @@ static int SymbolizerGetOpInfo(void *DisInfo, uint64_t Pc, uint64_t Offset,
// (if any) for an entry that matches this segment offset. // (if any) for an entry that matches this segment offset.
// uint64_t seg_offset = (Pc + Offset); // uint64_t seg_offset = (Pc + Offset);
return 0; return 0;
} else if (Arch == Triple::arm) { }
if (Arch == Triple::arm) {
if (Offset != 0 || (Size != 4 && Size != 2)) if (Offset != 0 || (Size != 4 && Size != 2))
return 0; return 0;
// First search the section's relocation entries (if any) for an entry // First search the section's relocation entries (if any) for an entry
// for this section offset. // for this section offset.
uint32_t sect_addr = info->S.getAddress(); uint32_t sect_addr = info->S.getAddress();
uint32_t sect_offset = (Pc + Offset) - sect_addr; uint32_t sect_offset = (Pc + Offset) - sect_addr;
bool reloc_found = false;
DataRefImpl Rel; DataRefImpl Rel;
MachO::any_relocation_info RE; MachO::any_relocation_info RE;
bool isExtern = false; bool isExtern = false;
SymbolRef Symbol; SymbolRef Symbol;
bool r_scattered = false; bool r_scattered = false;
uint32_t r_value, pair_r_value, r_type, r_length, other_half; uint32_t r_value, pair_r_value, r_type, r_length, other_half;
for (const RelocationRef &Reloc : info->S.relocations()) { auto Reloc =
uint64_t RelocOffset; std::find_if(info->S.relocations().begin(), info->S.relocations().end(),
Reloc.getOffset(RelocOffset); [&](const RelocationRef &Reloc) {
if (RelocOffset == sect_offset) { uint64_t RelocOffset;
Rel = Reloc.getRawDataRefImpl(); Reloc.getOffset(RelocOffset);
RE = info->O->getRelocation(Rel); return RelocOffset == sect_offset;
r_length = info->O->getAnyRelocationLength(RE); });
r_scattered = info->O->isRelocationScattered(RE);
if (r_scattered) { if (Reloc == info->S.relocations().end())
r_value = info->O->getScatteredRelocationValue(RE); return 0;
r_type = info->O->getScatteredRelocationType(RE);
} else { Rel = Reloc->getRawDataRefImpl();
r_type = info->O->getAnyRelocationType(RE); RE = info->O->getRelocation(Rel);
isExtern = info->O->getPlainRelocationExternal(RE); r_length = info->O->getAnyRelocationLength(RE);
if (isExtern) { r_scattered = info->O->isRelocationScattered(RE);
symbol_iterator RelocSym = Reloc.getSymbol(); if (r_scattered) {
Symbol = *RelocSym; r_value = info->O->getScatteredRelocationValue(RE);
} r_type = info->O->getScatteredRelocationType(RE);
} } else {
if (r_type == MachO::ARM_RELOC_HALF || r_type = info->O->getAnyRelocationType(RE);
r_type == MachO::ARM_RELOC_SECTDIFF || isExtern = info->O->getPlainRelocationExternal(RE);
r_type == MachO::ARM_RELOC_LOCAL_SECTDIFF || if (isExtern) {
r_type == MachO::ARM_RELOC_HALF_SECTDIFF) { symbol_iterator RelocSym = Reloc->getSymbol();
DataRefImpl RelNext = Rel; Symbol = *RelocSym;
info->O->moveRelocationNext(RelNext);
MachO::any_relocation_info RENext;
RENext = info->O->getRelocation(RelNext);
other_half = info->O->getAnyRelocationAddress(RENext) & 0xffff;
if (info->O->isRelocationScattered(RENext))
pair_r_value = info->O->getScatteredRelocationValue(RENext);
}
reloc_found = true;
break;
} }
} }
if (reloc_found && isExtern) { if (r_type == MachO::ARM_RELOC_HALF ||
r_type == MachO::ARM_RELOC_SECTDIFF ||
r_type == MachO::ARM_RELOC_LOCAL_SECTDIFF ||
r_type == MachO::ARM_RELOC_HALF_SECTDIFF) {
DataRefImpl RelNext = Rel;
info->O->moveRelocationNext(RelNext);
MachO::any_relocation_info RENext;
RENext = info->O->getRelocation(RelNext);
other_half = info->O->getAnyRelocationAddress(RENext) & 0xffff;
if (info->O->isRelocationScattered(RENext))
pair_r_value = info->O->getScatteredRelocationValue(RENext);
}
if (isExtern) {
StringRef SymName; StringRef SymName;
Symbol.getName(SymName); Symbol.getName(SymName);
const char *name = SymName.data(); const char *name = SymName.data();
@ -1959,27 +1964,25 @@ static int SymbolizerGetOpInfo(void *DisInfo, uint64_t Pc, uint64_t Offset,
// return 0 so the code in tryAddingSymbolicOperand() can use the // return 0 so the code in tryAddingSymbolicOperand() can use the
// SymbolLookUp call back with the branch target address to look up the // SymbolLookUp call back with the branch target address to look up the
// symbol and possiblity add an annotation for a symbol stub. // symbol and possiblity add an annotation for a symbol stub.
if (reloc_found && isExtern == 0 && (r_type == MachO::ARM_RELOC_BR24 || if (isExtern == 0 && (r_type == MachO::ARM_RELOC_BR24 ||
r_type == MachO::ARM_THUMB_RELOC_BR22)) r_type == MachO::ARM_THUMB_RELOC_BR22))
return 0; return 0;
uint32_t offset = 0; uint32_t offset = 0;
if (reloc_found) { if (r_type == MachO::ARM_RELOC_HALF ||
if (r_type == MachO::ARM_RELOC_HALF || r_type == MachO::ARM_RELOC_HALF_SECTDIFF) {
r_type == MachO::ARM_RELOC_HALF_SECTDIFF) { if ((r_length & 0x1) == 1)
if ((r_length & 0x1) == 1) value = value << 16 | other_half;
value = value << 16 | other_half; else
else value = other_half << 16 | value;
value = other_half << 16 | value; }
} if (r_scattered && (r_type != MachO::ARM_RELOC_HALF &&
if (r_scattered && (r_type != MachO::ARM_RELOC_HALF && r_type != MachO::ARM_RELOC_HALF_SECTDIFF)) {
r_type != MachO::ARM_RELOC_HALF_SECTDIFF)) { offset = value - r_value;
offset = value - r_value; value = r_value;
value = r_value;
}
} }
if (reloc_found && r_type == MachO::ARM_RELOC_HALF_SECTDIFF) { if (r_type == MachO::ARM_RELOC_HALF_SECTDIFF) {
if ((r_length & 0x1) == 1) if ((r_length & 0x1) == 1)
op_info->VariantKind = LLVMDisassembler_VariantKind_ARM_HI16; op_info->VariantKind = LLVMDisassembler_VariantKind_ARM_HI16;
else else
@ -2001,18 +2004,13 @@ static int SymbolizerGetOpInfo(void *DisInfo, uint64_t Pc, uint64_t Offset,
return 1; return 1;
} }
if (reloc_found == false)
return 0;
op_info->AddSymbol.Present = 1; op_info->AddSymbol.Present = 1;
op_info->Value = offset; op_info->Value = offset;
if (reloc_found) { if (r_type == MachO::ARM_RELOC_HALF) {
if (r_type == MachO::ARM_RELOC_HALF) { if ((r_length & 0x1) == 1)
if ((r_length & 0x1) == 1) op_info->VariantKind = LLVMDisassembler_VariantKind_ARM_HI16;
op_info->VariantKind = LLVMDisassembler_VariantKind_ARM_HI16; else
else op_info->VariantKind = LLVMDisassembler_VariantKind_ARM_LO16;
op_info->VariantKind = LLVMDisassembler_VariantKind_ARM_LO16;
}
} }
const char *add = GuessSymbolName(value, info->AddrMap); const char *add = GuessSymbolName(value, info->AddrMap);
if (add != nullptr) { if (add != nullptr) {
@ -2021,88 +2019,79 @@ static int SymbolizerGetOpInfo(void *DisInfo, uint64_t Pc, uint64_t Offset,
} }
op_info->AddSymbol.Value = value; op_info->AddSymbol.Value = value;
return 1; return 1;
} else if (Arch == Triple::aarch64) { }
if (Arch == Triple::aarch64) {
if (Offset != 0 || Size != 4) if (Offset != 0 || Size != 4)
return 0; return 0;
// First search the section's relocation entries (if any) for an entry // First search the section's relocation entries (if any) for an entry
// for this section offset. // for this section offset.
uint64_t sect_addr = info->S.getAddress(); uint64_t sect_addr = info->S.getAddress();
uint64_t sect_offset = (Pc + Offset) - sect_addr; uint64_t sect_offset = (Pc + Offset) - sect_addr;
bool reloc_found = false; auto Reloc =
DataRefImpl Rel; std::find_if(info->S.relocations().begin(), info->S.relocations().end(),
MachO::any_relocation_info RE; [&](const RelocationRef &Reloc) {
bool isExtern = false; uint64_t RelocOffset;
SymbolRef Symbol; Reloc.getOffset(RelocOffset);
uint32_t r_type = 0; return RelocOffset == sect_offset;
for (const RelocationRef &Reloc : info->S.relocations()) { });
uint64_t RelocOffset;
Reloc.getOffset(RelocOffset);
if (RelocOffset == sect_offset) {
Rel = Reloc.getRawDataRefImpl();
RE = info->O->getRelocation(Rel);
r_type = info->O->getAnyRelocationType(RE);
if (r_type == MachO::ARM64_RELOC_ADDEND) {
DataRefImpl RelNext = Rel;
info->O->moveRelocationNext(RelNext);
MachO::any_relocation_info RENext = info->O->getRelocation(RelNext);
if (value == 0) {
value = info->O->getPlainRelocationSymbolNum(RENext);
op_info->Value = value;
}
}
// NOTE: Scattered relocations don't exist on arm64.
isExtern = info->O->getPlainRelocationExternal(RE);
if (isExtern) {
symbol_iterator RelocSym = Reloc.getSymbol();
Symbol = *RelocSym;
}
reloc_found = true;
break;
}
}
if (reloc_found && isExtern) {
StringRef SymName;
Symbol.getName(SymName);
const char *name = SymName.data();
op_info->AddSymbol.Present = 1;
op_info->AddSymbol.Name = name;
switch (r_type) { if (Reloc == info->S.relocations().end())
case MachO::ARM64_RELOC_PAGE21: return 0;
/* @page */
op_info->VariantKind = LLVMDisassembler_VariantKind_ARM64_PAGE; DataRefImpl Rel = Reloc->getRawDataRefImpl();
break; MachO::any_relocation_info RE = info->O->getRelocation(Rel);
case MachO::ARM64_RELOC_PAGEOFF12: uint32_t r_type = info->O->getAnyRelocationType(RE);
/* @pageoff */ if (r_type == MachO::ARM64_RELOC_ADDEND) {
op_info->VariantKind = LLVMDisassembler_VariantKind_ARM64_PAGEOFF; DataRefImpl RelNext = Rel;
break; info->O->moveRelocationNext(RelNext);
case MachO::ARM64_RELOC_GOT_LOAD_PAGE21: MachO::any_relocation_info RENext = info->O->getRelocation(RelNext);
/* @gotpage */ if (value == 0) {
op_info->VariantKind = LLVMDisassembler_VariantKind_ARM64_GOTPAGE; value = info->O->getPlainRelocationSymbolNum(RENext);
break; op_info->Value = value;
case MachO::ARM64_RELOC_GOT_LOAD_PAGEOFF12:
/* @gotpageoff */
op_info->VariantKind = LLVMDisassembler_VariantKind_ARM64_GOTPAGEOFF;
break;
case MachO::ARM64_RELOC_TLVP_LOAD_PAGE21:
/* @tvlppage is not implemented in llvm-mc */
op_info->VariantKind = LLVMDisassembler_VariantKind_ARM64_TLVP;
break;
case MachO::ARM64_RELOC_TLVP_LOAD_PAGEOFF12:
/* @tvlppageoff is not implemented in llvm-mc */
op_info->VariantKind = LLVMDisassembler_VariantKind_ARM64_TLVOFF;
break;
default:
case MachO::ARM64_RELOC_BRANCH26:
op_info->VariantKind = LLVMDisassembler_VariantKind_None;
break;
} }
return 1;
} }
return 0; // NOTE: Scattered relocations don't exist on arm64.
} else { if (!info->O->getPlainRelocationExternal(RE))
return 0; return 0;
StringRef SymName;
Reloc->getSymbol()->getName(SymName);
const char *name = SymName.data();
op_info->AddSymbol.Present = 1;
op_info->AddSymbol.Name = name;
switch (r_type) {
case MachO::ARM64_RELOC_PAGE21:
/* @page */
op_info->VariantKind = LLVMDisassembler_VariantKind_ARM64_PAGE;
break;
case MachO::ARM64_RELOC_PAGEOFF12:
/* @pageoff */
op_info->VariantKind = LLVMDisassembler_VariantKind_ARM64_PAGEOFF;
break;
case MachO::ARM64_RELOC_GOT_LOAD_PAGE21:
/* @gotpage */
op_info->VariantKind = LLVMDisassembler_VariantKind_ARM64_GOTPAGE;
break;
case MachO::ARM64_RELOC_GOT_LOAD_PAGEOFF12:
/* @gotpageoff */
op_info->VariantKind = LLVMDisassembler_VariantKind_ARM64_GOTPAGEOFF;
break;
case MachO::ARM64_RELOC_TLVP_LOAD_PAGE21:
/* @tvlppage is not implemented in llvm-mc */
op_info->VariantKind = LLVMDisassembler_VariantKind_ARM64_TLVP;
break;
case MachO::ARM64_RELOC_TLVP_LOAD_PAGEOFF12:
/* @tvlppageoff is not implemented in llvm-mc */
op_info->VariantKind = LLVMDisassembler_VariantKind_ARM64_TLVOFF;
break;
default:
case MachO::ARM64_RELOC_BRANCH26:
op_info->VariantKind = LLVMDisassembler_VariantKind_None;
break;
}
return 1;
} }
return 0;
} }
// GuessCstringPointer is passed the address of what might be a pointer to a // GuessCstringPointer is passed the address of what might be a pointer to a
@ -2421,7 +2410,7 @@ static const char *get_pointer_64(uint64_t Address, uint32_t &offset,
static const char *get_symbol_64(uint32_t sect_offset, SectionRef S, static const char *get_symbol_64(uint32_t sect_offset, SectionRef S,
DisassembleInfo *info, uint64_t &n_value) { DisassembleInfo *info, uint64_t &n_value) {
n_value = 0; n_value = 0;
if (info->verbose == false) if (!info->verbose)
return nullptr; return nullptr;
// See if there is an external relocation entry at the sect_offset. // See if there is an external relocation entry at the sect_offset.
@ -2716,7 +2705,7 @@ static const char *GuessLiteralPointer(uint64_t ReferenceValue,
bool classref, selref, msgref, cfstring; bool classref, selref, msgref, cfstring;
uint64_t pointer_value = GuessPointerPointer(ReferenceValue, info, classref, uint64_t pointer_value = GuessPointerPointer(ReferenceValue, info, classref,
selref, msgref, cfstring); selref, msgref, cfstring);
if (classref == true && pointer_value == 0) { if (classref && pointer_value == 0) {
// Note the ReferenceValue is a pointer into the __objc_classrefs section. // Note the ReferenceValue is a pointer into the __objc_classrefs section.
// And the pointer_value in that section is typically zero as it will be // And the pointer_value in that section is typically zero as it will be
// set by dyld as part of the "bind information". // set by dyld as part of the "bind information".
@ -2732,7 +2721,7 @@ static const char *GuessLiteralPointer(uint64_t ReferenceValue,
} }
} }
if (classref == true) { if (classref) {
*ReferenceType = LLVMDisassembler_ReferenceType_Out_Objc_Class_Ref; *ReferenceType = LLVMDisassembler_ReferenceType_Out_Objc_Class_Ref;
const char *name = const char *name =
get_objc2_64bit_class_name(pointer_value, ReferenceValue, info); get_objc2_64bit_class_name(pointer_value, ReferenceValue, info);
@ -2743,13 +2732,13 @@ static const char *GuessLiteralPointer(uint64_t ReferenceValue,
return name; return name;
} }
if (cfstring == true) { if (cfstring) {
*ReferenceType = LLVMDisassembler_ReferenceType_Out_Objc_CFString_Ref; *ReferenceType = LLVMDisassembler_ReferenceType_Out_Objc_CFString_Ref;
const char *name = get_objc2_64bit_cfstring_name(ReferenceValue, info); const char *name = get_objc2_64bit_cfstring_name(ReferenceValue, info);
return name; return name;
} }
if (selref == true && pointer_value == 0) if (selref && pointer_value == 0)
pointer_value = get_objc2_64bit_selref(ReferenceValue, info); pointer_value = get_objc2_64bit_selref(ReferenceValue, info);
if (pointer_value != 0) if (pointer_value != 0)
@ -2757,10 +2746,10 @@ static const char *GuessLiteralPointer(uint64_t ReferenceValue,
const char *name = GuessCstringPointer(ReferenceValue, info); const char *name = GuessCstringPointer(ReferenceValue, info);
if (name) { if (name) {
if (pointer_value != 0 && selref == true) { if (pointer_value != 0 && selref) {
*ReferenceType = LLVMDisassembler_ReferenceType_Out_Objc_Selector_Ref; *ReferenceType = LLVMDisassembler_ReferenceType_Out_Objc_Selector_Ref;
info->selector_name = name; info->selector_name = name;
} else if (pointer_value != 0 && msgref == true) { } else if (pointer_value != 0 && msgref) {
info->class_name = nullptr; info->class_name = nullptr;
*ReferenceType = LLVMDisassembler_ReferenceType_Out_Objc_Message_Ref; *ReferenceType = LLVMDisassembler_ReferenceType_Out_Objc_Message_Ref;
info->selector_name = name; info->selector_name = name;
@ -2815,7 +2804,7 @@ static const char *SymbolizerSymbolLookUp(void *DisInfo,
const char **ReferenceName) { const char **ReferenceName) {
struct DisassembleInfo *info = (struct DisassembleInfo *)DisInfo; struct DisassembleInfo *info = (struct DisassembleInfo *)DisInfo;
// If no verbose symbolic information is wanted then just return nullptr. // If no verbose symbolic information is wanted then just return nullptr.
if (info->verbose == false) { if (!info->verbose) {
*ReferenceName = nullptr; *ReferenceName = nullptr;
*ReferenceType = LLVMDisassembler_ReferenceType_InOut_None; *ReferenceType = LLVMDisassembler_ReferenceType_InOut_None;
return nullptr; return nullptr;
@ -3208,7 +3197,7 @@ static void DisassembleMachO(StringRef Filename, MachOObjectFile *MachOOF,
DisSymNameFound = true; DisSymNameFound = true;
} }
} }
if (!DisSymName.empty() && DisSymNameFound == false) { if (!DisSymName.empty() && !DisSymNameFound) {
outs() << "Can't find -dis-symname: " << DisSymName << "\n"; outs() << "Can't find -dis-symname: " << DisSymName << "\n";
return; return;
} }