From d735307aa2be0ebcc37ddd8d4268635dcd1e9d4e Mon Sep 17 00:00:00 2001 From: Slava Gurevich Date: Mon, 1 Aug 2022 12:36:38 -0700 Subject: [PATCH] [LLDB][Reliability] Remove dead code. Remove redundant code that can never execute due to preceeding logic checks in the code. Differential Revision: https://reviews.llvm.org/D130929 --- lldb/source/API/SBFrame.cpp | 2 +- .../Plugins/ABI/AArch64/ABIMacOSX_arm64.cpp | 3 --- .../Plugins/ABI/AArch64/ABISysV_arm64.cpp | 3 --- .../Plugins/Language/ObjC/CoreMedia.cpp | 3 --- lldb/source/Target/Platform.cpp | 20 ++++++++----------- 5 files changed, 9 insertions(+), 22 deletions(-) diff --git a/lldb/source/API/SBFrame.cpp b/lldb/source/API/SBFrame.cpp index ea9c2bb747e1..4157c20cbabb 100644 --- a/lldb/source/API/SBFrame.cpp +++ b/lldb/source/API/SBFrame.cpp @@ -739,7 +739,7 @@ SBValueList SBFrame::GetVariables(bool arguments, bool locals, bool statics, lldb::DynamicValueType use_dynamic = frame->CalculateTarget()->GetPreferDynamicValue(); const bool include_runtime_support_values = - target ? target->GetDisplayRuntimeSupportValues() : false; + target->GetDisplayRuntimeSupportValues(); SBVariablesOptions options; options.SetIncludeArguments(arguments); diff --git a/lldb/source/Plugins/ABI/AArch64/ABIMacOSX_arm64.cpp b/lldb/source/Plugins/ABI/AArch64/ABIMacOSX_arm64.cpp index 9dfc50564e64..7b948d8fa8cb 100644 --- a/lldb/source/Plugins/ABI/AArch64/ABIMacOSX_arm64.cpp +++ b/lldb/source/Plugins/ABI/AArch64/ABIMacOSX_arm64.cpp @@ -612,9 +612,6 @@ static bool LoadValueFromConsecutiveGPRRegisters( ++NGRN; } - if (reg_info == nullptr) - return false; - const lldb::addr_t value_addr = reg_ctx->ReadRegisterAsUnsigned(reg_info, LLDB_INVALID_ADDRESS); diff --git a/lldb/source/Plugins/ABI/AArch64/ABISysV_arm64.cpp b/lldb/source/Plugins/ABI/AArch64/ABISysV_arm64.cpp index 2896f5920db9..a0b2d077a22f 100644 --- a/lldb/source/Plugins/ABI/AArch64/ABISysV_arm64.cpp +++ b/lldb/source/Plugins/ABI/AArch64/ABISysV_arm64.cpp @@ -582,9 +582,6 @@ static bool LoadValueFromConsecutiveGPRRegisters( ++NGRN; } - if (reg_info == nullptr) - return false; - const lldb::addr_t value_addr = reg_ctx->ReadRegisterAsUnsigned(reg_info, LLDB_INVALID_ADDRESS); diff --git a/lldb/source/Plugins/Language/ObjC/CoreMedia.cpp b/lldb/source/Plugins/Language/ObjC/CoreMedia.cpp index a862da551813..4b7fad08f00c 100644 --- a/lldb/source/Plugins/Language/ObjC/CoreMedia.cpp +++ b/lldb/source/Plugins/Language/ObjC/CoreMedia.cpp @@ -65,9 +65,6 @@ bool lldb_private::formatters::CMTimeSummaryProvider( return true; } - if (timescale == 0) - return false; - switch (timescale) { case 0: return false; diff --git a/lldb/source/Target/Platform.cpp b/lldb/source/Target/Platform.cpp index b9b32bff0730..717dc968f37d 100644 --- a/lldb/source/Target/Platform.cpp +++ b/lldb/source/Target/Platform.cpp @@ -1772,24 +1772,20 @@ lldb::ProcessSP Platform::DoConnectProcess(llvm::StringRef connect_url, error.Clear(); if (!target) { - ArchSpec arch; - if (target && target->GetArchitecture().IsValid()) - arch = target->GetArchitecture(); - else - arch = Target::GetDefaultArchitecture(); + ArchSpec arch = Target::GetDefaultArchitecture(); - const char *triple = ""; - if (arch.IsValid()) - triple = arch.GetTriple().getTriple().c_str(); + const char *triple = + arch.IsValid() ? arch.GetTriple().getTriple().c_str() : ""; TargetSP new_target_sp; error = debugger.GetTargetList().CreateTarget( debugger, "", triple, eLoadDependentsNo, nullptr, new_target_sp); - target = new_target_sp.get(); - } - if (!target || error.Fail()) - return nullptr; + target = new_target_sp.get(); + if (!target || error.Fail()) { + return nullptr; + } + } lldb::ProcessSP process_sp = target->CreateProcess(debugger.GetListener(), plugin_name, nullptr, true);