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
diff --git a/lldb/source/Core/Disassembler.cpp b/lldb/source/Core/Disassembler.cpp
index f957a5c..a34b803 100644
--- a/lldb/source/Core/Disassembler.cpp
+++ b/lldb/source/Core/Disassembler.cpp
@@ -452,8 +452,7 @@
if (mixed_source_and_assembly && sc.line_entry.IsValid()) {
if (sc.symbol != previous_symbol) {
SourceLine decl_line = GetFunctionDeclLineEntry(sc);
- if (ElideMixedSourceAndDisassemblyLine(exe_ctx, sc, decl_line) ==
- false)
+ if (!ElideMixedSourceAndDisassemblyLine(exe_ctx, sc, decl_line))
AddLineToSourceLineTables(decl_line, source_lines_seen);
}
if (sc.line_entry.IsValid()) {
@@ -461,8 +460,7 @@
this_line.file = sc.line_entry.file;
this_line.line = sc.line_entry.line;
this_line.column = sc.line_entry.column;
- if (ElideMixedSourceAndDisassemblyLine(exe_ctx, sc, this_line) ==
- false)
+ if (!ElideMixedSourceAndDisassemblyLine(exe_ctx, sc, this_line))
AddLineToSourceLineTables(this_line, source_lines_seen);
}
}
@@ -506,8 +504,8 @@
previous_symbol = sc.symbol;
if (sc.function && sc.line_entry.IsValid()) {
LineEntry prologue_end_line = sc.line_entry;
- if (ElideMixedSourceAndDisassemblyLine(
- exe_ctx, sc, prologue_end_line) == false) {
+ if (!ElideMixedSourceAndDisassemblyLine(exe_ctx, sc,
+ prologue_end_line)) {
FileSpec func_decl_file;
uint32_t func_decl_line;
sc.function->GetStartLineSourceInfo(func_decl_file,
@@ -547,8 +545,8 @@
this_line.file = sc.line_entry.file;
this_line.line = sc.line_entry.line;
- if (ElideMixedSourceAndDisassemblyLine(exe_ctx, sc,
- this_line) == false) {
+ if (!ElideMixedSourceAndDisassemblyLine(exe_ctx, sc,
+ this_line)) {
// Only print this source line if it is different from the
// last source line we printed. There may have been inlined
// functions between these lines that we elided, resulting in
diff --git a/lldb/source/Core/Mangled.cpp b/lldb/source/Core/Mangled.cpp
index 536c812..943df00 100644
--- a/lldb/source/Core/Mangled.cpp
+++ b/lldb/source/Core/Mangled.cpp
@@ -419,9 +419,7 @@
return true;
ConstString demangled = GetDemangledName(language);
- if (demangled && regex.Execute(demangled.AsCString()))
- return true;
- return false;
+ return demangled && regex.Execute(demangled.AsCString());
}
//----------------------------------------------------------------------
diff --git a/lldb/source/Core/SearchFilter.cpp b/lldb/source/Core/SearchFilter.cpp
index df1b6d3..ebacbd2 100644
--- a/lldb/source/Core/SearchFilter.cpp
+++ b/lldb/source/Core/SearchFilter.cpp
@@ -388,10 +388,7 @@
bool SearchFilterForUnconstrainedSearches::ModulePasses(
const FileSpec &module_spec) {
- if (m_target_sp->ModuleIsExcludedForUnconstrainedSearches(module_spec))
- return false;
- else
- return true;
+ return !m_target_sp->ModuleIsExcludedForUnconstrainedSearches(module_spec);
}
bool SearchFilterForUnconstrainedSearches::ModulePasses(
@@ -570,22 +567,15 @@
if (m_module_spec_list.GetSize() == 0)
return true;
- if (module_sp &&
- m_module_spec_list.FindFileIndex(0, module_sp->GetFileSpec(), false) !=
- UINT32_MAX)
- return true;
- else
- return false;
+ return module_sp && m_module_spec_list.FindFileIndex(
+ 0, module_sp->GetFileSpec(), false) != UINT32_MAX;
}
bool SearchFilterByModuleList::ModulePasses(const FileSpec &spec) {
if (m_module_spec_list.GetSize() == 0)
return true;
- if (m_module_spec_list.FindFileIndex(0, spec, true) != UINT32_MAX)
- return true;
- else
- return false;
+ return m_module_spec_list.FindFileIndex(0, spec, true) != UINT32_MAX;
}
bool SearchFilterByModuleList::AddressPasses(Address &address) {
diff --git a/lldb/source/Core/SourceManager.cpp b/lldb/source/Core/SourceManager.cpp
index 16cc1b8..fe603c5 100644
--- a/lldb/source/Core/SourceManager.cpp
+++ b/lldb/source/Core/SourceManager.cpp
@@ -486,7 +486,7 @@
if (end_offset > start_offset) {
uint32_t length = end_offset - start_offset;
- if (include_newline_chars == false) {
+ if (!include_newline_chars) {
const char *line_start =
(const char *)m_data_sp->GetBytes() + start_offset;
while (length > 0) {
diff --git a/lldb/source/Core/ValueObject.cpp b/lldb/source/Core/ValueObject.cpp
index 96a1716..b0dd04a 100644
--- a/lldb/source/Core/ValueObject.cpp
+++ b/lldb/source/Core/ValueObject.cpp
@@ -214,7 +214,7 @@
if (first_update)
SetValueDidChange(false);
- else if (!m_value_did_change && success == false) {
+ else if (!m_value_did_change && !success) {
// The value wasn't gotten successfully, so we mark this as changed if
// the value used to be valid and now isn't
SetValueDidChange(value_was_valid);
@@ -442,10 +442,7 @@
}
bool ret;
- if (scalar_value.ULongLong(1) == 0)
- ret = false;
- else
- ret = true;
+ ret = scalar_value.ULongLong(1) != 0;
error.Clear();
return ret;
}
@@ -639,7 +636,7 @@
bool child_is_deref_of_parent = false;
uint64_t language_flags = 0;
- const bool transparent_pointers = synthetic_array_member == false;
+ const bool transparent_pointers = !synthetic_array_member;
CompilerType child_compiler_type;
ExecutionContext exe_ctx(GetExecutionContextRef());
@@ -1921,11 +1918,11 @@
}
void ValueObject::CalculateSyntheticValue(bool use_synthetic) {
- if (use_synthetic == false)
+ if (!use_synthetic)
return;
TargetSP target_sp(GetTargetSP());
- if (target_sp && target_sp->GetEnableSyntheticValue() == false) {
+ if (target_sp && !target_sp->GetEnableSyntheticValue()) {
m_synthetic_value = NULL;
return;
}
@@ -1976,7 +1973,7 @@
lldb::ValueObjectSP ValueObject::GetNonSyntheticValue() { return GetSP(); }
ValueObjectSP ValueObject::GetSyntheticValue(bool use_synthetic) {
- if (use_synthetic == false)
+ if (!use_synthetic)
return ValueObjectSP();
CalculateSyntheticValue(use_synthetic);
@@ -1995,10 +1992,7 @@
CalculateSyntheticValue(true);
- if (m_synthetic_value)
- return true;
- else
- return false;
+ return m_synthetic_value != nullptr;
}
bool ValueObject::GetBaseClassPath(Stream &s) {
@@ -3195,7 +3189,7 @@
ValueObject::FollowParentChain(std::function<bool(ValueObject *)> f) {
ValueObject *vo = this;
while (vo) {
- if (f(vo) == false)
+ if (!f(vo))
break;
vo = vo->m_parent;
}
@@ -3264,8 +3258,7 @@
// board debugging scenarios have no notion of types, but still manage to
// have raw numeric values for things like registers. sigh.
const CompilerType &type(GetCompilerType());
- return (false == type.IsValid()) ||
- (0 != (type.GetTypeInfo() & eTypeHasValue));
+ return (!type.IsValid()) || (0 != (type.GetTypeInfo() & eTypeHasValue));
}
bool ValueObject::IsChecksumEmpty() { return m_value_checksum.empty(); }
diff --git a/lldb/source/Core/ValueObjectChild.cpp b/lldb/source/Core/ValueObjectChild.cpp
index 42b31cc..7255eed 100644
--- a/lldb/source/Core/ValueObjectChild.cpp
+++ b/lldb/source/Core/ValueObjectChild.cpp
@@ -124,7 +124,7 @@
Flags parent_type_flags(parent_type.GetTypeInfo());
const bool is_instance_ptr_base =
- ((m_is_base_class == true) &&
+ ((m_is_base_class) &&
(parent_type_flags.AnySet(lldb::eTypeInstanceIsPointer)));
if (parent->GetCompilerType().ShouldTreatScalarValueAsAddress()) {
@@ -142,7 +142,7 @@
switch (addr_type) {
case eAddressTypeFile: {
lldb::ProcessSP process_sp(GetProcessSP());
- if (process_sp && process_sp->IsAlive() == true)
+ if (process_sp && process_sp->IsAlive())
m_value.SetValueType(Value::eValueTypeLoadAddress);
else
m_value.SetValueType(Value::eValueTypeFileAddress);
diff --git a/lldb/source/Core/ValueObjectConstResultImpl.cpp b/lldb/source/Core/ValueObjectConstResultImpl.cpp
index 789f388..6bf8e62 100644
--- a/lldb/source/Core/ValueObjectConstResultImpl.cpp
+++ b/lldb/source/Core/ValueObjectConstResultImpl.cpp
@@ -66,7 +66,7 @@
bool child_is_deref_of_parent = false;
uint64_t language_flags;
- const bool transparent_pointers = synthetic_array_member == false;
+ const bool transparent_pointers = !synthetic_array_member;
CompilerType compiler_type = m_impl_backend->GetCompilerType();
CompilerType child_compiler_type;
diff --git a/lldb/source/Core/ValueObjectSyntheticFilter.cpp b/lldb/source/Core/ValueObjectSyntheticFilter.cpp
index 1da142f..d22b1dc 100644
--- a/lldb/source/Core/ValueObjectSyntheticFilter.cpp
+++ b/lldb/source/Core/ValueObjectSyntheticFilter.cpp
@@ -119,7 +119,7 @@
if (m_might_have_children == eLazyBoolCalculate)
m_might_have_children =
(m_synth_filter_ap->MightHaveChildren() ? eLazyBoolYes : eLazyBoolNo);
- return (m_might_have_children == eLazyBoolNo ? false : true);
+ return (m_might_have_children != eLazyBoolNo);
}
uint64_t ValueObjectSynthetic::GetByteSize() { return m_parent->GetByteSize(); }
@@ -174,7 +174,7 @@
}
// let our backend do its update
- if (m_synth_filter_ap->Update() == false) {
+ if (!m_synth_filter_ap->Update()) {
if (log)
log->Printf("[ValueObjectSynthetic::UpdateValue] name=%s, synthetic "
"filter said caches are stale - clearing",
@@ -235,7 +235,7 @@
UpdateValueIfNeeded();
ValueObject *valobj;
- if (m_children_byindex.GetValueForKey(idx, valobj) == false) {
+ if (!m_children_byindex.GetValueForKey(idx, valobj)) {
if (can_create && m_synth_filter_ap.get() != nullptr) {
if (log)
log->Printf("[ValueObjectSynthetic::GetChildAtIndex] name=%s, child at "