summaryrefslogtreecommitdiffstats
path: root/lldb/source/Plugins/ObjectFile
diff options
context:
space:
mode:
authorJonas Devlieghere <jonas@devlieghere.com>2018-12-15 00:15:33 +0000
committerJonas Devlieghere <jonas@devlieghere.com>2018-12-15 00:15:33 +0000
commita6682a413d893bc1ed6190dfadcee806155da66e (patch)
tree326b3a6e484e3a3a3a5087663e1284f9b594f2a8 /lldb/source/Plugins/ObjectFile
parent9d1827331f3f9582fa2ed05913ae4301f2604a19 (diff)
downloadbcm5719-llvm-a6682a413d893bc1ed6190dfadcee806155da66e.tar.gz
bcm5719-llvm-a6682a413d893bc1ed6190dfadcee806155da66e.zip
Simplify Boolean expressions
This patch simplifies boolean expressions acorss LLDB. It was generated using clang-tidy with the following command: run-clang-tidy.py -checks='-*,readability-simplify-boolean-expr' -format -fix $PWD Differential revision: https://reviews.llvm.org/D55584 llvm-svn: 349215
Diffstat (limited to 'lldb/source/Plugins/ObjectFile')
-rw-r--r--lldb/source/Plugins/ObjectFile/ELF/ELFHeader.cpp29
-rw-r--r--lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp10
-rw-r--r--lldb/source/Plugins/ObjectFile/JIT/ObjectFileJIT.cpp2
-rw-r--r--lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp92
-rw-r--r--lldb/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp2
5 files changed, 65 insertions, 70 deletions
diff --git a/lldb/source/Plugins/ObjectFile/ELF/ELFHeader.cpp b/lldb/source/Plugins/ObjectFile/ELF/ELFHeader.cpp
index 16cbb6e5753..3d4735286bf 100644
--- a/lldb/source/Plugins/ObjectFile/ELF/ELFHeader.cpp
+++ b/lldb/source/Plugins/ObjectFile/ELF/ELFHeader.cpp
@@ -38,7 +38,7 @@ static bool GetMaxU64(const lldb_private::DataExtractor &data,
lldb::offset_t saved_offset = *offset;
for (uint32_t i = 0; i < count; ++i, ++value) {
- if (GetMaxU64(data, offset, value, byte_size) == false) {
+ if (!GetMaxU64(data, offset, value, byte_size)) {
*offset = saved_offset;
return false;
}
@@ -60,7 +60,7 @@ static bool GetMaxS64(const lldb_private::DataExtractor &data,
lldb::offset_t saved_offset = *offset;
for (uint32_t i = 0; i < count; ++i, ++value) {
- if (GetMaxS64(data, offset, value, byte_size) == false) {
+ if (!GetMaxS64(data, offset, value, byte_size)) {
*offset = saved_offset;
return false;
}
@@ -133,7 +133,7 @@ bool ELFHeader::Parse(lldb_private::DataExtractor &data,
return false;
// Read e_entry, e_phoff and e_shoff.
- if (GetMaxU64(data, offset, &e_entry, byte_size, 3) == false)
+ if (!GetMaxU64(data, offset, &e_entry, byte_size, 3))
return false;
// Read e_flags.
@@ -232,11 +232,11 @@ bool ELFSectionHeader::Parse(const lldb_private::DataExtractor &data,
return false;
// Read sh_flags.
- if (GetMaxU64(data, offset, &sh_flags, byte_size) == false)
+ if (!GetMaxU64(data, offset, &sh_flags, byte_size))
return false;
// Read sh_addr, sh_off and sh_size.
- if (GetMaxU64(data, offset, &sh_addr, byte_size, 3) == false)
+ if (!GetMaxU64(data, offset, &sh_addr, byte_size, 3))
return false;
// Read sh_link and sh_info.
@@ -244,7 +244,7 @@ bool ELFSectionHeader::Parse(const lldb_private::DataExtractor &data,
return false;
// Read sh_addralign and sh_entsize.
- if (GetMaxU64(data, offset, &sh_addralign, byte_size, 2) == false)
+ if (!GetMaxU64(data, offset, &sh_addralign, byte_size, 2))
return false;
return true;
@@ -332,7 +332,7 @@ bool ELFSymbol::Parse(const lldb_private::DataExtractor &data,
if (parsing_32) {
// Read st_value and st_size.
- if (GetMaxU64(data, offset, &st_value, byte_size, 2) == false)
+ if (!GetMaxU64(data, offset, &st_value, byte_size, 2))
return false;
// Read st_info and st_other.
@@ -376,7 +376,7 @@ bool ELFProgramHeader::Parse(const lldb_private::DataExtractor &data,
if (parsing_32) {
// Read p_offset, p_vaddr, p_paddr, p_filesz and p_memsz.
- if (GetMaxU64(data, offset, &p_offset, byte_size, 5) == false)
+ if (!GetMaxU64(data, offset, &p_offset, byte_size, 5))
return false;
// Read p_flags.
@@ -384,7 +384,7 @@ bool ELFProgramHeader::Parse(const lldb_private::DataExtractor &data,
return false;
// Read p_align.
- if (GetMaxU64(data, offset, &p_align, byte_size) == false)
+ if (!GetMaxU64(data, offset, &p_align, byte_size))
return false;
} else {
// Read p_flags.
@@ -392,7 +392,7 @@ bool ELFProgramHeader::Parse(const lldb_private::DataExtractor &data,
return false;
// Read p_offset, p_vaddr, p_paddr, p_filesz, p_memsz and p_align.
- if (GetMaxU64(data, offset, &p_offset, byte_size, 6) == false)
+ if (!GetMaxU64(data, offset, &p_offset, byte_size, 6))
return false;
}
@@ -420,10 +420,7 @@ bool ELFRel::Parse(const lldb_private::DataExtractor &data,
const unsigned byte_size = data.GetAddressByteSize();
// Read r_offset and r_info.
- if (GetMaxU64(data, offset, &r_offset, byte_size, 2) == false)
- return false;
-
- return true;
+ return GetMaxU64(data, offset, &r_offset, byte_size, 2) != false;
}
//------------------------------------------------------------------------------
@@ -436,11 +433,11 @@ bool ELFRela::Parse(const lldb_private::DataExtractor &data,
const unsigned byte_size = data.GetAddressByteSize();
// Read r_offset and r_info.
- if (GetMaxU64(data, offset, &r_offset, byte_size, 2) == false)
+ if (!GetMaxU64(data, offset, &r_offset, byte_size, 2))
return false;
// Read r_addend;
- if (GetMaxS64(data, offset, &r_addend, byte_size) == false)
+ if (!GetMaxS64(data, offset, &r_addend, byte_size))
return false;
return true;
diff --git a/lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp b/lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
index 77ae9731ea8..e294bd470a6 100644
--- a/lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
+++ b/lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
@@ -1140,7 +1140,7 @@ size_t ObjectFileELF::GetProgramHeaderInfo(ProgramHeaderColl &program_headers,
uint32_t idx;
lldb::offset_t offset;
for (idx = 0, offset = 0; idx < header.e_phnum; ++idx) {
- if (program_headers[idx].Parse(data, &offset) == false)
+ if (!program_headers[idx].Parse(data, &offset))
break;
}
@@ -1552,7 +1552,7 @@ size_t ObjectFileELF::GetSectionHeaderInfo(SectionHeaderColl &section_headers,
uint32_t idx;
lldb::offset_t offset;
for (idx = 0, offset = 0; idx < header.e_shnum; ++idx) {
- if (section_headers[idx].Parse(sh_data, &offset) == false)
+ if (!section_headers[idx].Parse(sh_data, &offset))
break;
}
if (idx < section_headers.size())
@@ -1953,7 +1953,7 @@ unsigned ObjectFileELF::ParseSymbols(Symtab *symtab, user_id_t start_id,
unsigned i;
for (i = 0; i < num_symbols; ++i) {
- if (symbol.Parse(symtab_data, &offset) == false)
+ if (!symbol.Parse(symtab_data, &offset))
break;
const char *symbol_name = strtab_data.PeekCStr(symbol.st_name);
@@ -2419,7 +2419,7 @@ static unsigned ParsePLTRelocations(
unsigned slot_type = hdr->GetRelocationJumpSlotType();
unsigned i;
for (i = 0; i < num_relocations; ++i) {
- if (rel.Parse(rel_data, &offset) == false)
+ if (!rel.Parse(rel_data, &offset))
break;
if (reloc_type(rel) != slot_type)
@@ -2552,7 +2552,7 @@ unsigned ObjectFileELF::ApplyRelocations(
}
for (unsigned i = 0; i < num_relocations; ++i) {
- if (rel.Parse(rel_data, &offset) == false)
+ if (!rel.Parse(rel_data, &offset))
break;
Symbol *symbol = NULL;
diff --git a/lldb/source/Plugins/ObjectFile/JIT/ObjectFileJIT.cpp b/lldb/source/Plugins/ObjectFile/JIT/ObjectFileJIT.cpp
index 53eb820746e..bce35224550 100644
--- a/lldb/source/Plugins/ObjectFile/JIT/ObjectFileJIT.cpp
+++ b/lldb/source/Plugins/ObjectFile/JIT/ObjectFileJIT.cpp
@@ -218,7 +218,7 @@ bool ObjectFileJIT::SetLoadAddress(Target &target, lldb::addr_t value,
// that size on disk (to avoid __PAGEZERO) and load them
SectionSP section_sp(section_list->GetSectionAtIndex(sect_idx));
if (section_sp && section_sp->GetFileSize() > 0 &&
- section_sp->IsThreadSpecific() == false) {
+ !section_sp->IsThreadSpecific()) {
if (target.GetSectionLoadList().SetSectionLoadAddress(
section_sp, section_sp->GetFileAddress() + value))
++num_loaded_sections;
diff --git a/lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp b/lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
index e6b9c520dd1..c7a790ebd09 100644
--- a/lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
+++ b/lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
@@ -4469,7 +4469,7 @@ size_t ObjectFileMachO::ParseSymtab() {
symbol_value -= section_file_addr;
}
- if (is_debug == false) {
+ if (!is_debug) {
if (type == eSymbolTypeCode) {
// See if we can find a N_FUN entry for any code symbols. If we
// do find a match, and the name matches, then we can merge the
@@ -4616,7 +4616,7 @@ size_t ObjectFileMachO::ParseSymtab() {
if (function_starts_count > 0) {
uint32_t num_synthetic_function_symbols = 0;
for (i = 0; i < function_starts_count; ++i) {
- if (function_starts.GetEntryRef(i).data == false)
+ if (!function_starts.GetEntryRef(i).data)
++num_synthetic_function_symbols;
}
@@ -4628,7 +4628,7 @@ size_t ObjectFileMachO::ParseSymtab() {
for (i = 0; i < function_starts_count; ++i) {
const FunctionStarts::Entry *func_start_entry =
function_starts.GetEntryAtIndex(i);
- if (func_start_entry->data == false) {
+ if (!func_start_entry->data) {
addr_t symbol_file_addr = func_start_entry->addr;
uint32_t symbol_flags = 0;
if (is_arm) {
@@ -5861,7 +5861,7 @@ uint32_t ObjectFileMachO::GetSDKVersion(uint32_t *versions,
if (m_sdk_versions.empty()) {
lldb::offset_t offset = MachHeaderSizeFromMagic(m_header.magic);
bool success = false;
- for (uint32_t i = 0; success == false && i < m_header.ncmds; ++i) {
+ for (uint32_t i = 0; !success && i < m_header.ncmds; ++i) {
const lldb::offset_t load_cmd_offset = offset;
version_min_command lc;
@@ -5890,47 +5890,46 @@ uint32_t ObjectFileMachO::GetSDKVersion(uint32_t *versions,
offset = load_cmd_offset + lc.cmdsize;
}
- if (success == false)
- {
- offset = MachHeaderSizeFromMagic(m_header.magic);
- for (uint32_t i = 0; success == false && i < m_header.ncmds; ++i)
- {
- const lldb::offset_t load_cmd_offset = offset;
+ if (!success) {
+ offset = MachHeaderSizeFromMagic(m_header.magic);
+ for (uint32_t i = 0; !success && i < m_header.ncmds; ++i) {
+ const lldb::offset_t load_cmd_offset = offset;
- version_min_command lc;
- if (m_data.GetU32(&offset, &lc.cmd, 2) == NULL)
- break;
- if (lc.cmd == llvm::MachO::LC_BUILD_VERSION)
- {
- // struct build_version_command {
- // uint32_t cmd; /* LC_BUILD_VERSION */
- // uint32_t cmdsize; /* sizeof(struct build_version_command) plus */
- // /* ntools * sizeof(struct build_tool_version) */
- // uint32_t platform; /* platform */
- // uint32_t minos; /* X.Y.Z is encoded in nibbles xxxx.yy.zz */
- // uint32_t sdk; /* X.Y.Z is encoded in nibbles xxxx.yy.zz */
- // uint32_t ntools; /* number of tool entries following this */
- // };
-
- offset += 4; // skip platform
- uint32_t minos = m_data.GetU32(&offset);
-
- const uint32_t xxxx = minos >> 16;
- const uint32_t yy = (minos >> 8) & 0xffu;
- const uint32_t zz = minos & 0xffu;
- if (xxxx)
- {
- m_sdk_versions.push_back (xxxx);
- m_sdk_versions.push_back (yy);
- m_sdk_versions.push_back (zz);
- success = true;
- }
- }
- offset = load_cmd_offset + lc.cmdsize;
+ version_min_command lc;
+ if (m_data.GetU32(&offset, &lc.cmd, 2) == NULL)
+ break;
+ if (lc.cmd == llvm::MachO::LC_BUILD_VERSION) {
+ // struct build_version_command {
+ // uint32_t cmd; /* LC_BUILD_VERSION */
+ // uint32_t cmdsize; /* sizeof(struct
+ // build_version_command) plus */
+ // /* ntools * sizeof(struct
+ // build_tool_version) */
+ // uint32_t platform; /* platform */
+ // uint32_t minos; /* X.Y.Z is encoded in nibbles
+ // xxxx.yy.zz */ uint32_t sdk; /* X.Y.Z is encoded
+ // in nibbles xxxx.yy.zz */ uint32_t ntools; /* number
+ // of tool entries following this */
+ // };
+
+ offset += 4; // skip platform
+ uint32_t minos = m_data.GetU32(&offset);
+
+ const uint32_t xxxx = minos >> 16;
+ const uint32_t yy = (minos >> 8) & 0xffu;
+ const uint32_t zz = minos & 0xffu;
+ if (xxxx) {
+ m_sdk_versions.push_back(xxxx);
+ m_sdk_versions.push_back(yy);
+ m_sdk_versions.push_back(zz);
+ success = true;
+ }
}
+ offset = load_cmd_offset + lc.cmdsize;
+ }
}
- if (success == false) {
+ if (!success) {
// Push an invalid value so we don't try to find
// the version # again on the next call to this
// method.
@@ -5991,8 +5990,7 @@ Section *ObjectFileMachO::GetMachHeaderSection() {
++sect_idx) {
Section *section = section_list->GetSectionAtIndex(sect_idx).get();
if (section && section->GetFileSize() > 0 &&
- section->GetFileOffset() == 0 &&
- section->IsThreadSpecific() == false &&
+ section->GetFileOffset() == 0 && !section->IsThreadSpecific() &&
module_sp.get() == section->GetModule().get()) {
return section;
}
@@ -6011,7 +6009,7 @@ lldb::addr_t ObjectFileMachO::CalculateSectionLoadAddressForMemoryImage(
lldb::addr_t mach_header_file_addr = mach_header_section->GetFileAddress();
if (mach_header_file_addr != LLDB_INVALID_ADDRESS) {
if (section && section->GetFileSize() > 0 &&
- section->IsThreadSpecific() == false &&
+ !section->IsThreadSpecific() &&
module_sp.get() == section->GetModule().get()) {
// Ignore __LINKEDIT and __DWARF segments
if (section->GetName() == GetSegmentNameLINKEDIT()) {
@@ -6019,7 +6017,7 @@ lldb::addr_t ObjectFileMachO::CalculateSectionLoadAddressForMemoryImage(
// kernel binary like a kext or mach_kernel.
const bool is_memory_image = (bool)m_process_wp.lock();
const Strata strata = GetStrata();
- if (is_memory_image == false || strata == eStrataKernel)
+ if (!is_memory_image || strata == eStrataKernel)
return LLDB_INVALID_ADDRESS;
}
return section->GetFileAddress() - mach_header_file_addr +
@@ -6046,7 +6044,7 @@ bool ObjectFileMachO::SetLoadAddress(Target &target, lldb::addr_t value,
// sections that size on disk (to avoid __PAGEZERO) and load them
SectionSP section_sp(section_list->GetSectionAtIndex(sect_idx));
if (section_sp && section_sp->GetFileSize() > 0 &&
- section_sp->IsThreadSpecific() == false &&
+ !section_sp->IsThreadSpecific() &&
module_sp.get() == section_sp->GetModule().get()) {
// Ignore __LINKEDIT and __DWARF segments
if (section_sp->GetName() == GetSegmentNameLINKEDIT()) {
@@ -6054,7 +6052,7 @@ bool ObjectFileMachO::SetLoadAddress(Target &target, lldb::addr_t value,
// isn't a kernel binary like a kext or mach_kernel.
const bool is_memory_image = (bool)m_process_wp.lock();
const Strata strata = GetStrata();
- if (is_memory_image == false || strata == eStrataKernel)
+ if (!is_memory_image || strata == eStrataKernel)
continue;
}
if (target.GetSectionLoadList().SetSectionLoadAddress(
diff --git a/lldb/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp b/lldb/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp
index 12d9a673e03..abdec6550e5 100644
--- a/lldb/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp
+++ b/lldb/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp
@@ -527,7 +527,7 @@ bool ObjectFilePECOFF::ParseSectionHeaders(
}
}
- return m_sect_headers.empty() == false;
+ return !m_sect_headers.empty();
}
bool ObjectFilePECOFF::GetSectionName(std::string &sect_name,
OpenPOWER on IntegriCloud