Index: include/lldb/Breakpoint/BreakpointResolver.h =================================================================== --- include/lldb/Breakpoint/BreakpointResolver.h +++ include/lldb/Breakpoint/BreakpointResolver.h @@ -173,8 +173,8 @@ enum ResolverTy GetResolverTy() { if (SubclassID > ResolverTy::LastKnownResolverType) return ResolverTy::UnknownResolver; - else - return (enum ResolverTy)SubclassID; + + return (enum ResolverTy)SubclassID; } const char *GetResolverName() { return ResolverTyToName(GetResolverTy()); } Index: include/lldb/Core/Broadcaster.h =================================================================== --- include/lldb/Core/Broadcaster.h +++ include/lldb/Core/Broadcaster.h @@ -68,10 +68,10 @@ uint32_t in_bits = in_spec.GetEventBits(); if (in_bits == m_event_bits) return true; - else { - if ((m_event_bits & in_bits) != 0 && (m_event_bits & ~in_bits) == 0) - return true; - } + + if ((m_event_bits & in_bits) != 0 && (m_event_bits & ~in_bits) == 0) + return true; + return false; } @@ -188,8 +188,8 @@ bool operator()(const event_listener_key input) const { if (input.second == m_listener_sp) return true; - else - return false; + + return false; } private: @@ -206,15 +206,15 @@ bool operator()(const event_listener_key input) const { if (input.second.get() == m_listener) return true; - else - return false; + + return false; } bool operator()(const lldb::ListenerSP input) const { if (input.get() == m_listener) return true; - else - return false; + + return false; } private: Index: include/lldb/Core/Event.h =================================================================== --- include/lldb/Core/Event.h +++ include/lldb/Core/Event.h @@ -231,8 +231,8 @@ m_broadcaster_wp.lock(); if (broadcaster_impl_sp) return broadcaster_impl_sp->GetBroadcaster(); - else - return nullptr; + + return nullptr; } bool BroadcasterIs(Broadcaster *broadcaster) { @@ -240,8 +240,8 @@ m_broadcaster_wp.lock(); if (broadcaster_impl_sp) return broadcaster_impl_sp->GetBroadcaster() == broadcaster; - else - return false; + + return false; } void Clear() { m_data_sp.reset(); } Index: include/lldb/Core/FileSpecList.h =================================================================== --- include/lldb/Core/FileSpecList.h +++ include/lldb/Core/FileSpecList.h @@ -184,7 +184,8 @@ if (idx < m_files.size()) { m_files.insert(m_files.begin() + idx, file); return true; - } else if (idx == m_files.size()) { + } + if (idx == m_files.size()) { m_files.push_back(file); return true; } Index: include/lldb/Core/RangeMap.h =================================================================== --- include/lldb/Core/RangeMap.h +++ include/lldb/Core/RangeMap.h @@ -280,7 +280,8 @@ if (pos != end && pos->Contains(addr)) { return std::distance(begin, pos); - } else if (pos != begin) { + } + if (pos != begin) { --pos; if (pos->Contains(addr)) return std::distance(begin, pos); @@ -302,7 +303,8 @@ if (pos != end && pos->Contains(addr)) { return &(*pos); - } else if (pos != begin) { + } + if (pos != begin) { --pos; if (pos->Contains(addr)) { return &(*pos); @@ -324,7 +326,8 @@ if (pos != end && pos->Contains(range)) { return &(*pos); - } else if (pos != begin) { + } + if (pos != begin) { --pos; if (pos->Contains(range)) { return &(*pos); @@ -515,7 +518,8 @@ if (pos != end && pos->Contains(addr)) { return std::distance(begin, pos); - } else if (pos != begin) { + } + if (pos != begin) { --pos; if (pos->Contains(addr)) return std::distance(begin, pos); @@ -537,7 +541,8 @@ if (pos != end && pos->Contains(addr)) { return &(*pos); - } else if (pos != begin) { + } + if (pos != begin) { --pos; if (pos->Contains(addr)) { return &(*pos); @@ -559,7 +564,8 @@ if (pos != end && pos->Contains(range)) { return &(*pos); - } else if (pos != begin) { + } + if (pos != begin) { --pos; if (pos->Contains(range)) { return &(*pos); @@ -616,8 +622,8 @@ if (this->base == rhs.base) { if (this->size == rhs.size) return this->data < rhs.data; - else - return this->size < rhs.size; + + return this->size < rhs.size; } return this->base < rhs.base; } @@ -730,7 +736,8 @@ if (pos != end && pos->Contains(addr)) { return std::distance(begin, pos); - } else if (pos != begin) { + } + if (pos != begin) { --pos; if (pos->Contains(addr)) return std::distance(begin, pos); @@ -754,7 +761,8 @@ if (pos != end && pos->Contains(addr)) { return &(*pos); - } else if (pos != begin) { + } + if (pos != begin) { --pos; if (pos->Contains(addr)) { return &(*pos); @@ -779,7 +787,8 @@ if (pos != end && pos->Contains(addr)) { return &(*pos); - } else if (pos != begin) { + } + if (pos != begin) { --pos; if (pos->Contains(addr)) { return &(*pos); @@ -801,7 +810,8 @@ if (pos != end && pos->Contains(range)) { return &(*pos); - } else if (pos != begin) { + } + if (pos != begin) { --pos; if (pos->Contains(range)) { return &(*pos); Index: include/lldb/Core/SearchFilter.h =================================================================== --- include/lldb/Core/SearchFilter.h +++ include/lldb/Core/SearchFilter.h @@ -276,8 +276,8 @@ enum FilterTy GetFilterTy() { if (SubclassID > FilterTy::LastKnownFilterType) return FilterTy::UnknownFilter; - else - return (enum FilterTy)SubclassID; + + return (enum FilterTy)SubclassID; } const char *GetFilterName() { return FilterTyToName(GetFilterTy()); } Index: include/lldb/Core/StructuredDataImpl.h =================================================================== --- include/lldb/Core/StructuredDataImpl.h +++ include/lldb/Core/StructuredDataImpl.h @@ -96,7 +96,8 @@ if (m_data_sp->GetType() == lldb::eStructuredDataTypeDictionary) { auto dict = m_data_sp->GetAsDictionary(); return (dict->GetSize()); - } else if (m_data_sp->GetType() == lldb::eStructuredDataTypeArray) { + } + if (m_data_sp->GetType() == lldb::eStructuredDataTypeArray) { auto array = m_data_sp->GetAsArray(); return (array->GetSize()); } else Index: include/lldb/Core/ValueObject.h =================================================================== --- include/lldb/Core/ValueObject.h +++ include/lldb/Core/ValueObject.h @@ -320,7 +320,7 @@ const bool accept_invalid_exe_ctx = false; if (!m_mod_id.IsValid()) return false; - else if (SyncWithProcessState(accept_invalid_exe_ctx)) { + if (SyncWithProcessState(accept_invalid_exe_ctx)) { if (!m_mod_id.IsValid()) return false; } Index: include/lldb/DataFormatters/FormattersContainer.h =================================================================== --- include/lldb/DataFormatters/FormattersContainer.h +++ include/lldb/DataFormatters/FormattersContainer.h @@ -278,8 +278,8 @@ if (key) return lldb::TypeNameSpecifierImplSP( new TypeNameSpecifierImpl(key.AsCString(), false)); - else - return lldb::TypeNameSpecifierImplSP(); + + return lldb::TypeNameSpecifierImplSP(); } lldb::TypeNameSpecifierImplSP @@ -328,11 +328,10 @@ if (candidate.IsMatch(entry) == false) { entry.reset(); continue; - } else { - if (reason) - *reason = candidate.GetReason(); - return true; } + if (reason) + *reason = candidate.GetReason(); + return true; } } return false; Index: include/lldb/DataFormatters/FormattersHelpers.h =================================================================== --- include/lldb/DataFormatters/FormattersHelpers.h +++ include/lldb/DataFormatters/FormattersHelpers.h @@ -92,22 +92,22 @@ bool IsNegative() const { if (ptr_size == 4) return ((int32_t)thirty_two) < 0; - else - return ((int64_t)sixty_four) < 0; + + return ((int64_t)sixty_four) < 0; } bool IsZero() const { if (ptr_size == 4) return thirty_two == 0; - else - return sixty_four == 0; + + return sixty_four == 0; } static InferiorSizedWord GetMaximum(Process &process) { if (process.GetAddressByteSize() == 4) return InferiorSizedWord(UINT32_MAX, 4); - else - return InferiorSizedWord(UINT64_MAX, 8); + + return InferiorSizedWord(UINT64_MAX, 8); } InferiorSizedWord operator>>(int rhs) const { @@ -156,18 +156,17 @@ if (ptr_size == 4) { memcpy(buffer, &thirty_two, 4); return buffer + 4; - } else { - memcpy(buffer, &sixty_four, 8); - return buffer + 8; } + memcpy(buffer, &sixty_four, 8); + return buffer + 8; } DataExtractor GetAsData(lldb::ByteOrder byte_order = lldb::eByteOrderInvalid) const { if (ptr_size == 4) return DataExtractor(&thirty_two, 4, byte_order, 4); - else - return DataExtractor(&sixty_four, 8, byte_order, 8); + + return DataExtractor(&sixty_four, 8, byte_order, 8); } private: Index: include/lldb/DataFormatters/TypeCategory.h =================================================================== --- include/lldb/DataFormatters/TypeCategory.h +++ include/lldb/DataFormatters/TypeCategory.h @@ -346,8 +346,8 @@ uint32_t GetEnabledPosition() { if (m_enabled == false) return UINT32_MAX; - else - return m_enabled_position; + + return m_enabled_position; } bool Get(ValueObject &valobj, const FormattersMatchVector &candidates, Index: include/lldb/Host/ProcessRunLock.h =================================================================== --- include/lldb/Host/ProcessRunLock.h +++ include/lldb/Host/ProcessRunLock.h @@ -49,8 +49,8 @@ if (m_lock) { if (m_lock == lock) return true; // We already have this lock locked - else - Unlock(); + + Unlock(); } if (lock) { if (lock->ReadTryLock()) { Index: include/lldb/Interpreter/CommandObject.h =================================================================== --- include/lldb/Interpreter/CommandObject.h +++ include/lldb/Interpreter/CommandObject.h @@ -324,7 +324,7 @@ if (m_command_override_callback) return m_command_override_callback(m_command_override_baton, argv, result); - else if (m_deprecated_command_override_callback) + if (m_deprecated_command_override_callback) return m_deprecated_command_override_callback(m_command_override_baton, argv); else Index: include/lldb/Symbol/ClangASTImporter.h =================================================================== --- include/lldb/Symbol/ClangASTImporter.h +++ include/lldb/Symbol/ClangASTImporter.h @@ -302,9 +302,8 @@ ASTContextMetadataSP(new ASTContextMetadata(dst_ctx)); m_metadata_map[dst_ctx] = context_md; return context_md; - } else { - return context_md_iter->second; } + return context_md_iter->second; } ASTContextMetadataSP MaybeGetContextMetadata(clang::ASTContext *dst_ctx) { @@ -312,8 +311,8 @@ if (context_md_iter != m_metadata_map.end()) return context_md_iter->second; - else - return ASTContextMetadataSP(); + + return ASTContextMetadataSP(); } MinionSP GetMinion(clang::ASTContext *dst_ctx, clang::ASTContext *src_ctx) { @@ -326,9 +325,8 @@ MinionSP minion = MinionSP(new Minion(*this, dst_ctx, src_ctx)); minions[src_ctx] = minion; return minion; - } else { - return minion_iter->second; } + return minion_iter->second; } DeclOrigin GetDeclOrigin(const clang::Decl *decl); Index: include/lldb/Symbol/ClangExternalASTSourceCommon.h =================================================================== --- include/lldb/Symbol/ClangExternalASTSourceCommon.h +++ include/lldb/Symbol/ClangExternalASTSourceCommon.h @@ -61,8 +61,8 @@ lldb::user_id_t GetUserID() const { if (m_union_is_user_id) return m_user_id; - else - return LLDB_INVALID_UID; + + return LLDB_INVALID_UID; } void SetISAPtr(uint64_t isa_ptr) { @@ -74,8 +74,8 @@ uint64_t GetISAPtr() const { if (m_union_is_isa_ptr) return m_isa_ptr; - else - return 0; + + return 0; } void SetObjectPtrName(const char *name) { @@ -92,8 +92,8 @@ if (m_has_object_ptr) { if (m_is_self) return lldb::eLanguageTypeObjC; - else - return lldb::eLanguageTypeC_plus_plus; + + return lldb::eLanguageTypeC_plus_plus; } return lldb::eLanguageTypeUnknown; } @@ -102,8 +102,8 @@ if (m_has_object_ptr) { if (m_is_self) return "self"; - else - return "this"; + + return "this"; } else return nullptr; } Index: include/lldb/Symbol/DebugMacros.h =================================================================== --- include/lldb/Symbol/DebugMacros.h +++ include/lldb/Symbol/DebugMacros.h @@ -83,8 +83,8 @@ DebugMacroEntry GetMacroEntryAtIndex(const size_t index) const { if (index < m_macro_entries.size()) return m_macro_entries[index]; - else - return DebugMacroEntry(); + + return DebugMacroEntry(); } private: Index: include/lldb/Symbol/Symbol.h =================================================================== --- include/lldb/Symbol/Symbol.h +++ include/lldb/Symbol/Symbol.h @@ -89,8 +89,8 @@ // symbol's value isn't an address. if (ValueIsAddress()) return m_addr_range.GetBaseAddress(); - else - return Address(); + + return Address(); } // When a symbol's value isn't an address, we need to access the raw value. @@ -102,10 +102,9 @@ // This symbol's value is an address. Use Symbol::GetAddress() to get the // address. return fail_value; - } else { - // The value is stored in the base address' offset - return m_addr_range.GetBaseAddress().GetOffset(); } + // The value is stored in the base address' offset + return m_addr_range.GetBaseAddress().GetOffset(); } lldb::addr_t ResolveCallableAddress(Target &target) const; Index: include/lldb/Symbol/Type.h =================================================================== --- include/lldb/Symbol/Type.h +++ include/lldb/Symbol/Type.h @@ -318,29 +318,29 @@ CompilerType GetReferenceType() const { if (type_sp) return type_sp->GetForwardCompilerType().GetLValueReferenceType(); - else - return compiler_type.GetLValueReferenceType(); + + return compiler_type.GetLValueReferenceType(); } CompilerType GetTypedefedType() const { if (type_sp) return type_sp->GetForwardCompilerType().GetTypedefedType(); - else - return compiler_type.GetTypedefedType(); + + return compiler_type.GetTypedefedType(); } CompilerType GetDereferencedType() const { if (type_sp) return type_sp->GetForwardCompilerType().GetNonReferenceType(); - else - return compiler_type.GetNonReferenceType(); + + return compiler_type.GetNonReferenceType(); } CompilerType GetUnqualifiedType() const { if (type_sp) return type_sp->GetForwardCompilerType().GetFullyUnqualifiedType(); - else - return compiler_type.GetFullyUnqualifiedType(); + + return compiler_type.GetFullyUnqualifiedType(); } CompilerType GetCanonicalType() const { Index: include/lldb/Target/ObjCLanguageRuntime.h =================================================================== --- include/lldb/Target/ObjCLanguageRuntime.h +++ include/lldb/Target/ObjCLanguageRuntime.h @@ -346,20 +346,20 @@ bool operator==(const ClassAndSel &rhs) { if (class_addr == rhs.class_addr && sel_addr == rhs.sel_addr) return true; - else - return false; + + return false; } bool operator<(const ClassAndSel &rhs) const { if (class_addr < rhs.class_addr) return true; - else if (class_addr > rhs.class_addr) + if (class_addr > rhs.class_addr) return false; else { if (sel_addr < rhs.sel_addr) return true; - else - return false; + + return false; } } Index: include/lldb/Target/Process.h =================================================================== --- include/lldb/Target/Process.h +++ include/lldb/Target/Process.h @@ -503,8 +503,8 @@ inline bool operator==(const ProcessModID &lhs, const ProcessModID &rhs) { if (lhs.StopIDEqual(rhs) && lhs.MemoryIDEqual(rhs)) return true; - else - return false; + + return false; } inline bool operator!=(const ProcessModID &lhs, const ProcessModID &rhs) { Index: include/lldb/Target/StackFrameList.h =================================================================== --- include/lldb/Target/StackFrameList.h +++ include/lldb/Target/StackFrameList.h @@ -58,8 +58,8 @@ uint32_t GetVisibleStackFrameIndex(uint32_t idx) { if (m_current_inlined_depth < UINT32_MAX) return idx - m_current_inlined_depth; - else - return idx; + + return idx; } /// Calculate and set the current inline depth. This may be used to update Index: include/lldb/Target/StopInfo.h =================================================================== --- include/lldb/Target/StopInfo.h +++ include/lldb/Target/StopInfo.h @@ -60,8 +60,8 @@ virtual bool ShouldNotify(Event *event_ptr) { if (m_override_should_notify == eLazyBoolCalculate) return DoShouldNotify(event_ptr); - else - return m_override_should_notify == eLazyBoolYes; + + return m_override_should_notify == eLazyBoolYes; } virtual void WillResume(lldb::StateType resume_state) { Index: include/lldb/Target/ThreadPlan.h =================================================================== --- include/lldb/Target/ThreadPlan.h +++ include/lldb/Target/ThreadPlan.h @@ -415,8 +415,8 @@ bool TracerExplainsStop() { if (!m_tracer_sp) return false; - else - return m_tracer_sp->TracerExplainsStop(); + + return m_tracer_sp->TracerExplainsStop(); } lldb::StateType RunState(); @@ -552,8 +552,8 @@ virtual size_t GetIterationCount() { if (!m_takes_iteration_count) return 0; - else - return m_iteration_count; + + return m_iteration_count; } protected: Index: include/lldb/Target/ThreadPlanCallFunction.h =================================================================== --- include/lldb/Target/ThreadPlanCallFunction.h +++ include/lldb/Target/ThreadPlanCallFunction.h @@ -85,8 +85,8 @@ lldb::StopInfoSP GetRealStopInfo() override { if (m_real_stop_info_sp) return m_real_stop_info_sp; - else - return GetPrivateStopInfo(); + + return GetPrivateStopInfo(); } lldb::addr_t GetStopAddress() { return m_stop_address; } Index: include/lldb/Target/ThreadSpec.h =================================================================== --- include/lldb/Target/ThreadSpec.h +++ include/lldb/Target/ThreadSpec.h @@ -66,8 +66,8 @@ bool TIDMatches(lldb::tid_t thread_id) const { if (m_tid == LLDB_INVALID_THREAD_ID || thread_id == LLDB_INVALID_THREAD_ID) return true; - else - return thread_id == m_tid; + + return thread_id == m_tid; } bool TIDMatches(Thread &thread) const; @@ -75,8 +75,8 @@ bool IndexMatches(uint32_t index) const { if (m_index == UINT32_MAX || index == UINT32_MAX) return true; - else - return index == m_index; + + return index == m_index; } bool IndexMatches(Thread &thread) const; @@ -84,7 +84,7 @@ bool NameMatches(const char *name) const { if (m_name.empty()) return true; - else if (name == nullptr) + if (name == nullptr) return false; else return m_name == name; @@ -95,7 +95,7 @@ bool QueueNameMatches(const char *queue_name) const { if (m_queue_name.empty()) return true; - else if (queue_name == nullptr) + if (queue_name == nullptr) return false; else return m_queue_name == queue_name; Index: source/API/SBAddress.cpp =================================================================== --- source/API/SBAddress.cpp +++ source/API/SBAddress.cpp @@ -83,8 +83,8 @@ lldb::addr_t SBAddress::GetFileAddress() const { if (m_opaque_ap->IsValid()) return m_opaque_ap->GetFileAddress(); - else - return LLDB_INVALID_ADDRESS; + + return LLDB_INVALID_ADDRESS; } lldb::addr_t SBAddress::GetLoadAddress(const SBTarget &target) const { Index: source/API/SBBreakpoint.cpp =================================================================== --- source/API/SBBreakpoint.cpp +++ source/API/SBBreakpoint.cpp @@ -83,7 +83,7 @@ BreakpointSP bkpt_sp = GetSP(); if (!bkpt_sp) return false; - else if (bkpt_sp->GetTarget().GetBreakpointByID(bkpt_sp->GetID())) + if (bkpt_sp->GetTarget().GetBreakpointByID(bkpt_sp->GetID())) return true; else return false; @@ -180,8 +180,8 @@ std::lock_guard guard( bkpt_sp->GetTarget().GetAPIMutex()); return bkpt_sp->IsEnabled(); - } else - return false; + } + return false; } void SBBreakpoint::SetOneShot(bool one_shot) { @@ -203,8 +203,8 @@ std::lock_guard guard( bkpt_sp->GetTarget().GetAPIMutex()); return bkpt_sp->IsOneShot(); - } else - return false; + } + return false; } bool SBBreakpoint::IsInternal() { @@ -213,8 +213,8 @@ std::lock_guard guard( bkpt_sp->GetTarget().GetAPIMutex()); return bkpt_sp->IsInternal(); - } else - return false; + } + return false; } void SBBreakpoint::SetIgnoreCount(uint32_t count) { @@ -789,8 +789,8 @@ size_t SBBreakpointList::GetSize() const { if (!m_opaque_sp) return 0; - else - return m_opaque_sp->GetSize(); + + return m_opaque_sp->GetSize(); } SBBreakpoint SBBreakpointList::GetBreakpointAtIndex(size_t idx) { Index: source/API/SBBreakpointLocation.cpp =================================================================== --- source/API/SBBreakpointLocation.cpp +++ source/API/SBBreakpointLocation.cpp @@ -65,8 +65,8 @@ BreakpointLocationSP loc_sp = GetSP(); if (loc_sp) return SBAddress(&loc_sp->GetAddress()); - else - return SBAddress(); + + return SBAddress(); } addr_t SBBreakpointLocation::GetLoadAddress() { @@ -97,8 +97,8 @@ std::lock_guard guard( loc_sp->GetTarget().GetAPIMutex()); return loc_sp->IsEnabled(); - } else - return false; + } + return false; } uint32_t SBBreakpointLocation::GetHitCount() { @@ -107,8 +107,8 @@ std::lock_guard guard( loc_sp->GetTarget().GetAPIMutex()); return loc_sp->GetHitCount(); - } else - return 0; + } + return 0; } uint32_t SBBreakpointLocation::GetIgnoreCount() { @@ -117,8 +117,8 @@ std::lock_guard guard( loc_sp->GetTarget().GetAPIMutex()); return loc_sp->GetIgnoreCount(); - } else - return 0; + } + return 0; } void SBBreakpointLocation::SetIgnoreCount(uint32_t n) { @@ -358,8 +358,8 @@ std::lock_guard guard( loc_sp->GetTarget().GetAPIMutex()); return loc_sp->GetID(); - } else - return LLDB_INVALID_BREAK_ID; + } + return LLDB_INVALID_BREAK_ID; } SBBreakpoint SBBreakpointLocation::GetBreakpoint() { Index: source/API/SBBreakpointName.cpp =================================================================== --- source/API/SBBreakpointName.cpp +++ source/API/SBBreakpointName.cpp @@ -144,9 +144,9 @@ { if (!rhs.m_impl_up) return; - else - m_impl_up.reset(new SBBreakpointNameImpl(rhs.m_impl_up->GetTarget(), - rhs.m_impl_up->GetName())); + + m_impl_up.reset(new SBBreakpointNameImpl(rhs.m_impl_up->GetTarget(), + rhs.m_impl_up->GetName())); } SBBreakpointName::~SBBreakpointName() = default; Index: source/API/SBCommandReturnObject.cpp =================================================================== --- source/API/SBCommandReturnObject.cpp +++ source/API/SBCommandReturnObject.cpp @@ -224,7 +224,8 @@ if (m_opaque_ap) { if (len == 0 || string == nullptr || *string == 0) { return; - } else if (len > 0) { + } + if (len > 0) { std::string buffer(string, len); m_opaque_ap->AppendMessage(buffer.c_str()); } else Index: source/API/SBDebugger.cpp =================================================================== --- source/API/SBDebugger.cpp +++ source/API/SBDebugger.cpp @@ -77,10 +77,10 @@ if (init_func) { if (init_func(debugger_sb)) return dynlib; - else - error.SetErrorString("plug-in refused to load " - "(lldb::PluginInitialize(lldb::SBDebugger) " - "returned false)"); + + error.SetErrorString("plug-in refused to load " + "(lldb::PluginInitialize(lldb::SBDebugger) " + "returned false)"); } else { error.SetErrorString("plug-in is missing the required initialization: " "lldb::PluginInitialize(lldb::SBDebugger)"); @@ -1172,16 +1172,16 @@ if (DataVisualization::Categories::GetCategory(ConstString(category_name), category_sp, false)) return SBTypeCategory(category_sp); - else - return SBTypeCategory(); + + return SBTypeCategory(); } SBTypeCategory SBDebugger::GetCategory(lldb::LanguageType lang_type) { TypeCategoryImplSP category_sp; if (DataVisualization::Categories::GetCategory(lang_type, category_sp)) return SBTypeCategory(category_sp); - else - return SBTypeCategory(); + + return SBTypeCategory(); } SBTypeCategory SBDebugger::CreateCategory(const char *category_name) { @@ -1193,8 +1193,8 @@ if (DataVisualization::Categories::GetCategory(ConstString(category_name), category_sp, true)) return SBTypeCategory(category_sp); - else - return SBTypeCategory(); + + return SBTypeCategory(); } bool SBDebugger::DeleteCategory(const char *category_name) { @@ -1264,8 +1264,8 @@ llvm::raw_string_ostream error_stream(error); return m_opaque_sp->EnableLog(channel, GetCategoryArray(categories), "", log_options, error_stream); - } else - return false; + } + return false; } void SBDebugger::SetLoggingCallback(lldb::LogOutputCallback log_callback, Index: source/API/SBEvent.cpp =================================================================== --- source/API/SBEvent.cpp +++ source/API/SBEvent.cpp @@ -90,8 +90,8 @@ const Event *lldb_event = get(); if (lldb_event) return lldb_event->GetBroadcaster()->GetBroadcasterClass().AsCString(); - else - return "unknown class"; + + return "unknown class"; } bool SBEvent::BroadcasterMatchesPtr(const SBBroadcaster *broadcaster) { Index: source/API/SBInstruction.cpp =================================================================== --- source/API/SBInstruction.cpp +++ source/API/SBInstruction.cpp @@ -185,8 +185,8 @@ lldb::InstructionSP SBInstruction::GetOpaque() { if (m_opaque_sp) return m_opaque_sp->GetSP(); - else - return lldb::InstructionSP(); + + return lldb::InstructionSP(); } void SBInstruction::SetOpaque(const lldb::DisassemblerSP &disasm_sp, Index: source/API/SBListener.cpp =================================================================== --- source/API/SBListener.cpp +++ source/API/SBListener.cpp @@ -71,8 +71,8 @@ BroadcastEventSpec event_spec(ConstString(broadcaster_class), event_mask); return m_opaque_sp->StartListeningForEventSpec( lldb_debugger->GetBroadcasterManager(), event_spec); - } else - return 0; + } + return 0; } bool SBListener::StopListeningForEventClass(SBDebugger &debugger, @@ -85,8 +85,8 @@ BroadcastEventSpec event_spec(ConstString(broadcaster_class), event_mask); return m_opaque_sp->StopListeningForEventSpec( lldb_debugger->GetBroadcasterManager(), event_spec); - } else - return false; + } + return false; } uint32_t SBListener::StartListeningForEvents(const SBBroadcaster &broadcaster, Index: source/API/SBProcess.cpp =================================================================== --- source/API/SBProcess.cpp +++ source/API/SBProcess.cpp @@ -524,8 +524,8 @@ process_sp->GetTarget().GetAPIMutex()); if (include_expression_stops) return process_sp->GetStopID(); - else - return process_sp->GetLastNaturalStopID(); + + return process_sp->GetLastNaturalStopID(); } return 0; } @@ -1168,13 +1168,13 @@ PlatformSP platform_sp = process_sp->GetTarget().GetPlatform(); return platform_sp->LoadImage(process_sp.get(), *sb_local_image_spec, *sb_remote_image_spec, sb_error.ref()); - } else { - if (log) - log->Printf("SBProcess(%p)::LoadImage() => error: process is running", - static_cast(process_sp.get())); - sb_error.SetErrorString("process is running"); } - } else { + if (log) + log->Printf("SBProcess(%p)::LoadImage() => error: process is running", + static_cast(process_sp.get())); + sb_error.SetErrorString("process is running"); + + } else { if (log) log->Printf("SBProcess(%p)::LoadImage() => error: called with invalid" " process", @@ -1217,21 +1217,21 @@ if (token != LLDB_INVALID_IMAGE_TOKEN) loaded_path = loaded_spec; return token; - } else { - if (log) - log->Printf("SBProcess(%p)::LoadImageUsingPaths() => error: " - "process is running", - static_cast(process_sp.get())); - error.SetErrorString("process is running"); } - } else { + if (log) + log->Printf("SBProcess(%p)::LoadImageUsingPaths() => error: " + "process is running", + static_cast(process_sp.get())); + error.SetErrorString("process is running"); + + } else { if (log) log->Printf("SBProcess(%p)::LoadImageUsingPaths() => error: " "called with invalid process", static_cast(process_sp.get())); error.SetErrorString("process is invalid"); } - + return LLDB_INVALID_IMAGE_TOKEN; } @@ -1297,13 +1297,12 @@ runtime->GetExtendedBacktraceTypes(); if (idx < names.size()) { return names[idx].AsCString(); - } else { - Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); - if (log) - log->Printf("SBProcess(%p)::GetExtendedBacktraceTypeAtIndex() => " - "error: requested extended backtrace name out of bounds", - static_cast(process_sp.get())); } + Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); + if (log) + log->Printf("SBProcess(%p)::GetExtendedBacktraceTypeAtIndex() => " + "error: requested extended backtrace name out of bounds", + static_cast(process_sp.get())); } return NULL; } Index: source/API/SBSourceManager.cpp =================================================================== --- source/API/SBSourceManager.cpp +++ source/API/SBSourceManager.cpp @@ -50,16 +50,15 @@ return target_sp->GetSourceManager().DisplaySourceLinesWithLineNumbers( file, line, column, context_before, context_after, current_line_cstr, s); - } else { - lldb::DebuggerSP debugger_sp(m_debugger_wp.lock()); - if (debugger_sp) { - return debugger_sp->GetSourceManager() - .DisplaySourceLinesWithLineNumbers(file, line, column, - context_before, context_after, - current_line_cstr, s); - } } - return 0; + lldb::DebuggerSP debugger_sp(m_debugger_wp.lock()); + if (debugger_sp) { + return debugger_sp->GetSourceManager().DisplaySourceLinesWithLineNumbers( + file, line, column, context_before, context_after, current_line_cstr, + s); + } + + return 0; } private: Index: source/API/SBThread.cpp =================================================================== --- source/API/SBThread.cpp +++ source/API/SBThread.cpp @@ -135,12 +135,10 @@ Process::StopLocker stop_locker; if (stop_locker.TryLock(&exe_ctx.GetProcessPtr()->GetRunLock())) { return exe_ctx.GetThreadPtr()->GetStopReason(); - } else { - if (log) - log->Printf( - "SBThread(%p)::GetStopReason() => error: process is running", - static_cast(exe_ctx.GetThreadPtr())); } + if (log) + log->Printf("SBThread(%p)::GetStopReason() => error: process is running", + static_cast(exe_ctx.GetThreadPtr())); } if (log) @@ -179,8 +177,8 @@ site_id)); if (bp_site_sp) return bp_site_sp->GetNumberOfOwners() * 2; - else - return 0; // Breakpoint must have cleared itself... + + return 0; // Breakpoint must have cleared itself... } break; case eStopReasonWatchpoint: @@ -239,10 +237,9 @@ if (idx & 1) { // Odd idx, return the breakpoint location ID return bp_loc_sp->GetID(); - } else { - // Even idx, return the breakpoint ID - return bp_loc_sp->GetBreakpoint().GetID(); } + // Even idx, return the breakpoint ID + return bp_loc_sp->GetBreakpoint().GetID(); } } return LLDB_INVALID_BREAK_ID; @@ -330,11 +327,11 @@ static_cast(exe_ctx.GetThreadPtr()), stop_desc); if (dst) return ::snprintf(dst, dst_len, "%s", stop_desc); - else { - // NULL dst passed in, return the length needed to contain the - // description - return ::strlen(stop_desc) + 1; // Include the NULL byte for size - } + + // NULL dst passed in, return the length needed to contain the + // description + return ::strlen(stop_desc) + 1; // Include the NULL byte for size + } else { size_t stop_desc_len = 0; switch (stop_info_sp->GetStopReason()) { @@ -1510,14 +1507,14 @@ ThreadSP thread_sp(m_opaque_sp->GetThreadSP()); if (thread_sp) return thread_sp.get(); - else - return NULL; + + return NULL; } lldb_private::Thread *SBThread::get() { ThreadSP thread_sp(m_opaque_sp->GetThreadSP()); if (thread_sp) return thread_sp.get(); - else - return NULL; + + return NULL; } Index: source/API/SBThreadPlan.cpp =================================================================== --- source/API/SBThreadPlan.cpp +++ source/API/SBThreadPlan.cpp @@ -91,8 +91,8 @@ SBThread SBThreadPlan::GetThread() const { if (m_opaque_sp) { return SBThread(m_opaque_sp->GetThread().shared_from_this()); - } else - return SBThread(); + } + return SBThread(); } bool SBThreadPlan::GetDescription(lldb::SBStream &description) const { @@ -116,22 +116,22 @@ bool SBThreadPlan::IsPlanComplete() { if (m_opaque_sp) return m_opaque_sp->IsPlanComplete(); - else - return true; + + return true; } bool SBThreadPlan::IsPlanStale() { if (m_opaque_sp) return m_opaque_sp->IsPlanStale(); - else - return true; + + return true; } bool SBThreadPlan::IsValid() { if (m_opaque_sp) return m_opaque_sp->ValidatePlan(nullptr); - else - return false; + + return false; } // This section allows an SBThreadPlan to push another of the common types of @@ -168,9 +168,8 @@ error.SetErrorString(plan_status.AsCString()); return plan; - } else { - return SBThreadPlan(); } + return SBThreadPlan(); } SBThreadPlan @@ -202,9 +201,8 @@ error.SetErrorString(plan_status.AsCString()); return plan; - } else { - return SBThreadPlan(); } + return SBThreadPlan(); } SBThreadPlan @@ -232,9 +230,8 @@ error.SetErrorString(plan_status.AsCString()); return plan; - } else { - return SBThreadPlan(); } + return SBThreadPlan(); } SBThreadPlan @@ -259,9 +256,8 @@ error.SetErrorString(plan_status.AsCString()); return plan; - } else { - return SBThreadPlan(); } + return SBThreadPlan(); } SBThreadPlan @@ -283,7 +279,6 @@ error.SetErrorString(plan_status.AsCString()); return plan; - } else { - return SBThreadPlan(); } + return SBThreadPlan(); } Index: source/API/SBTypeCategory.cpp =================================================================== --- source/API/SBTypeCategory.cpp +++ source/API/SBTypeCategory.cpp @@ -321,9 +321,9 @@ if (type_name.IsRegex()) return m_opaque_sp->GetRegexTypeFormatsContainer()->Delete( ConstString(type_name.GetName())); - else - return m_opaque_sp->GetTypeFormatsContainer()->Delete( - ConstString(type_name.GetName())); + + return m_opaque_sp->GetTypeFormatsContainer()->Delete( + ConstString(type_name.GetName())); } #ifndef LLDB_DISABLE_PYTHON @@ -395,9 +395,9 @@ if (type_name.IsRegex()) return m_opaque_sp->GetRegexTypeSummariesContainer()->Delete( ConstString(type_name.GetName())); - else - return m_opaque_sp->GetTypeSummariesContainer()->Delete( - ConstString(type_name.GetName())); + + return m_opaque_sp->GetTypeSummariesContainer()->Delete( + ConstString(type_name.GetName())); } bool SBTypeCategory::AddTypeFilter(SBTypeNameSpecifier type_name, @@ -433,9 +433,9 @@ if (type_name.IsRegex()) return m_opaque_sp->GetRegexTypeFiltersContainer()->Delete( ConstString(type_name.GetName())); - else - return m_opaque_sp->GetTypeFiltersContainer()->Delete( - ConstString(type_name.GetName())); + + return m_opaque_sp->GetTypeFiltersContainer()->Delete( + ConstString(type_name.GetName())); } #ifndef LLDB_DISABLE_PYTHON @@ -506,9 +506,9 @@ if (type_name.IsRegex()) return m_opaque_sp->GetRegexTypeSyntheticsContainer()->Delete( ConstString(type_name.GetName())); - else - return m_opaque_sp->GetTypeSyntheticsContainer()->Delete( - ConstString(type_name.GetName())); + + return m_opaque_sp->GetTypeSyntheticsContainer()->Delete( + ConstString(type_name.GetName())); } #endif // LLDB_DISABLE_PYTHON Index: source/API/SBTypeFilter.cpp =================================================================== --- source/API/SBTypeFilter.cpp +++ source/API/SBTypeFilter.cpp @@ -44,10 +44,9 @@ lldb::DescriptionLevel description_level) { if (!IsValid()) return false; - else { - description.Printf("%s\n", m_opaque_sp->GetDescription().c_str()); - return true; - } + + description.Printf("%s\n", m_opaque_sp->GetDescription().c_str()); + return true; } void SBTypeFilter::Clear() { @@ -74,8 +73,8 @@ bool SBTypeFilter::ReplaceExpressionPathAtIndex(uint32_t i, const char *item) { if (CopyOnWrite_Impl()) return m_opaque_sp->SetExpressionPathAtIndex(i, item); - else - return false; + + return false; } void SBTypeFilter::AppendExpressionPath(const char *item) { Index: source/API/SBTypeFormat.cpp =================================================================== --- source/API/SBTypeFormat.cpp +++ source/API/SBTypeFormat.cpp @@ -74,10 +74,9 @@ lldb::DescriptionLevel description_level) { if (!IsValid()) return false; - else { - description.Printf("%s\n", m_opaque_sp->GetDescription().c_str()); - return true; - } + + description.Printf("%s\n", m_opaque_sp->GetDescription().c_str()); + return true; } lldb::SBTypeFormat &SBTypeFormat::operator=(const lldb::SBTypeFormat &rhs) { @@ -99,8 +98,8 @@ if (GetFormat() == rhs.GetFormat()) return GetOptions() == rhs.GetOptions(); - else - return false; + + return false; } bool SBTypeFormat::operator!=(lldb::SBTypeFormat &rhs) { Index: source/API/SBTypeSummary.cpp =================================================================== --- source/API/SBTypeSummary.cpp +++ source/API/SBTypeSummary.cpp @@ -188,8 +188,9 @@ if (ftext && *ftext) return ftext; return fname; - } else if (StringSummaryFormat *string_summary_ptr = - llvm::dyn_cast(m_opaque_sp.get())) + } + if (StringSummaryFormat *string_summary_ptr = + llvm::dyn_cast(m_opaque_sp.get())) return string_summary_ptr->GetSummaryString(); return nullptr; } @@ -240,10 +241,9 @@ lldb::DescriptionLevel description_level) { if (!CopyOnWrite_Impl()) return false; - else { - description.Printf("%s\n", m_opaque_sp->GetDescription().c_str()); - return true; - } + + description.Printf("%s\n", m_opaque_sp->GetDescription().c_str()); + return true; } bool SBTypeSummary::DoesPrintValue(lldb::SBValue value) { @@ -275,9 +275,9 @@ // invalid and valid are different if (rhs.IsValid()) return false; - else - // both invalid are the same - return true; + + // both invalid are the same + return true; } if (m_opaque_sp->GetKind() != rhs.m_opaque_sp->GetKind()) Index: source/API/SBTypeSynthetic.cpp =================================================================== --- source/API/SBTypeSynthetic.cpp +++ source/API/SBTypeSynthetic.cpp @@ -62,8 +62,8 @@ return NULL; if (IsClassCode()) return m_opaque_sp->GetPythonCode(); - else - return m_opaque_sp->GetPythonClassName(); + + return m_opaque_sp->GetPythonClassName(); } void SBTypeSynthetic::SetClassName(const char *data) { Index: source/API/SBValue.cpp =================================================================== --- source/API/SBValue.cpp +++ source/API/SBValue.cpp @@ -85,24 +85,23 @@ bool IsValid() { if (m_valobj_sp.get() == NULL) return false; - else { - // FIXME: This check is necessary but not sufficient. We for sure don't - // want to touch SBValues whose owning - // targets have gone away. This check is a little weak in that it - // enforces that restriction when you call IsValid, but since IsValid - // doesn't lock the target, you have no guarantee that the SBValue won't - // go invalid after you call this... Also, an SBValue could depend on - // data from one of the modules in the target, and those could go away - // independently of the target, for instance if a module is unloaded. - // But right now, neither SBValues nor ValueObjects know which modules - // they depend on. So I have no good way to make that check without - // tracking that in all the ValueObject subclasses. - TargetSP target_sp = m_valobj_sp->GetTargetSP(); - if (target_sp && target_sp->IsValid()) - return true; - else - return false; - } + + // FIXME: This check is necessary but not sufficient. We for sure don't + // want to touch SBValues whose owning + // targets have gone away. This check is a little weak in that it + // enforces that restriction when you call IsValid, but since IsValid + // doesn't lock the target, you have no guarantee that the SBValue won't + // go invalid after you call this... Also, an SBValue could depend on + // data from one of the modules in the target, and those could go away + // independently of the target, for instance if a module is unloaded. + // But right now, neither SBValues nor ValueObjects know which modules + // they depend on. So I have no good way to make that check without + // tracking that in all the ValueObject subclasses. + TargetSP target_sp = m_valobj_sp->GetTargetSP(); + if (target_sp && target_sp->IsValid()) + return true; + + return false; } lldb::ValueObjectSP GetRootSP() { return m_valobj_sp; } @@ -173,29 +172,29 @@ TargetSP GetTargetSP() { if (m_valobj_sp) return m_valobj_sp->GetTargetSP(); - else - return TargetSP(); + + return TargetSP(); } ProcessSP GetProcessSP() { if (m_valobj_sp) return m_valobj_sp->GetProcessSP(); - else - return ProcessSP(); + + return ProcessSP(); } ThreadSP GetThreadSP() { if (m_valobj_sp) return m_valobj_sp->GetThreadSP(); - else - return ThreadSP(); + + return ThreadSP(); } StackFrameSP GetFrameSP() { if (m_valobj_sp) return m_valobj_sp->GetFrameSP(); - else - return StackFrameSP(); + + return StackFrameSP(); } private: @@ -1013,9 +1012,9 @@ if (!success) error.SetErrorString("could not resolve value"); return ret_val; - } else - error.SetErrorStringWithFormat("could not get SBValue: %s", - locker.GetError().AsCString()); + } + error.SetErrorStringWithFormat("could not get SBValue: %s", + locker.GetError().AsCString()); return fail_value; } @@ -1031,9 +1030,9 @@ if (!success) error.SetErrorString("could not resolve value"); return ret_val; - } else - error.SetErrorStringWithFormat("could not get SBValue: %s", - locker.GetError().AsCString()); + } + error.SetErrorStringWithFormat("could not get SBValue: %s", + locker.GetError().AsCString()); return fail_value; } Index: source/API/SBWatchpoint.cpp =================================================================== --- source/API/SBWatchpoint.cpp +++ source/API/SBWatchpoint.cpp @@ -144,8 +144,8 @@ std::lock_guard guard( watchpoint_sp->GetTarget().GetAPIMutex()); return watchpoint_sp->IsEnabled(); - } else - return false; + } + return false; } uint32_t SBWatchpoint::GetHitCount() { @@ -171,8 +171,8 @@ std::lock_guard guard( watchpoint_sp->GetTarget().GetAPIMutex()); return watchpoint_sp->GetIgnoreCount(); - } else - return 0; + } + return 0; } void SBWatchpoint::SetIgnoreCount(uint32_t n) { Index: source/Breakpoint/Breakpoint.cpp =================================================================== --- source/Breakpoint/Breakpoint.cpp +++ source/Breakpoint/Breakpoint.cpp @@ -331,8 +331,8 @@ // to find & decrement it, we only have to decrement our own ignore count. DecrementIgnoreCount(); return false; - } else - return true; + } + return true; } uint32_t Breakpoint::GetHitCount() const { return m_hit_count; } @@ -362,8 +362,8 @@ lldb::tid_t Breakpoint::GetThreadID() const { if (m_options_up->GetThreadSpecNoCreate() == nullptr) return LLDB_INVALID_THREAD_ID; - else - return m_options_up->GetThreadSpecNoCreate()->GetTID(); + + return m_options_up->GetThreadSpecNoCreate()->GetTID(); } void Breakpoint::SetThreadIndex(uint32_t index) { @@ -377,8 +377,8 @@ uint32_t Breakpoint::GetThreadIndex() const { if (m_options_up->GetThreadSpecNoCreate() == nullptr) return 0; - else - return m_options_up->GetThreadSpecNoCreate()->GetIndex(); + + return m_options_up->GetThreadSpecNoCreate()->GetIndex(); } void Breakpoint::SetThreadName(const char *thread_name) { @@ -393,8 +393,8 @@ const char *Breakpoint::GetThreadName() const { if (m_options_up->GetThreadSpecNoCreate() == nullptr) return nullptr; - else - return m_options_up->GetThreadSpecNoCreate()->GetName(); + + return m_options_up->GetThreadSpecNoCreate()->GetName(); } void Breakpoint::SetQueueName(const char *queue_name) { @@ -409,8 +409,8 @@ const char *Breakpoint::GetQueueName() const { if (m_options_up->GetThreadSpecNoCreate() == nullptr) return nullptr; - else - return m_options_up->GetThreadSpecNoCreate()->GetQueueName(); + + return m_options_up->GetThreadSpecNoCreate()->GetQueueName(); } void Breakpoint::SetCondition(const char *condition) { @@ -872,8 +872,8 @@ if (level == eDescriptionLevelBrief) { s->PutCString(GetBreakpointKind()); return; - } else - s->Printf("Kind: %s\n", GetBreakpointKind()); + } + s->Printf("Kind: %s\n", GetBreakpointKind()); } const size_t num_locations = GetNumLocations(); @@ -1085,8 +1085,8 @@ if (data == nullptr) return eBreakpointEventTypeInvalidType; - else - return data->GetBreakpointEventType(); + + return data->GetBreakpointEventType(); } BreakpointSP Breakpoint::BreakpointEventData::GetBreakpointFromEvent( Index: source/Breakpoint/BreakpointIDList.cpp =================================================================== --- source/Breakpoint/BreakpointIDList.cpp +++ source/Breakpoint/BreakpointIDList.cpp @@ -146,8 +146,8 @@ result.AppendError(error.AsCString()); result.SetStatus(eReturnStatusFailed); return; - } else - names_found.insert(current_arg); + } + names_found.insert(current_arg); } else if ((i + 2 < old_args.size()) && BreakpointID::IsRangeIdentifier(old_args[i + 1].ref) && BreakpointID::IsValidIDExpression(current_arg) && Index: source/Breakpoint/BreakpointLocation.cpp =================================================================== --- source/Breakpoint/BreakpointLocation.cpp +++ source/Breakpoint/BreakpointLocation.cpp @@ -59,8 +59,8 @@ const { if (m_options_ap && m_options_ap->IsOptionSet(kind)) return m_options_ap.get(); - else - return m_owner.GetOptions(); + + return m_owner.GetOptions(); } Address &BreakpointLocation::GetAddress() { return m_address; } @@ -72,7 +72,7 @@ bool BreakpointLocation::IsEnabled() const { if (!m_owner.IsEnabled()) return false; - else if (m_options_ap.get() != nullptr) + if (m_options_ap.get() != nullptr) return m_options_ap->IsEnabled(); else return true; @@ -93,8 +93,8 @@ if (m_options_ap && m_options_ap->IsOptionSet(BreakpointOptions::eAutoContinue)) return m_options_ap->IsAutoContinue(); - else - return m_owner.IsAutoContinue(); + + return m_owner.IsAutoContinue(); } void BreakpointLocation::SetAutoContinue(bool auto_continue) { @@ -120,8 +120,8 @@ ->GetThreadSpecNoCreate(); if (thread_spec) return thread_spec->GetTID(); - else - return LLDB_INVALID_THREAD_ID; + + return LLDB_INVALID_THREAD_ID; } void BreakpointLocation::SetThreadIndex(uint32_t index) { @@ -142,8 +142,8 @@ ->GetThreadSpecNoCreate(); if (thread_spec) return thread_spec->GetIndex(); - else - return 0; + + return 0; } void BreakpointLocation::SetThreadName(const char *thread_name) { @@ -164,8 +164,8 @@ ->GetThreadSpecNoCreate(); if (thread_spec) return thread_spec->GetName(); - else - return nullptr; + + return nullptr; } void BreakpointLocation::SetQueueName(const char *queue_name) { @@ -186,15 +186,15 @@ ->GetThreadSpecNoCreate(); if (thread_spec) return thread_spec->GetQueueName(); - else - return nullptr; + + return nullptr; } bool BreakpointLocation::InvokeCallback(StoppointCallbackContext *context) { if (m_options_ap.get() != nullptr && m_options_ap->HasCallback()) return m_options_ap->InvokeCallback(context, m_owner.GetID(), GetID()); - else - return m_owner.InvokeCallback(context, GetID()); + + return m_owner.InvokeCallback(context, GetID()); } void BreakpointLocation::SetCallback(BreakpointHitCallback callback, Index: source/Breakpoint/BreakpointLocationList.cpp =================================================================== --- source/Breakpoint/BreakpointLocationList.cpp +++ source/Breakpoint/BreakpointLocationList.cpp @@ -74,8 +74,8 @@ std::lower_bound(m_locations.begin(), end, break_id, Compare); if (pos != end && (*pos)->GetID() == break_id) return *(pos); - else - return BreakpointLocationSP(); + + return BreakpointLocationSP(); } size_t BreakpointLocationList::FindInModule( Index: source/Breakpoint/BreakpointOptions.cpp =================================================================== --- source/Breakpoint/BreakpointOptions.cpp +++ source/Breakpoint/BreakpointOptions.cpp @@ -104,8 +104,8 @@ if (found_something) return data_up; - else - return std::unique_ptr(); + + return std::unique_ptr(); } const char *BreakpointOptions::g_option_names[( @@ -470,7 +470,8 @@ return m_callback(m_callback_baton_sp ? m_callback_baton_sp->data() : nullptr, context, break_id, break_loc_id); - } else if (IsCallbackSynchronous()) { + } + if (IsCallbackSynchronous()) { // If a synchronous callback is called at async time, it should not say // to stop. return false; @@ -516,9 +517,8 @@ *hash = m_condition_text_hash; return m_condition_text.c_str(); - } else { - return nullptr; } + return nullptr; } const ThreadSpec *BreakpointOptions::GetThreadSpecNoCreate() const { Index: source/Breakpoint/BreakpointResolver.cpp =================================================================== --- source/Breakpoint/BreakpointResolver.cpp +++ source/Breakpoint/BreakpointResolver.cpp @@ -143,11 +143,10 @@ if (!error.Success()) { return result_sp; - } else { - // Add on the global offset option: - resolver->SetOffset(offset); - return BreakpointResolverSP(resolver); } + // Add on the global offset option: + resolver->SetOffset(offset); + return BreakpointResolverSP(resolver); } StructuredData::DictionarySP BreakpointResolver::WrapOptionsDict( Index: source/Breakpoint/BreakpointResolverName.cpp =================================================================== --- source/Breakpoint/BreakpointResolverName.cpp +++ source/Breakpoint/BreakpointResolverName.cpp @@ -130,13 +130,13 @@ RegularExpression regex(regex_text); return new BreakpointResolverName(bkpt, regex, language, offset, skip_prologue); - } else { - StructuredData::Array *names_array; - success = options_dict.GetValueForKeyAsArray( - GetKey(OptionNames::SymbolNameArray), names_array); - if (!success) { - error.SetErrorStringWithFormat("BRN::CFSD: Missing symbol names entry."); - return nullptr; + } + StructuredData::Array *names_array; + success = options_dict.GetValueForKeyAsArray( + GetKey(OptionNames::SymbolNameArray), names_array); + if (!success) { + error.SetErrorStringWithFormat("BRN::CFSD: Missing symbol names entry."); + return nullptr; } StructuredData::Array *names_mask_array; success = options_dict.GetValueForKeyAsArray( @@ -186,7 +186,6 @@ resolver->AddNameLookup(ConstString(names[i]), name_masks[i]); } return resolver; - } } StructuredData::ObjectSP BreakpointResolverName::SerializeToStructuredData() { Index: source/Breakpoint/BreakpointResolverScripted.cpp =================================================================== --- source/Breakpoint/BreakpointResolverScripted.cpp +++ source/Breakpoint/BreakpointResolverScripted.cpp @@ -144,8 +144,8 @@ &context); if (should_continue) return Searcher::eCallbackReturnContinue; - else - return Searcher::eCallbackReturnStop; + + return Searcher::eCallbackReturnStop; } lldb::SearchDepth Index: source/Breakpoint/BreakpointSiteList.cpp =================================================================== --- source/Breakpoint/BreakpointSiteList.cpp +++ source/Breakpoint/BreakpointSiteList.cpp @@ -30,9 +30,8 @@ if (iter == m_bp_site_list.end()) { m_bp_site_list.insert(iter, collection::value_type(bp_site_load_addr, bp)); return bp->GetID(); - } else { - return LLDB_INVALID_BREAK_ID; } + return LLDB_INVALID_BREAK_ID; } bool BreakpointSiteList::ShouldStop(StoppointCallbackContext *context, Index: source/Breakpoint/Watchpoint.cpp =================================================================== --- source/Breakpoint/Watchpoint.cpp +++ source/Breakpoint/Watchpoint.cpp @@ -295,8 +295,8 @@ const char *Watchpoint::GetConditionText() const { if (m_condition_ap.get()) return m_condition_ap->GetUserText(); - else - return nullptr; + + return nullptr; } void Watchpoint::SendWatchpointChangedEvent( @@ -366,8 +366,8 @@ if (data == nullptr) return eWatchpointEventTypeInvalidType; - else - return data->GetWatchpointEventType(); + + return data->GetWatchpointEventType(); } WatchpointSP Watchpoint::WatchpointEventData::GetWatchpointFromEvent( Index: source/Breakpoint/WatchpointOptions.cpp =================================================================== --- source/Breakpoint/WatchpointOptions.cpp +++ source/Breakpoint/WatchpointOptions.cpp @@ -105,8 +105,8 @@ return m_callback(m_callback_baton_sp ? m_callback_baton_sp->data() : nullptr, context, watch_id); - } else - return true; + } + return true; } bool WatchpointOptions::HasCallback() { Index: source/Commands/CommandCompletions.cpp =================================================================== --- source/Commands/CommandCompletions.cpp +++ source/Commands/CommandCompletions.cpp @@ -62,9 +62,9 @@ for (int i = 0;; i++) { if (g_common_completions[i].type == eNoCompletion) break; - else if ((g_common_completions[i].type & completion_mask) == - g_common_completions[i].type && - g_common_completions[i].callback != nullptr) { + if ((g_common_completions[i].type & completion_mask) == + g_common_completions[i].type && + g_common_completions[i].callback != nullptr) { handled = true; g_common_completions[i].callback(interpreter, request, searcher); } Index: source/Commands/CommandObjectBreakpoint.cpp =================================================================== --- source/Commands/CommandObjectBreakpoint.cpp +++ source/Commands/CommandObjectBreakpoint.cpp @@ -811,9 +811,8 @@ "No files provided and could not find default file."); result.SetStatus(eReturnStatusFailed); return false; - } else { - m_options.m_filenames.Append(file); } + m_options.m_filenames.Append(file); } RegularExpression regexp(m_options.m_source_text_regexp); @@ -935,7 +934,8 @@ "No selected frame to use to find the default file."); result.SetStatus(eReturnStatusFailed); return false; - } else if (!cur_frame->HasDebugInformation()) { + } + if (!cur_frame->HasDebugInformation()) { result.AppendError("Cannot use the selected frame to find the default " "file, it has no debug info."); result.SetStatus(eReturnStatusFailed); Index: source/Commands/CommandObjectCommands.cpp =================================================================== --- source/Commands/CommandObjectCommands.cpp +++ source/Commands/CommandObjectCommands.cpp @@ -617,7 +617,8 @@ original_raw_command_string.str().c_str()); result.SetStatus(eReturnStatusFailed); return false; - } else if (!cmd_obj->WantsRawCommandString()) { + } + if (!cmd_obj->WantsRawCommandString()) { // Note that args was initialized with the original command, and has not // been updated to this point. Therefore can we pass it to the version of // Execute that does not need/expect raw input in the alias. Index: source/Commands/CommandObjectDisassemble.cpp =================================================================== --- source/Commands/CommandObjectDisassemble.cpp +++ source/Commands/CommandObjectDisassemble.cpp @@ -283,9 +283,9 @@ m_options.arch.GetArchitectureName()); result.SetStatus(eReturnStatusFailed); return false; - } else if (flavor_string != nullptr && - !disassembler->FlavorValidForArchSpec(m_options.arch, - flavor_string)) + } + if (flavor_string != nullptr && + !disassembler->FlavorValidForArchSpec(m_options.arch, flavor_string)) result.AppendWarningWithFormat( "invalid disassembler flavor \"%s\", using default.\n", flavor_string); Index: source/Commands/CommandObjectFrame.cpp =================================================================== --- source/Commands/CommandObjectFrame.cpp +++ source/Commands/CommandObjectFrame.cpp @@ -345,8 +345,8 @@ result.AppendError("Already at the bottom of the stack."); result.SetStatus(eReturnStatusFailed); return false; - } else - frame_idx = 0; + } + frame_idx = 0; } } else if (m_options.relative_frame_offset > 0) { // I don't want "up 20" where "20" takes you past the top of the stack @@ -364,8 +364,8 @@ result.AppendError("Already at the top of the stack."); result.SetStatus(eReturnStatusFailed); return false; - } else - frame_idx = num_frames - 1; + } + frame_idx = num_frames - 1; } } } else { Index: source/Commands/CommandObjectHelp.cpp =================================================================== --- source/Commands/CommandObjectHelp.cpp +++ source/Commands/CommandObjectHelp.cpp @@ -122,16 +122,15 @@ if (!sub_cmd_obj->IsMultiwordObject()) { all_okay = false; break; - } else { - CommandObject *found_cmd; - found_cmd = - sub_cmd_obj->GetSubcommandObject(sub_command.c_str(), &matches); - if (found_cmd == nullptr || matches.GetSize() > 1) { - all_okay = false; - break; - } else - sub_cmd_obj = found_cmd; } + CommandObject *found_cmd; + found_cmd = + sub_cmd_obj->GetSubcommandObject(sub_command.c_str(), &matches); + if (found_cmd == nullptr || matches.GetSize() > 1) { + all_okay = false; + break; + } + sub_cmd_obj = found_cmd; } if (!all_okay || (sub_cmd_obj == nullptr)) { @@ -148,7 +147,8 @@ result.AppendError(s.GetString()); result.SetStatus(eReturnStatusFailed); return false; - } else if (!sub_cmd_obj) { + } + if (!sub_cmd_obj) { StreamString error_msg_stream; GenerateAdditionalHelpAvenuesMessage( &error_msg_stream, cmd_string.c_str(), @@ -209,20 +209,18 @@ // Return the completions of the commands in the help system: if (request.GetCursorIndex() == 0) { return m_interpreter.HandleCompletionMatches(request); - } else { - CommandObject *cmd_obj = - m_interpreter.GetCommandObject(request.GetParsedLine()[0].ref); + } + CommandObject *cmd_obj = + m_interpreter.GetCommandObject(request.GetParsedLine()[0].ref); - // The command that they are getting help on might be ambiguous, in which - // case we should complete that, otherwise complete with the command the - // user is getting help on... + // The command that they are getting help on might be ambiguous, in which + // case we should complete that, otherwise complete with the command the + // user is getting help on... - if (cmd_obj) { - request.GetParsedLine().Shift(); - request.SetCursorIndex(request.GetCursorIndex() - 1); - return cmd_obj->HandleCompletion(request); - } else { - return m_interpreter.HandleCompletionMatches(request); + if (cmd_obj) { + request.GetParsedLine().Shift(); + request.SetCursorIndex(request.GetCursorIndex() - 1); + return cmd_obj->HandleCompletion(request); } - } + return m_interpreter.HandleCompletionMatches(request); } Index: source/Commands/CommandObjectMemory.cpp =================================================================== --- source/Commands/CommandObjectMemory.cpp +++ source/Commands/CommandObjectMemory.cpp @@ -506,10 +506,9 @@ view_as_type_cstr); result.SetStatus(eReturnStatusFailed); return false; - } else { - TypeSP type_sp(type_list.GetTypeAtIndex(0)); - clang_ast_type = type_sp->GetFullCompilerType(); } + TypeSP type_sp(type_list.GetTypeAtIndex(0)); + clang_ast_type = type_sp->GetFullCompilerType(); } while (pointer_count > 0) { @@ -605,7 +604,8 @@ result.AppendError(error.AsCString()); result.SetStatus(eReturnStatusFailed); return false; - } else if (end_addr <= addr) { + } + if (end_addr <= addr) { result.AppendErrorWithFormat( "end address (0x%" PRIx64 ") must be greater that the start address (0x%" PRIx64 ").\n", @@ -779,13 +779,13 @@ "%zi bytes %s to '%s'\n", bytes_written, append ? "appended" : "written", path.c_str()); return true; - } else { - result.AppendErrorWithFormat("Failed to write %" PRIu64 - " bytes to '%s'.\n", - (uint64_t)bytes_read, path.c_str()); - result.SetStatus(eReturnStatusFailed); - return false; } + result.AppendErrorWithFormat("Failed to write %" PRIu64 + " bytes to '%s'.\n", + (uint64_t)bytes_read, path.c_str()); + result.SetStatus(eReturnStatusFailed); + return false; + } else { // We are going to write ASCII to the file just point the // output_stream to our outfile_stream... @@ -1166,8 +1166,8 @@ j--; if (j < 0) return low + s; - else - s += bad_char_heuristic[iterator[s + buffer_size - 1]]; + + s += bad_char_heuristic[iterator[s + buffer_size - 1]]; } return LLDB_INVALID_ADDRESS; @@ -1392,7 +1392,8 @@ result.SetStatus(eReturnStatusFailed); } return result.Succeeded(); - } else if (item_byte_size == 0) { + } + if (item_byte_size == 0) { if (m_format_options.GetFormat() == eFormatPointer) item_byte_size = buffer.GetAddressByteSize(); else @@ -1455,7 +1456,8 @@ "'%s' is not a valid hex string value.\n", entry.c_str()); result.SetStatus(eReturnStatusFailed); return false; - } else if (!UIntValueIsValidForSize(uval64, item_byte_size)) { + } + if (!UIntValueIsValidForSize(uval64, item_byte_size)) { result.AppendErrorWithFormat("Value 0x%" PRIx64 " is too large to fit in a %" PRIu64 " byte unsigned integer value.\n", @@ -1577,13 +1579,12 @@ buffer.GetString().size(), error) == buffer.GetString().size()) return true; - else { - result.AppendErrorWithFormat("Memory write to 0x%" PRIx64 - " failed: %s.\n", - addr, error.AsCString()); - result.SetStatus(eReturnStatusFailed); - return false; - } + + result.AppendErrorWithFormat("Memory write to 0x%" PRIx64 + " failed: %s.\n", + addr, error.AsCString()); + result.SetStatus(eReturnStatusFailed); + return false; } return true; } Index: source/Commands/CommandObjectMultiword.cpp =================================================================== --- source/Commands/CommandObjectMultiword.cpp +++ source/Commands/CommandObjectMultiword.cpp @@ -211,21 +211,19 @@ } } return new_matches.GetSize(); - } else { - StringList new_matches; - CommandObject *sub_command_object = GetSubcommandObject(arg0, &new_matches); - if (sub_command_object == nullptr) { - request.AddCompletions(new_matches); - return request.GetNumberOfMatches(); - } else { - // Remove the one match that we got from calling GetSubcommandObject. - new_matches.DeleteStringAtIndex(0); - request.AddCompletions(new_matches); - request.GetParsedLine().Shift(); - request.SetCursorIndex(request.GetCursorIndex() - 1); - return sub_command_object->HandleCompletion(request); - } } + StringList new_matches; + CommandObject *sub_command_object = GetSubcommandObject(arg0, &new_matches); + if (sub_command_object == nullptr) { + request.AddCompletions(new_matches); + return request.GetNumberOfMatches(); + } + // Remove the one match that we got from calling GetSubcommandObject. + new_matches.DeleteStringAtIndex(0); + request.AddCompletions(new_matches); + request.GetParsedLine().Shift(); + request.SetCursorIndex(request.GetCursorIndex() - 1); + return sub_command_object->HandleCompletion(request); } const char *CommandObjectMultiword::GetRepeatCommand(Args ¤t_command_args, Index: source/Commands/CommandObjectPlatform.cpp =================================================================== --- source/Commands/CommandObjectPlatform.cpp +++ source/Commands/CommandObjectPlatform.cpp @@ -1449,19 +1449,18 @@ entry.ref.str().c_str()); result.SetStatus(eReturnStatusFailed); break; - } else { - ProcessInstanceInfo proc_info; - if (platform_sp->GetProcessInfo(pid, proc_info)) { - ostrm.Printf("Process information for process %" PRIu64 ":\n", - pid); - proc_info.Dump(ostrm, platform_sp.get()); + } + ProcessInstanceInfo proc_info; + if (platform_sp->GetProcessInfo(pid, proc_info)) { + ostrm.Printf("Process information for process %" PRIu64 ":\n", + pid); + proc_info.Dump(ostrm, platform_sp.get()); } else { ostrm.Printf("error: no process information is available for " "process %" PRIu64 "\n", pid); } ostrm.EOL(); - } } } else { // Not connected... Index: source/Commands/CommandObjectProcess.cpp =================================================================== --- source/Commands/CommandObjectProcess.cpp +++ source/Commands/CommandObjectProcess.cpp @@ -68,29 +68,27 @@ if (!m_interpreter.Confirm(message, true)) { result.SetStatus(eReturnStatusFailed); return false; + } + if (process->GetShouldDetach()) { + bool keep_stopped = false; + Status detach_error(process->Detach(keep_stopped)); + if (detach_error.Success()) { + result.SetStatus(eReturnStatusSuccessFinishResult); + process = nullptr; + } else { + result.AppendErrorWithFormat("Failed to detach from process: %s\n", + detach_error.AsCString()); + result.SetStatus(eReturnStatusFailed); + } } else { - if (process->GetShouldDetach()) { - bool keep_stopped = false; - Status detach_error(process->Detach(keep_stopped)); - if (detach_error.Success()) { - result.SetStatus(eReturnStatusSuccessFinishResult); - process = nullptr; - } else { - result.AppendErrorWithFormat( - "Failed to detach from process: %s\n", - detach_error.AsCString()); - result.SetStatus(eReturnStatusFailed); - } + Status destroy_error(process->Destroy(false)); + if (destroy_error.Success()) { + result.SetStatus(eReturnStatusSuccessFinishResult); + process = nullptr; } else { - Status destroy_error(process->Destroy(false)); - if (destroy_error.Success()) { - result.SetStatus(eReturnStatusSuccessFinishResult); - process = nullptr; - } else { - result.AppendErrorWithFormat("Failed to kill process: %s\n", - destroy_error.AsCString()); - result.SetStatus(eReturnStatusFailed); - } + result.AppendErrorWithFormat("Failed to kill process: %s\n", + destroy_error.AsCString()); + result.SetStatus(eReturnStatusFailed); } } } @@ -1084,20 +1082,19 @@ entry.ref.str().c_str()); result.SetStatus(eReturnStatusFailed); break; - } else { - Status error(process->GetTarget().GetPlatform()->UnloadImage( - process, image_token)); - if (error.Success()) { - result.AppendMessageWithFormat( - "Unloading shared library with index %u...ok\n", image_token); - result.SetStatus(eReturnStatusSuccessFinishResult); + } + Status error(process->GetTarget().GetPlatform()->UnloadImage( + process, image_token)); + if (error.Success()) { + result.AppendMessageWithFormat( + "Unloading shared library with index %u...ok\n", image_token); + result.SetStatus(eReturnStatusSuccessFinishResult); } else { result.AppendErrorWithFormat("failed to unload image: %s", error.AsCString()); result.SetStatus(eReturnStatusFailed); break; } - } } return result.Succeeded(); } Index: source/Commands/CommandObjectSettings.cpp =================================================================== --- source/Commands/CommandObjectSettings.cpp +++ source/Commands/CommandObjectSettings.cpp @@ -243,9 +243,8 @@ result.AppendError(error.AsCString()); result.SetStatus(eReturnStatusFailed); return false; - } else { - result.SetStatus(eReturnStatusSuccessFinishResult); } + result.SetStatus(eReturnStatusSuccessFinishResult); return result.Succeeded(); } @@ -793,9 +792,8 @@ result.AppendError(error.AsCString()); result.SetStatus(eReturnStatusFailed); return false; - } else { - result.SetStatus(eReturnStatusSuccessFinishNoResult); } + result.SetStatus(eReturnStatusSuccessFinishNoResult); return result.Succeeded(); } Index: source/Commands/CommandObjectSource.cpp =================================================================== --- source/Commands/CommandObjectSource.cpp +++ source/Commands/CommandObjectSource.cpp @@ -543,7 +543,8 @@ result.AppendError( "No selected frame to use to find the default source."); return false; - } else if (!cur_frame->HasDebugInformation()) { + } + if (!cur_frame->HasDebugInformation()) { result.AppendError("No debug info for the selected frame."); return false; } else { @@ -887,11 +888,10 @@ return target->GetSourceManager().DisplaySourceLinesWithLineNumbers( start_file, line_no, column, 0, m_options.num_lines, "", &result.GetOutputStream(), GetBreakpointLocations()); - } else { - result.AppendErrorWithFormat( - "Could not find function info for: \"%s\".\n", - m_options.symbol_name.c_str()); } + result.AppendErrorWithFormat("Could not find function info for: \"%s\".\n", + m_options.symbol_name.c_str()); + return 0; } @@ -1039,7 +1039,8 @@ } } return result.Succeeded(); - } else if (m_options.address != LLDB_INVALID_ADDRESS) { + } + if (m_options.address != LLDB_INVALID_ADDRESS) { Address so_addr; StreamString error_strm; SymbolContextList sc_list; @@ -1236,8 +1237,8 @@ if (test_cu_spec != static_cast(sc.comp_unit)) got_multiple = true; break; - } else - test_cu_spec = sc.comp_unit; + } + test_cu_spec = sc.comp_unit; } } if (got_multiple) { Index: source/Commands/CommandObjectTarget.cpp =================================================================== --- source/Commands/CommandObjectTarget.cpp +++ source/Commands/CommandObjectTarget.cpp @@ -428,12 +428,12 @@ error.AsCString("can't find plug-in for core file")); result.SetStatus(eReturnStatusFailed); return false; - } else { - result.AppendMessageWithFormat( - "Core file '%s' (%s) was loaded.\n", core_path, - target_sp->GetArchitecture().GetArchitectureName()); - result.SetStatus(eReturnStatusSuccessFinishNoResult); } + result.AppendMessageWithFormat( + "Core file '%s' (%s) was loaded.\n", core_path, + target_sp->GetArchitecture().GetArchitectureName()); + result.SetStatus(eReturnStatusSuccessFinishNoResult); + } else { result.AppendErrorWithFormat( "Unable to find process plug-in for core file '%s'\n", @@ -885,21 +885,20 @@ "error: can't find global variable '%s'\n", arg); result.SetStatus(eReturnStatusFailed); return false; - } else { - for (uint32_t global_idx = 0; global_idx < matches; ++global_idx) { - VariableSP var_sp(variable_list.GetVariableAtIndex(global_idx)); - if (var_sp) { - ValueObjectSP valobj_sp( - valobj_list.GetValueObjectAtIndex(global_idx)); - if (!valobj_sp) - valobj_sp = ValueObjectVariable::Create( - m_exe_ctx.GetBestExecutionContextScope(), var_sp); - - if (valobj_sp) - DumpValueObject(s, var_sp, valobj_sp, - use_var_name ? var_sp->GetName().GetCString() - : arg); - } + } + for (uint32_t global_idx = 0; global_idx < matches; ++global_idx) { + VariableSP var_sp(variable_list.GetVariableAtIndex(global_idx)); + if (var_sp) { + ValueObjectSP valobj_sp( + valobj_list.GetValueObjectAtIndex(global_idx)); + if (!valobj_sp) + valobj_sp = ValueObjectVariable::Create( + m_exe_ctx.GetBestExecutionContextScope(), var_sp); + + if (valobj_sp) + DumpValueObject(s, var_sp, valobj_sp, + use_var_name ? var_sp->GetName().GetCString() + : arg); } } } @@ -1383,10 +1382,9 @@ std::string fullpath = file_spec_ptr->GetPath(); strm.Printf("%-*s", width, fullpath.c_str()); return; - } else { - file_spec_ptr->Dump(&strm); - return; } + file_spec_ptr->Dump(&strm); + return; } // Keep the width spacing correct if things go wrong... if (width > 0) @@ -1524,7 +1522,7 @@ if (target && !target->GetSectionLoadList().IsEmpty()) { if (!target->GetSectionLoadList().ResolveLoadAddress(addr, so_addr)) return false; - else if (so_addr.GetModule().get() != module) + if (so_addr.GetModule().get() != module) return false; } else { if (!module->ResolveFileAddress(addr, so_addr)) @@ -2052,40 +2050,40 @@ "'target create' command"); result.SetStatus(eReturnStatusFailed); return false; - } else { - uint32_t num_dumped = 0; + } + uint32_t num_dumped = 0; - uint32_t addr_byte_size = target->GetArchitecture().GetAddressByteSize(); - result.GetOutputStream().SetAddressByteSize(addr_byte_size); - result.GetErrorStream().SetAddressByteSize(addr_byte_size); + uint32_t addr_byte_size = target->GetArchitecture().GetAddressByteSize(); + result.GetOutputStream().SetAddressByteSize(addr_byte_size); + result.GetErrorStream().SetAddressByteSize(addr_byte_size); - if (command.GetArgumentCount() == 0) { - // Dump all sections for all modules images - std::lock_guard guard( - target->GetImages().GetMutex()); - const size_t num_modules = target->GetImages().GetSize(); - if (num_modules > 0) { - result.GetOutputStream().Printf("Dumping symbol table for %" PRIu64 - " modules.\n", - (uint64_t)num_modules); - for (size_t image_idx = 0; image_idx < num_modules; ++image_idx) { - if (num_dumped > 0) { - result.GetOutputStream().EOL(); - result.GetOutputStream().EOL(); - } - if (m_interpreter.WasInterrupted()) - break; - num_dumped++; - DumpModuleSymtab( - m_interpreter, result.GetOutputStream(), - target->GetImages().GetModulePointerAtIndexUnlocked(image_idx), - m_options.m_sort_order); + if (command.GetArgumentCount() == 0) { + // Dump all sections for all modules images + std::lock_guard guard( + target->GetImages().GetMutex()); + const size_t num_modules = target->GetImages().GetSize(); + if (num_modules > 0) { + result.GetOutputStream().Printf("Dumping symbol table for %" PRIu64 + " modules.\n", + (uint64_t)num_modules); + for (size_t image_idx = 0; image_idx < num_modules; ++image_idx) { + if (num_dumped > 0) { + result.GetOutputStream().EOL(); + result.GetOutputStream().EOL(); } - } else { - result.AppendError("the target has no associated executable images"); - result.SetStatus(eReturnStatusFailed); - return false; + if (m_interpreter.WasInterrupted()) + break; + num_dumped++; + DumpModuleSymtab( + m_interpreter, result.GetOutputStream(), + target->GetImages().GetModulePointerAtIndexUnlocked(image_idx), + m_options.m_sort_order); } + } else { + result.AppendError("the target has no associated executable images"); + result.SetStatus(eReturnStatusFailed); + return false; + } } else { // Dump specified images (by basename or fullpath) const char *arg_cstr; @@ -2122,8 +2120,8 @@ result.AppendError("no matching executable images found"); result.SetStatus(eReturnStatusFailed); } - } - return result.Succeeded(); + + return result.Succeeded(); } CommandOptions m_options; @@ -2155,33 +2153,33 @@ "'target create' command"); result.SetStatus(eReturnStatusFailed); return false; - } else { - uint32_t num_dumped = 0; + } + uint32_t num_dumped = 0; - uint32_t addr_byte_size = target->GetArchitecture().GetAddressByteSize(); - result.GetOutputStream().SetAddressByteSize(addr_byte_size); - result.GetErrorStream().SetAddressByteSize(addr_byte_size); + uint32_t addr_byte_size = target->GetArchitecture().GetAddressByteSize(); + result.GetOutputStream().SetAddressByteSize(addr_byte_size); + result.GetErrorStream().SetAddressByteSize(addr_byte_size); - if (command.GetArgumentCount() == 0) { - // Dump all sections for all modules images - const size_t num_modules = target->GetImages().GetSize(); - if (num_modules > 0) { - result.GetOutputStream().Printf("Dumping sections for %" PRIu64 - " modules.\n", - (uint64_t)num_modules); - for (size_t image_idx = 0; image_idx < num_modules; ++image_idx) { - if (m_interpreter.WasInterrupted()) - break; - num_dumped++; - DumpModuleSections( - m_interpreter, result.GetOutputStream(), - target->GetImages().GetModulePointerAtIndex(image_idx)); - } - } else { - result.AppendError("the target has no associated executable images"); - result.SetStatus(eReturnStatusFailed); - return false; + if (command.GetArgumentCount() == 0) { + // Dump all sections for all modules images + const size_t num_modules = target->GetImages().GetSize(); + if (num_modules > 0) { + result.GetOutputStream().Printf("Dumping sections for %" PRIu64 + " modules.\n", + (uint64_t)num_modules); + for (size_t image_idx = 0; image_idx < num_modules; ++image_idx) { + if (m_interpreter.WasInterrupted()) + break; + num_dumped++; + DumpModuleSections( + m_interpreter, result.GetOutputStream(), + target->GetImages().GetModulePointerAtIndex(image_idx)); } + } else { + result.AppendError("the target has no associated executable images"); + result.SetStatus(eReturnStatusFailed); + return false; + } } else { // Dump specified images (by basename or fullpath) const char *arg_cstr; @@ -2219,8 +2217,8 @@ result.AppendError("no matching executable images found"); result.SetStatus(eReturnStatusFailed); } - } - return result.Succeeded(); + + return result.Succeeded(); } }; @@ -2329,35 +2327,35 @@ "'target create' command"); result.SetStatus(eReturnStatusFailed); return false; - } else { - uint32_t num_dumped = 0; + } + uint32_t num_dumped = 0; - uint32_t addr_byte_size = target->GetArchitecture().GetAddressByteSize(); - result.GetOutputStream().SetAddressByteSize(addr_byte_size); - result.GetErrorStream().SetAddressByteSize(addr_byte_size); + uint32_t addr_byte_size = target->GetArchitecture().GetAddressByteSize(); + result.GetOutputStream().SetAddressByteSize(addr_byte_size); + result.GetErrorStream().SetAddressByteSize(addr_byte_size); - if (command.GetArgumentCount() == 0) { - // Dump all sections for all modules images - const ModuleList &target_modules = target->GetImages(); - std::lock_guard guard(target_modules.GetMutex()); - const size_t num_modules = target_modules.GetSize(); - if (num_modules > 0) { - result.GetOutputStream().Printf("Dumping debug symbols for %" PRIu64 - " modules.\n", - (uint64_t)num_modules); - for (uint32_t image_idx = 0; image_idx < num_modules; ++image_idx) { - if (m_interpreter.WasInterrupted()) - break; - if (DumpModuleSymbolVendor( - result.GetOutputStream(), - target_modules.GetModulePointerAtIndexUnlocked(image_idx))) - num_dumped++; - } - } else { - result.AppendError("the target has no associated executable images"); - result.SetStatus(eReturnStatusFailed); - return false; + if (command.GetArgumentCount() == 0) { + // Dump all sections for all modules images + const ModuleList &target_modules = target->GetImages(); + std::lock_guard guard(target_modules.GetMutex()); + const size_t num_modules = target_modules.GetSize(); + if (num_modules > 0) { + result.GetOutputStream().Printf("Dumping debug symbols for %" PRIu64 + " modules.\n", + (uint64_t)num_modules); + for (uint32_t image_idx = 0; image_idx < num_modules; ++image_idx) { + if (m_interpreter.WasInterrupted()) + break; + if (DumpModuleSymbolVendor( + result.GetOutputStream(), + target_modules.GetModulePointerAtIndexUnlocked(image_idx))) + num_dumped++; } + } else { + result.AppendError("the target has no associated executable images"); + result.SetStatus(eReturnStatusFailed); + return false; + } } else { // Dump specified images (by basename or fullpath) const char *arg_cstr; @@ -2389,8 +2387,8 @@ result.AppendError("no matching executable images found"); result.SetStatus(eReturnStatusFailed); } - } - return result.Succeeded(); + + return result.Succeeded(); } }; @@ -2424,37 +2422,36 @@ result.AppendError("file option must be specified."); result.SetStatus(eReturnStatusFailed); return result.Succeeded(); - } else { - // Dump specified images (by basename or fullpath) - const char *arg_cstr; - for (int arg_idx = 0; - (arg_cstr = command.GetArgumentAtIndex(arg_idx)) != nullptr; - ++arg_idx) { - FileSpec file_spec(arg_cstr); - - const ModuleList &target_modules = target->GetImages(); - std::lock_guard guard(target_modules.GetMutex()); - const size_t num_modules = target_modules.GetSize(); - if (num_modules > 0) { - uint32_t num_dumped = 0; - for (uint32_t i = 0; i < num_modules; ++i) { - if (m_interpreter.WasInterrupted()) - break; - if (DumpCompileUnitLineTable( - m_interpreter, result.GetOutputStream(), - target_modules.GetModulePointerAtIndexUnlocked(i), - file_spec, m_exe_ctx.GetProcessPtr() && - m_exe_ctx.GetProcessRef().IsAlive())) - num_dumped++; - } - if (num_dumped == 0) - result.AppendWarningWithFormat( - "No source filenames matched '%s'.\n", arg_cstr); - else - total_num_dumped += num_dumped; + } + // Dump specified images (by basename or fullpath) + const char *arg_cstr; + for (int arg_idx = 0; + (arg_cstr = command.GetArgumentAtIndex(arg_idx)) != nullptr; + ++arg_idx) { + FileSpec file_spec(arg_cstr); + + const ModuleList &target_modules = target->GetImages(); + std::lock_guard guard(target_modules.GetMutex()); + const size_t num_modules = target_modules.GetSize(); + if (num_modules > 0) { + uint32_t num_dumped = 0; + for (uint32_t i = 0; i < num_modules; ++i) { + if (m_interpreter.WasInterrupted()) + break; + if (DumpCompileUnitLineTable( + m_interpreter, result.GetOutputStream(), + target_modules.GetModulePointerAtIndexUnlocked(i), file_spec, + m_exe_ctx.GetProcessPtr() && + m_exe_ctx.GetProcessRef().IsAlive())) + num_dumped++; } + if (num_dumped == 0) + result.AppendWarningWithFormat("No source filenames matched '%s'.\n", + arg_cstr); + else + total_num_dumped += num_dumped; + } } - } if (total_num_dumped > 0) result.SetStatus(eReturnStatusSuccessFinishResult); @@ -2550,65 +2547,63 @@ "'target create' command"); result.SetStatus(eReturnStatusFailed); return false; - } else { - bool flush = false; + } + bool flush = false; - const size_t argc = args.GetArgumentCount(); - if (argc == 0) { - if (m_uuid_option_group.GetOptionValue().OptionWasSet()) { - // We are given a UUID only, go locate the file - ModuleSpec module_spec; - module_spec.GetUUID() = - m_uuid_option_group.GetOptionValue().GetCurrentValue(); - if (m_symbol_file.GetOptionValue().OptionWasSet()) - module_spec.GetSymbolFileSpec() = - m_symbol_file.GetOptionValue().GetCurrentValue(); - if (Symbols::DownloadObjectAndSymbolFile(module_spec)) { - ModuleSP module_sp(target->GetSharedModule(module_spec)); - if (module_sp) { - result.SetStatus(eReturnStatusSuccessFinishResult); - return true; + const size_t argc = args.GetArgumentCount(); + if (argc == 0) { + if (m_uuid_option_group.GetOptionValue().OptionWasSet()) { + // We are given a UUID only, go locate the file + ModuleSpec module_spec; + module_spec.GetUUID() = + m_uuid_option_group.GetOptionValue().GetCurrentValue(); + if (m_symbol_file.GetOptionValue().OptionWasSet()) + module_spec.GetSymbolFileSpec() = + m_symbol_file.GetOptionValue().GetCurrentValue(); + if (Symbols::DownloadObjectAndSymbolFile(module_spec)) { + ModuleSP module_sp(target->GetSharedModule(module_spec)); + if (module_sp) { + result.SetStatus(eReturnStatusSuccessFinishResult); + return true; + } + StreamString strm; + module_spec.GetUUID().Dump(&strm); + if (module_spec.GetFileSpec()) { + if (module_spec.GetSymbolFileSpec()) { + result.AppendErrorWithFormat( + "Unable to create the executable or symbol file with " + "UUID %s with path %s and symbol file %s", + strm.GetData(), module_spec.GetFileSpec().GetPath().c_str(), + module_spec.GetSymbolFileSpec().GetPath().c_str()); } else { - StreamString strm; - module_spec.GetUUID().Dump(&strm); - if (module_spec.GetFileSpec()) { - if (module_spec.GetSymbolFileSpec()) { - result.AppendErrorWithFormat( - "Unable to create the executable or symbol file with " - "UUID %s with path %s and symbol file %s", - strm.GetData(), - module_spec.GetFileSpec().GetPath().c_str(), - module_spec.GetSymbolFileSpec().GetPath().c_str()); - } else { - result.AppendErrorWithFormat( - "Unable to create the executable or symbol file with " - "UUID %s with path %s", - strm.GetData(), - module_spec.GetFileSpec().GetPath().c_str()); - } - } else { - result.AppendErrorWithFormat("Unable to create the executable " - "or symbol file with UUID %s", - strm.GetData()); - } - result.SetStatus(eReturnStatusFailed); - return false; + result.AppendErrorWithFormat( + "Unable to create the executable or symbol file with " + "UUID %s with path %s", + strm.GetData(), module_spec.GetFileSpec().GetPath().c_str()); } } else { - StreamString strm; - module_spec.GetUUID().Dump(&strm); - result.AppendErrorWithFormat( - "Unable to locate the executable or symbol file with UUID %s", - strm.GetData()); - result.SetStatus(eReturnStatusFailed); - return false; + result.AppendErrorWithFormat("Unable to create the executable " + "or symbol file with UUID %s", + strm.GetData()); } + result.SetStatus(eReturnStatusFailed); + return false; + } else { - result.AppendError( - "one or more executable image paths must be specified"); + StreamString strm; + module_spec.GetUUID().Dump(&strm); + result.AppendErrorWithFormat( + "Unable to locate the executable or symbol file with UUID %s", + strm.GetData()); result.SetStatus(eReturnStatusFailed); return false; } + } else { + result.AppendError( + "one or more executable image paths must be specified"); + result.SetStatus(eReturnStatusFailed); + return false; + } } else { for (auto &entry : args.entries()) { if (entry.ref.empty()) @@ -2636,9 +2631,9 @@ entry.c_str()); result.SetStatus(eReturnStatusFailed); return false; - } else { - flush = true; } + flush = true; + result.SetStatus(eReturnStatusSuccessFinishResult); } else { std::string resolved_path = file_spec.GetPath(); @@ -2661,7 +2656,6 @@ if (process) process->Flush(); } - } return result.Succeeded(); } @@ -2713,23 +2707,23 @@ "'target create' command"); result.SetStatus(eReturnStatusFailed); return false; - } else { - const size_t argc = args.GetArgumentCount(); - ModuleSpec module_spec; - bool search_using_module_spec = false; - - // Allow "load" option to work without --file or --uuid option. - if (load) { - if (!m_file_option.GetOptionValue().OptionWasSet() && - !m_uuid_option_group.GetOptionValue().OptionWasSet()) { - ModuleList &module_list = target->GetImages(); - if (module_list.GetSize() == 1) { - search_using_module_spec = true; - module_spec.GetFileSpec() = - module_list.GetModuleAtIndex(0)->GetFileSpec(); - } + } + const size_t argc = args.GetArgumentCount(); + ModuleSpec module_spec; + bool search_using_module_spec = false; + + // Allow "load" option to work without --file or --uuid option. + if (load) { + if (!m_file_option.GetOptionValue().OptionWasSet() && + !m_uuid_option_group.GetOptionValue().OptionWasSet()) { + ModuleList &module_list = target->GetImages(); + if (module_list.GetSize() == 1) { + search_using_module_spec = true; + module_spec.GetFileSpec() = + module_list.GetModuleAtIndex(0)->GetFileSpec(); } } + } if (m_file_option.GetOptionValue().OptionWasSet()) { search_using_module_spec = true; @@ -2815,15 +2809,14 @@ sect_name); result.SetStatus(eReturnStatusFailed); break; - } else { - if (target->GetSectionLoadList() - .SetSectionLoadAddress(section_sp, - load_addr)) - changed = true; - result.AppendMessageWithFormat( - "section '%s' loaded at 0x%" PRIx64 "\n", - sect_name, load_addr); } + if (target->GetSectionLoadList() + .SetSectionLoadAddress(section_sp, load_addr)) + changed = true; + result.AppendMessageWithFormat( + "section '%s' loaded at 0x%" PRIx64 "\n", + sect_name, load_addr); + } else { result.AppendErrorWithFormat("no section found that " "matches the section " @@ -2948,8 +2941,8 @@ result.SetStatus(eReturnStatusFailed); return false; } - } - return result.Succeeded(); + + return result.Succeeded(); } OptionGroupOptions m_option_group; @@ -3053,13 +3046,12 @@ "'target create' command"); result.SetStatus(eReturnStatusFailed); return false; - } else { - if (target) { - uint32_t addr_byte_size = - target->GetArchitecture().GetAddressByteSize(); - result.GetOutputStream().SetAddressByteSize(addr_byte_size); - result.GetErrorStream().SetAddressByteSize(addr_byte_size); - } + } + if (target) { + uint32_t addr_byte_size = target->GetArchitecture().GetAddressByteSize(); + result.GetOutputStream().SetAddressByteSize(addr_byte_size); + result.GetErrorStream().SetAddressByteSize(addr_byte_size); + } // Dump all sections for all modules images Stream &strm = result.GetOutputStream(); @@ -3171,8 +3163,8 @@ result.SetStatus(eReturnStatusFailed); return false; } - } - return result.Succeeded(); + + return result.Succeeded(); } void PrintModule(Target *target, Module *module, int indent, Stream &strm) { @@ -3932,54 +3924,53 @@ "'target create' command"); result.SetStatus(eReturnStatusFailed); return false; - } else { - bool syntax_error = false; - uint32_t i; - uint32_t num_successful_lookups = 0; - uint32_t addr_byte_size = target->GetArchitecture().GetAddressByteSize(); - result.GetOutputStream().SetAddressByteSize(addr_byte_size); - result.GetErrorStream().SetAddressByteSize(addr_byte_size); - // Dump all sections for all modules images - - if (command.GetArgumentCount() == 0) { - ModuleSP current_module; + } + bool syntax_error = false; + uint32_t i; + uint32_t num_successful_lookups = 0; + uint32_t addr_byte_size = target->GetArchitecture().GetAddressByteSize(); + result.GetOutputStream().SetAddressByteSize(addr_byte_size); + result.GetErrorStream().SetAddressByteSize(addr_byte_size); + // Dump all sections for all modules images - // Where it is possible to look in the current symbol context first, - // try that. If this search was successful and --all was not passed, - // don't print anything else. - if (LookupHere(m_interpreter, result, syntax_error)) { - result.GetOutputStream().EOL(); - num_successful_lookups++; - if (!m_options.m_print_all) { - result.SetStatus(eReturnStatusSuccessFinishResult); - return result.Succeeded(); - } + if (command.GetArgumentCount() == 0) { + ModuleSP current_module; + + // Where it is possible to look in the current symbol context first, + // try that. If this search was successful and --all was not passed, + // don't print anything else. + if (LookupHere(m_interpreter, result, syntax_error)) { + result.GetOutputStream().EOL(); + num_successful_lookups++; + if (!m_options.m_print_all) { + result.SetStatus(eReturnStatusSuccessFinishResult); + return result.Succeeded(); } + } - // Dump all sections for all other modules - - const ModuleList &target_modules = target->GetImages(); - std::lock_guard guard(target_modules.GetMutex()); - const size_t num_modules = target_modules.GetSize(); - if (num_modules > 0) { - for (i = 0; i < num_modules && !syntax_error; ++i) { - Module *module_pointer = - target_modules.GetModulePointerAtIndexUnlocked(i); - - if (module_pointer != current_module.get() && - LookupInModule( - m_interpreter, - target_modules.GetModulePointerAtIndexUnlocked(i), result, - syntax_error)) { - result.GetOutputStream().EOL(); - num_successful_lookups++; - } + // Dump all sections for all other modules + + const ModuleList &target_modules = target->GetImages(); + std::lock_guard guard(target_modules.GetMutex()); + const size_t num_modules = target_modules.GetSize(); + if (num_modules > 0) { + for (i = 0; i < num_modules && !syntax_error; ++i) { + Module *module_pointer = + target_modules.GetModulePointerAtIndexUnlocked(i); + + if (module_pointer != current_module.get() && + LookupInModule(m_interpreter, + target_modules.GetModulePointerAtIndexUnlocked(i), + result, syntax_error)) { + result.GetOutputStream().EOL(); + num_successful_lookups++; } - } else { - result.AppendError("the target has no associated executable images"); - result.SetStatus(eReturnStatusFailed); - return false; } + } else { + result.AppendError("the target has no associated executable images"); + result.SetStatus(eReturnStatusFailed); + return false; + } } else { // Dump specified images (by basename or fullpath) const char *arg_cstr; @@ -4010,8 +4001,8 @@ result.SetStatus(eReturnStatusSuccessFinishResult); else result.SetStatus(eReturnStatusFailed); - } - return result.Succeeded(); + + return result.Succeeded(); } CommandOptions m_options; @@ -4853,9 +4844,9 @@ if (!m_interpreter.Confirm("Delete all stop hooks?", true)) { result.SetStatus(eReturnStatusFailed); return false; - } else { - target->RemoveAllStopHooks(); } + target->RemoveAllStopHooks(); + } else { bool success; for (size_t i = 0; i < num_args; i++) { Index: source/Commands/CommandObjectThread.cpp =================================================================== --- source/Commands/CommandObjectThread.cpp +++ source/Commands/CommandObjectThread.cpp @@ -94,7 +94,8 @@ if (!thread || !HandleOneThread(thread->GetID(), result)) return false; return result.Succeeded(); - } else if (command.GetArgumentCount() == 1) { + } + if (command.GetArgumentCount() == 1) { all_threads = ::strcmp(command.GetArgumentAtIndex(0), "all") == 0; m_unique_stacks = ::strcmp(command.GetArgumentAtIndex(0), "unique") == 0; } @@ -617,8 +618,9 @@ result.AppendErrorWithFormat("empty class name for scripted step."); result.SetStatus(eReturnStatusFailed); return false; - } else if (!m_interpreter.GetScriptInterpreter()->CheckObjectExists( - m_options.m_class_name.c_str())) { + } + if (!m_interpreter.GetScriptInterpreter()->CheckObjectExists( + m_options.m_class_name.c_str())) { result.AppendErrorWithFormat( "class for scripted step: \"%s\" does not exist.", m_options.m_class_name.c_str()); @@ -894,34 +896,33 @@ result.AppendError("no valid thread indexes were specified"); result.SetStatus(eReturnStatusFailed); return false; - } else { - if (resume_threads.size() == 1) - result.AppendMessageWithFormat("Resuming thread: "); - else - result.AppendMessageWithFormat("Resuming threads: "); - - for (uint32_t idx = 0; idx < num_threads; ++idx) { - Thread *thread = - process->GetThreadList().GetThreadAtIndex(idx).get(); - std::vector::iterator this_thread_pos = - find(resume_threads.begin(), resume_threads.end(), thread); - - if (this_thread_pos != resume_threads.end()) { - resume_threads.erase(this_thread_pos); - if (!resume_threads.empty()) - result.AppendMessageWithFormat("%u, ", thread->GetIndexID()); - else - result.AppendMessageWithFormat("%u ", thread->GetIndexID()); + } + if (resume_threads.size() == 1) + result.AppendMessageWithFormat("Resuming thread: "); + else + result.AppendMessageWithFormat("Resuming threads: "); - const bool override_suspend = true; - thread->SetResumeState(eStateRunning, override_suspend); - } else { - thread->SetResumeState(eStateSuspended); - } + for (uint32_t idx = 0; idx < num_threads; ++idx) { + Thread *thread = process->GetThreadList().GetThreadAtIndex(idx).get(); + std::vector::iterator this_thread_pos = + find(resume_threads.begin(), resume_threads.end(), thread); + + if (this_thread_pos != resume_threads.end()) { + resume_threads.erase(this_thread_pos); + if (!resume_threads.empty()) + result.AppendMessageWithFormat("%u, ", thread->GetIndexID()); + else + result.AppendMessageWithFormat("%u ", thread->GetIndexID()); + + const bool override_suspend = true; + thread->SetResumeState(eStateRunning, override_suspend); + } else { + thread->SetResumeState(eStateSuspended); + } } result.AppendMessageWithFormat("in process %" PRIu64 "\n", process->GetID()); - } + } else { // These two lines appear at the beginning of both blocks in this // if..else, but that is because we need to release the lock before @@ -1152,8 +1153,8 @@ command.GetArgumentAtIndex(i)); result.SetStatus(eReturnStatusFailed); return false; - } else - line_numbers.push_back(line_number); + } + line_numbers.push_back(line_number); } } else if (m_options.m_until_addrs.empty()) { result.AppendErrorWithFormat("No line number or address provided:\n%s", @@ -1365,7 +1366,8 @@ result.AppendError("no process"); result.SetStatus(eReturnStatusFailed); return false; - } else if (command.GetArgumentCount() != 1) { + } + if (command.GetArgumentCount() != 1) { result.AppendErrorWithFormat( "'%s' takes exactly one thread index argument:\nUsage: %s\n", m_cmd_name.c_str(), m_cmd_syntax.c_str()); @@ -2053,13 +2055,12 @@ if (thread->DiscardUserThreadPlansUpToIndex(thread_plan_idx)) { result.SetStatus(eReturnStatusSuccessFinishNoResult); return true; - } else { - result.AppendErrorWithFormat( - "Could not find User thread plan with index %s.", - args.GetArgumentAtIndex(0)); - result.SetStatus(eReturnStatusFailed); - return false; } + result.AppendErrorWithFormat( + "Could not find User thread plan with index %s.", + args.GetArgumentAtIndex(0)); + result.SetStatus(eReturnStatusFailed); + return false; } }; Index: source/Commands/CommandObjectType.cpp =================================================================== --- source/Commands/CommandObjectType.cpp +++ source/Commands/CommandObjectType.cpp @@ -401,7 +401,7 @@ if (m_options.handwrite_python) return Execute_HandwritePython(command, result); - else if (m_options.is_class_based) + if (m_options.is_class_based) return Execute_PythonClass(command, result); else { result.AppendError("must either provide a children list, a Python class " @@ -884,11 +884,10 @@ if (delete_category || extra_deletion) { result.SetStatus(eReturnStatusSuccessFinishNoResult); return result.Succeeded(); - } else { - result.AppendErrorWithFormat("no custom formatter for %s.\n", typeA); - result.SetStatus(eReturnStatusFailed); - return false; } + result.AppendErrorWithFormat("no custom formatter for %s.\n", typeA); + result.SetStatus(eReturnStatusFailed); + return false; } }; @@ -1703,7 +1702,8 @@ category->GetRegexTypeSummariesContainer()->Add(typeRX, entry); return true; - } else if (type == eNamedSummary) { + } + if (type == eNamedSummary) { // system named summaries do not exist (yet?) DataVisualization::NamedSummaryFormats::Add(type_name, entry); return true; @@ -2054,11 +2054,10 @@ if (success) { result.SetStatus(eReturnStatusSuccessFinishResult); return result.Succeeded(); - } else { - result.AppendError("cannot delete one or more categories\n"); - result.SetStatus(eReturnStatusFailed); - return false; } + result.AppendError("cannot delete one or more categories\n"); + result.SetStatus(eReturnStatusFailed); + return false; } }; @@ -2481,11 +2480,10 @@ category->GetRegexTypeSyntheticsContainer()->Delete(type_name); category->GetRegexTypeSyntheticsContainer()->Add(typeRX, entry); - return true; - } else { - category->GetTypeSyntheticsContainer()->Add(type_name, entry); return true; } + category->GetTypeSyntheticsContainer()->Add(type_name, entry); + return true; } #endif // LLDB_DISABLE_PYTHON @@ -2618,11 +2616,10 @@ category->GetRegexTypeFiltersContainer()->Delete(type_name); category->GetRegexTypeFiltersContainer()->Add(typeRX, entry); - return true; - } else { - category->GetTypeFiltersContainer()->Add(type_name, entry); return true; } + category->GetTypeFiltersContainer()->Add(type_name, entry); + return true; } public: @@ -2944,8 +2941,8 @@ // this is "type lookup SomeName" and we did find a match, so get out if (any_found && is_global_search) break; - else if (is_first_language && is_global_search && - guessed_language != lldb::eLanguageTypeUnknown) { + if (is_first_language && is_global_search && + guessed_language != lldb::eLanguageTypeUnknown) { is_first_language = false; result.GetOutputStream().Printf( "no type was found in the current language %s matching '%s'; " @@ -3029,11 +3026,10 @@ result.SetStatus(lldb::eReturnStatusSuccessFinishNoResult); } return true; - } else { - result.AppendError("failed to evaluate expression"); - result.SetStatus(lldb::eReturnStatusFailed); - return false; } + result.AppendError("failed to evaluate expression"); + result.SetStatus(lldb::eReturnStatusFailed); + return false; } private: Index: source/Commands/CommandObjectWatchpoint.cpp =================================================================== --- source/Commands/CommandObjectWatchpoint.cpp +++ source/Commands/CommandObjectWatchpoint.cpp @@ -82,8 +82,8 @@ if (watch_sp) { wp_ids.push_back(watch_sp->GetID()); return true; - } else - return false; + } + return false; } llvm::StringRef Minus("-"); Index: source/Core/Address.cpp =================================================================== --- source/Core/Address.cpp +++ source/Core/Address.cpp @@ -281,7 +281,8 @@ // We have a valid file range, so we can return the file based address by // adding the file base address to our offset return sect_file_addr + m_offset; - } else if (SectionWasDeletedPrivate()) { + } + if (SectionWasDeletedPrivate()) { // Used to have a valid section but it got deleted so the offset doesn't // mean anything without the section return LLDB_INVALID_ADDRESS; @@ -950,11 +951,10 @@ if (lhs_module == rhs_module) { // Addresses are in the same module, just compare the file addresses return lhs.GetFileAddress() < rhs.GetFileAddress(); - } else { - // The addresses are from different modules, just use the module pointer - // value to get consistent ordering - return lhs_module < rhs_module; } + // The addresses are from different modules, just use the module pointer + // value to get consistent ordering + return lhs_module < rhs_module; } bool lldb_private::operator>(const Address &lhs, const Address &rhs) { @@ -965,11 +965,10 @@ if (lhs_module == rhs_module) { // Addresses are in the same module, just compare the file addresses return lhs.GetFileAddress() > rhs.GetFileAddress(); - } else { - // The addresses are from different modules, just use the module pointer - // value to get consistent ordering - return lhs_module > rhs_module; } + // The addresses are from different modules, just use the module pointer + // value to get consistent ordering + return lhs_module > rhs_module; } // The operator == checks for exact equality only (same section, same offset) Index: source/Core/AddressRange.cpp =================================================================== --- source/Core/AddressRange.cpp +++ source/Core/AddressRange.cpp @@ -170,7 +170,8 @@ } s->AddressRange(vmaddr, vmaddr + GetByteSize(), addr_size); return true; - } else if (fallback_style != Address::DumpStyleInvalid) { + } + if (fallback_style != Address::DumpStyleInvalid) { return Dump(s, target, fallback_style, Address::DumpStyleInvalid); } Index: source/Core/Broadcaster.cpp =================================================================== --- source/Core/Broadcaster.cpp +++ source/Core/Broadcaster.cpp @@ -288,9 +288,8 @@ const char *Broadcaster::BroadcasterImpl::GetHijackingListenerName() { if (m_hijacking_listeners.size()) { return m_hijacking_listeners.back()->GetName(); - } else { - return nullptr; } + return nullptr; } void Broadcaster::BroadcasterImpl::RestoreBroadcaster() { @@ -322,9 +321,8 @@ bool BroadcastEventSpec::operator<(const BroadcastEventSpec &rhs) const { if (GetBroadcasterClass() == rhs.GetBroadcasterClass()) { return GetEventBits() < rhs.GetEventBits(); - } else { - return GetBroadcasterClass() < rhs.GetBroadcasterClass(); } + return GetBroadcasterClass() < rhs.GetBroadcasterClass(); } BroadcastEventSpec &BroadcastEventSpec:: @@ -380,17 +378,16 @@ iter = find_if(m_event_map.begin(), end_iter, predicate); if (iter == end_iter) { break; - } else { - uint32_t iter_event_bits = (*iter).first.GetEventBits(); - removed_some = true; - - if (event_bits_to_remove != iter_event_bits) { - uint32_t new_event_bits = iter_event_bits & ~event_bits_to_remove; - to_be_readded.push_back(BroadcastEventSpec( - event_spec.GetBroadcasterClass(), new_event_bits)); + } + uint32_t iter_event_bits = (*iter).first.GetEventBits(); + removed_some = true; + + if (event_bits_to_remove != iter_event_bits) { + uint32_t new_event_bits = iter_event_bits & ~event_bits_to_remove; + to_be_readded.push_back( + BroadcastEventSpec(event_spec.GetBroadcasterClass(), new_event_bits)); } m_event_map.erase(iter); - } } // Okay now add back the bits that weren't completely removed: @@ -410,8 +407,8 @@ BroadcastEventSpecMatches(event_spec)); if (iter != end_iter) return (*iter).second; - else - return nullptr; + + return nullptr; } void BroadcasterManager::RemoveListener(Listener *listener) { @@ -429,8 +426,8 @@ iter = find_if(m_event_map.begin(), end_iter, predicate); if (iter == end_iter) break; - else - m_event_map.erase(iter); + + m_event_map.erase(iter); } } @@ -446,8 +443,8 @@ iter = find_if(m_event_map.begin(), end_iter, predicate); if (iter == end_iter) break; - else - m_event_map.erase(iter); + + m_event_map.erase(iter); } } Index: source/Core/Debugger.cpp =================================================================== --- source/Core/Debugger.cpp +++ source/Core/Debugger.cpp @@ -643,9 +643,9 @@ debugger->LoadPlugin(plugin_file_spec, plugin_load_error); return FileSystem::eEnumerateDirectoryResultNext; - } else if (ft == fs::file_type::directory_file || - ft == fs::file_type::symlink_file || - ft == fs::file_type::type_unknown) { + } + if (ft == fs::file_type::directory_file || + ft == fs::file_type::symlink_file || ft == fs::file_type::type_unknown) { // Try and recurse into anything that a directory or symbolic link. We must // also do this for unknown as sometimes the directory enumeration might be // enumerating a file system that doesn't have correct file type Index: source/Core/Disassembler.cpp =================================================================== --- source/Core/Disassembler.cpp +++ source/Core/Disassembler.cpp @@ -1189,7 +1189,8 @@ const bool data_from_file = load_addr == LLDB_INVALID_ADDRESS; return DecodeInstructions(range.GetBaseAddress(), data, 0, UINT32_MAX, false, data_from_file); - } else if (error_strm_ptr) { + } + if (error_strm_ptr) { const char *error_cstr = error.AsCString(); if (error_cstr) { error_strm_ptr->Printf("error: %s\n", error_cstr); Index: source/Core/DumpDataExtractor.cpp =================================================================== --- source/Core/DumpDataExtractor.cpp +++ source/Core/DumpDataExtractor.cpp @@ -84,7 +84,8 @@ } result = llvm::APInt(byte_size * 8, llvm::ArrayRef(uint64_array)); return true; - } else if (byte_order == lldb::eByteOrderBig) { + } + if (byte_order == lldb::eByteOrderBig) { lldb::offset_t be_offset = *offset_ptr + byte_size; lldb::offset_t temp_offset; while (bytes_left > 0) { Index: source/Core/DynamicLoader.cpp =================================================================== --- source/Core/DynamicLoader.cpp +++ source/Core/DynamicLoader.cpp @@ -225,8 +225,8 @@ m_process->ReadUnsignedIntegerFromMemory(addr, size_in_bytes, 0, error); if (error.Fail()) return -1; - else - return (int64_t)value; + + return (int64_t)value; } addr_t DynamicLoader::ReadPointer(addr_t addr) { @@ -234,8 +234,8 @@ addr_t value = m_process->ReadPointerFromMemory(addr, error); if (error.Fail()) return LLDB_INVALID_ADDRESS; - else - return value; + + return value; } void DynamicLoader::LoadOperatingSystemPlugin(bool flush) Index: source/Core/Event.cpp =================================================================== --- source/Core/Event.cpp +++ source/Core/Event.cpp @@ -273,8 +273,8 @@ auto event_data = EventDataStructuredData::GetEventDataFromEvent(event_ptr); if (event_data) return event_data->GetProcess(); - else - return ProcessSP(); + + return ProcessSP(); } StructuredData::ObjectSP @@ -282,8 +282,8 @@ auto event_data = EventDataStructuredData::GetEventDataFromEvent(event_ptr); if (event_data) return event_data->GetObject(); - else - return StructuredData::ObjectSP(); + + return StructuredData::ObjectSP(); } lldb::StructuredDataPluginSP @@ -291,8 +291,8 @@ auto event_data = EventDataStructuredData::GetEventDataFromEvent(event_ptr); if (event_data) return event_data->GetStructuredDataPlugin(); - else - return StructuredDataPluginSP(); + + return StructuredDataPluginSP(); } const ConstString &EventDataStructuredData::GetFlavorString() { Index: source/Core/FormatEntity.cpp =================================================================== --- source/Core/FormatEntity.cpp +++ source/Core/FormatEntity.cpp @@ -421,9 +421,8 @@ error.Success()) { s.Printf("%s", script_output.c_str()); return true; - } else { - s.Printf("", error.AsCString()); } + s.Printf("", error.AsCString()); } } return false; @@ -501,22 +500,21 @@ func_file_addr - addr_file_addr); } return true; - } else { - Target *target = Target::GetTargetFromContexts(exe_ctx, sc); - if (target) { - addr_t func_load_addr = func_addr.GetLoadAddress(target); - addr_t addr_load_addr = format_addr.GetLoadAddress(target); - if (addr_load_addr > func_load_addr || - (addr_load_addr == func_load_addr && print_zero_offsets)) { - s.Printf("%s+%s%" PRIu64, addr_offset_padding, addr_offset_padding, - addr_load_addr - func_load_addr); - } else if (addr_load_addr < func_load_addr) { - s.Printf("%s-%s%" PRIu64, addr_offset_padding, addr_offset_padding, - func_load_addr - addr_load_addr); - } - return true; - } } + Target *target = Target::GetTargetFromContexts(exe_ctx, sc); + if (target) { + addr_t func_load_addr = func_addr.GetLoadAddress(target); + addr_t addr_load_addr = format_addr.GetLoadAddress(target); + if (addr_load_addr > func_load_addr || + (addr_load_addr == func_load_addr && print_zero_offsets)) { + s.Printf("%s+%s%" PRIu64, addr_offset_padding, addr_offset_padding, + addr_load_addr - func_load_addr); + } else if (addr_load_addr < func_load_addr) { + s.Printf("%s-%s%" PRIu64, addr_offset_padding, addr_offset_padding, + func_load_addr - addr_load_addr); + } + return true; + } } } return false; @@ -541,14 +539,14 @@ if (log) log->Printf("[ScanBracketedRange] no bracketed range, skipping entirely"); return false; - } else { - var_name_final_if_array_range = subpath.data() + open_bracket_index; + } + var_name_final_if_array_range = subpath.data() + open_bracket_index; - if (close_bracket_index - open_bracket_index == 1) { - if (log) - log->Printf( - "[ScanBracketedRange] '[]' detected.. going from 0 to end of data"); - index_lower = 0; + if (close_bracket_index - open_bracket_index == 1) { + if (log) + log->Printf( + "[ScanBracketedRange] '[]' detected.. going from 0 to end of data"); + index_lower = 0; } else { const size_t separator_index = subpath.find('-', open_bracket_index + 1); @@ -577,8 +575,8 @@ index_higher = temp; } } - } - return true; + + return true; } static bool DumpFile(Stream &s, const FileSpec &file, FileKind file_kind) { @@ -802,16 +800,15 @@ " final_value_type %d", reason_to_stop, final_value_type); return false; - } else { - if (log) - log->Printf("[Debugger::FormatPrompt] ALL RIGHT: why stopping = %d," - " final_value_type %d", - reason_to_stop, final_value_type); - target = target - ->GetQualifiedRepresentationIfAvailable( - target->GetDynamicValueType(), true) - .get(); } + if (log) + log->Printf("[Debugger::FormatPrompt] ALL RIGHT: why stopping = %d," + " final_value_type %d", + reason_to_stop, final_value_type); + target = target + ->GetQualifiedRepresentationIfAvailable( + target->GetDynamicValueType(), true) + .get(); } is_array_range = @@ -893,18 +890,17 @@ if (success) s << str_temp.GetString(); return true; - } else { - if (was_plain_var) // if ${var} - { - s << target->GetTypeName() << " @ " << target->GetLocationAsCString(); - } else if (is_pointer) // if pointer, value is the address stored - { - target->DumpPrintableRepresentation( - s, val_obj_display, custom_format, - ValueObject::PrintableRepresentationSpecialCases::eDisable); - } - return true; } + if (was_plain_var) // if ${var} + { + s << target->GetTypeName() << " @ " << target->GetLocationAsCString(); + } else if (is_pointer) // if pointer, value is the address stored + { + target->DumpPrintableRepresentation( + s, val_obj_display, custom_format, + ValueObject::PrintableRepresentationSpecialCases::eDisable); + } + return true; } // if directly trying to print ${var}, and this is an aggregate, display a @@ -929,40 +925,37 @@ log->Printf("[Debugger::FormatPrompt] dumping ordinary printable output"); return target->DumpPrintableRepresentation(s, val_obj_display, custom_format); - } else { - if (log) - log->Printf("[Debugger::FormatPrompt] checking if I can handle as array"); - if (!is_array && !is_pointer) - return false; - if (log) - log->Printf("[Debugger::FormatPrompt] handle as array"); - StreamString special_directions_stream; - llvm::StringRef special_directions; - if (close_bracket_index != llvm::StringRef::npos && - subpath.size() > close_bracket_index) { - ConstString additional_data(subpath.drop_front(close_bracket_index + 1)); - special_directions_stream.Printf("${%svar%s", do_deref_pointer ? "*" : "", - additional_data.GetCString()); - - if (entry.fmt != eFormatDefault) { - const char format_char = - FormatManager::GetFormatAsFormatChar(entry.fmt); - if (format_char != '\0') - special_directions_stream.Printf("%%%c", format_char); - else { - const char *format_cstr = - FormatManager::GetFormatAsCString(entry.fmt); - special_directions_stream.Printf("%%%s", format_cstr); - } - } else if (entry.number != 0) { - const char style_char = ConvertValueObjectStyleToChar( - (ValueObject::ValueObjectRepresentationStyle)entry.number); - if (style_char) - special_directions_stream.Printf("%%%c", style_char); + } + if (log) + log->Printf("[Debugger::FormatPrompt] checking if I can handle as array"); + if (!is_array && !is_pointer) + return false; + if (log) + log->Printf("[Debugger::FormatPrompt] handle as array"); + StreamString special_directions_stream; + llvm::StringRef special_directions; + if (close_bracket_index != llvm::StringRef::npos && + subpath.size() > close_bracket_index) { + ConstString additional_data(subpath.drop_front(close_bracket_index + 1)); + special_directions_stream.Printf("${%svar%s", do_deref_pointer ? "*" : "", + additional_data.GetCString()); + + if (entry.fmt != eFormatDefault) { + const char format_char = FormatManager::GetFormatAsFormatChar(entry.fmt); + if (format_char != '\0') + special_directions_stream.Printf("%%%c", format_char); + else { + const char *format_cstr = FormatManager::GetFormatAsCString(entry.fmt); + special_directions_stream.Printf("%%%s", format_cstr); } - special_directions_stream.PutChar('}'); - special_directions = - llvm::StringRef(special_directions_stream.GetString()); + } else if (entry.number != 0) { + const char style_char = ConvertValueObjectStyleToChar( + (ValueObject::ValueObjectRepresentationStyle)entry.number); + if (style_char) + special_directions_stream.Printf("%%%c", style_char); + } + special_directions_stream.PutChar('}'); + special_directions = llvm::StringRef(special_directions_stream.GetString()); } // let us display items index_lower thru index_higher of this array @@ -1010,7 +1003,6 @@ } s.PutChar(']'); return success; - } } static bool DumpRegister(Stream &s, StackFrame *frame, const char *reg_name, @@ -1048,7 +1040,8 @@ token_format = entry.printf_format.c_str(); s.Printf(token_format, value->GetAsInteger()->GetValue()); return true; - } else if (value->GetType() == eStructuredDataTypeFloat) { + } + if (value->GetType() == eStructuredDataTypeFloat) { s.Printf("%f", value->GetAsFloat()->GetValue()); return true; } else if (value->GetType() == eStructuredDataTypeString) { @@ -1512,7 +1505,8 @@ if (sc->function) { s.Printf("function{0x%8.8" PRIx64 "}", sc->function->GetID()); return true; - } else if (sc->symbol) { + } + if (sc->symbol) { s.Printf("symbol[%u]", sc->symbol->GetID()); return true; } @@ -1540,29 +1534,28 @@ if (language_plugin_handled) { s << ss.GetString(); return true; - } else { - const char *name = nullptr; - if (sc->function) - name = sc->function->GetName().AsCString(nullptr); - else if (sc->symbol) - name = sc->symbol->GetName().AsCString(nullptr); - if (name) { - s.PutCString(name); - - if (sc->block) { - Block *inline_block = sc->block->GetContainingInlinedBlock(); - if (inline_block) { - const InlineFunctionInfo *inline_info = - sc->block->GetInlinedFunctionInfo(); - if (inline_info) { - s.PutCString(" [inlined] "); - inline_info->GetName(sc->function->GetLanguage()).Dump(&s); - } + } + const char *name = nullptr; + if (sc->function) + name = sc->function->GetName().AsCString(nullptr); + else if (sc->symbol) + name = sc->symbol->GetName().AsCString(nullptr); + if (name) { + s.PutCString(name); + + if (sc->block) { + Block *inline_block = sc->block->GetContainingInlinedBlock(); + if (inline_block) { + const InlineFunctionInfo *inline_info = + sc->block->GetInlinedFunctionInfo(); + if (inline_info) { + s.PutCString(" [inlined] "); + inline_info->GetName(sc->function->GetLanguage()).Dump(&s); } } - return true; } - } + return true; + } } return false; @@ -1582,17 +1575,16 @@ if (language_plugin_handled) { s << ss.GetString(); return true; - } else { - ConstString name; - if (sc->function) - name = sc->function->GetNameNoArguments(); - else if (sc->symbol) - name = sc->symbol->GetNameNoArguments(); - if (name) { - s.PutCString(name.GetCString()); - return true; - } } + ConstString name; + if (sc->function) + name = sc->function->GetNameNoArguments(); + else if (sc->symbol) + name = sc->symbol->GetNameNoArguments(); + if (name) { + s.PutCString(name.GetCString()); + return true; + } } return false; @@ -1611,142 +1603,142 @@ if (language_plugin_handled) { s << ss.GetString(); return true; - } else { - // Print the function name with arguments in it - if (sc->function) { - ExecutionContextScope *exe_scope = - exe_ctx ? exe_ctx->GetBestExecutionContextScope() : nullptr; - const char *cstr = sc->function->GetName().AsCString(nullptr); - if (cstr) { - const InlineFunctionInfo *inline_info = nullptr; - VariableListSP variable_list_sp; - bool get_function_vars = true; - if (sc->block) { - Block *inline_block = sc->block->GetContainingInlinedBlock(); - - if (inline_block) { - get_function_vars = false; - inline_info = sc->block->GetInlinedFunctionInfo(); - if (inline_info) - variable_list_sp = inline_block->GetBlockVariableList(true); - } - } + } + // Print the function name with arguments in it + if (sc->function) { + ExecutionContextScope *exe_scope = + exe_ctx ? exe_ctx->GetBestExecutionContextScope() : nullptr; + const char *cstr = sc->function->GetName().AsCString(nullptr); + if (cstr) { + const InlineFunctionInfo *inline_info = nullptr; + VariableListSP variable_list_sp; + bool get_function_vars = true; + if (sc->block) { + Block *inline_block = sc->block->GetContainingInlinedBlock(); - if (get_function_vars) { - variable_list_sp = - sc->function->GetBlock(true).GetBlockVariableList(true); + if (inline_block) { + get_function_vars = false; + inline_info = sc->block->GetInlinedFunctionInfo(); + if (inline_info) + variable_list_sp = inline_block->GetBlockVariableList(true); } + } - if (inline_info) { - s.PutCString(cstr); - s.PutCString(" [inlined] "); - cstr = - inline_info->GetName(sc->function->GetLanguage()).GetCString(); - } + if (get_function_vars) { + variable_list_sp = + sc->function->GetBlock(true).GetBlockVariableList(true); + } - VariableList args; - if (variable_list_sp) - variable_list_sp->AppendVariablesWithScope( - eValueTypeVariableArgument, args); - if (args.GetSize() > 0) { - const char *open_paren = strchr(cstr, '('); - const char *close_paren = nullptr; - const char *generic = strchr(cstr, '<'); - // if before the arguments list begins there is a template sign - // then scan to the end of the generic args before you try to find - // the arguments list - if (generic && open_paren && generic < open_paren) { - int generic_depth = 1; - ++generic; - for (; *generic && generic_depth > 0; generic++) { - if (*generic == '<') - generic_depth++; - if (*generic == '>') - generic_depth--; - } - if (*generic) - open_paren = strchr(generic, '('); - else - open_paren = nullptr; - } - if (open_paren) { - if (IsToken(open_paren, "(anonymous namespace)")) { - open_paren = - strchr(open_paren + strlen("(anonymous namespace)"), '('); - if (open_paren) - close_paren = strchr(open_paren, ')'); - } else - close_paren = strchr(open_paren, ')'); - } + if (inline_info) { + s.PutCString(cstr); + s.PutCString(" [inlined] "); + cstr = inline_info->GetName(sc->function->GetLanguage()).GetCString(); + } - if (open_paren) - s.Write(cstr, open_paren - cstr + 1); - else { - s.PutCString(cstr); - s.PutChar('('); + VariableList args; + if (variable_list_sp) + variable_list_sp->AppendVariablesWithScope(eValueTypeVariableArgument, + args); + if (args.GetSize() > 0) { + const char *open_paren = strchr(cstr, '('); + const char *close_paren = nullptr; + const char *generic = strchr(cstr, '<'); + // if before the arguments list begins there is a template sign + // then scan to the end of the generic args before you try to find + // the arguments list + if (generic && open_paren && generic < open_paren) { + int generic_depth = 1; + ++generic; + for (; *generic && generic_depth > 0; generic++) { + if (*generic == '<') + generic_depth++; + if (*generic == '>') + generic_depth--; } - const size_t num_args = args.GetSize(); - for (size_t arg_idx = 0; arg_idx < num_args; ++arg_idx) { - std::string buffer; - - VariableSP var_sp(args.GetVariableAtIndex(arg_idx)); - ValueObjectSP var_value_sp( - ValueObjectVariable::Create(exe_scope, var_sp)); - StreamString ss; - llvm::StringRef var_representation; - const char *var_name = var_value_sp->GetName().GetCString(); - if (var_value_sp->GetCompilerType().IsValid()) { - if (var_value_sp && exe_scope->CalculateTarget()) - var_value_sp = - var_value_sp->GetQualifiedRepresentationIfAvailable( - exe_scope->CalculateTarget() - ->TargetProperties::GetPreferDynamicValue(), - exe_scope->CalculateTarget() - ->TargetProperties::GetEnableSyntheticValue()); - if (var_value_sp->GetCompilerType().IsAggregateType() && - DataVisualization::ShouldPrintAsOneLiner(*var_value_sp)) { - static StringSummaryFormat format( - TypeSummaryImpl::Flags() - .SetHideItemNames(false) - .SetShowMembersOneLiner(true), - ""); - format.FormatObject(var_value_sp.get(), buffer, - TypeSummaryOptions()); - var_representation = buffer; - } else - var_value_sp->DumpPrintableRepresentation( - ss, ValueObject::ValueObjectRepresentationStyle:: - eValueObjectRepresentationStyleSummary, - eFormatDefault, - ValueObject::PrintableRepresentationSpecialCases::eAllow, - false); - } + if (*generic) + open_paren = strchr(generic, '('); + else + open_paren = nullptr; + } + if (open_paren) { + if (IsToken(open_paren, "(anonymous namespace)")) { + open_paren = + strchr(open_paren + strlen("(anonymous namespace)"), '('); + if (open_paren) + close_paren = strchr(open_paren, ')'); + } else + close_paren = strchr(open_paren, ')'); + } - if (!ss.GetString().empty()) - var_representation = ss.GetString(); - if (arg_idx > 0) - s.PutCString(", "); - if (var_value_sp->GetError().Success()) { - if (!var_representation.empty()) - s.Printf("%s=%s", var_name, var_representation.str().c_str()); - else - s.Printf("%s=%s at %s", var_name, - var_value_sp->GetTypeName().GetCString(), - var_value_sp->GetLocationAsCString()); + if (open_paren) + s.Write(cstr, open_paren - cstr + 1); + else { + s.PutCString(cstr); + s.PutChar('('); + } + const size_t num_args = args.GetSize(); + for (size_t arg_idx = 0; arg_idx < num_args; ++arg_idx) { + std::string buffer; + + VariableSP var_sp(args.GetVariableAtIndex(arg_idx)); + ValueObjectSP var_value_sp( + ValueObjectVariable::Create(exe_scope, var_sp)); + StreamString ss; + llvm::StringRef var_representation; + const char *var_name = var_value_sp->GetName().GetCString(); + if (var_value_sp->GetCompilerType().IsValid()) { + if (var_value_sp && exe_scope->CalculateTarget()) + var_value_sp = + var_value_sp->GetQualifiedRepresentationIfAvailable( + exe_scope->CalculateTarget() + ->TargetProperties::GetPreferDynamicValue(), + exe_scope->CalculateTarget() + ->TargetProperties::GetEnableSyntheticValue()); + if (var_value_sp->GetCompilerType().IsAggregateType() && + DataVisualization::ShouldPrintAsOneLiner(*var_value_sp)) { + static StringSummaryFormat format( + TypeSummaryImpl::Flags() + .SetHideItemNames(false) + .SetShowMembersOneLiner(true), + ""); + format.FormatObject(var_value_sp.get(), buffer, + TypeSummaryOptions()); + var_representation = buffer; } else - s.Printf("%s=", var_name); + var_value_sp->DumpPrintableRepresentation( + ss, + ValueObject::ValueObjectRepresentationStyle:: + eValueObjectRepresentationStyleSummary, + eFormatDefault, + ValueObject::PrintableRepresentationSpecialCases::eAllow, + false); } - if (close_paren) - s.PutCString(close_paren); - else - s.PutChar(')'); - - } else { - s.PutCString(cstr); + if (!ss.GetString().empty()) + var_representation = ss.GetString(); + if (arg_idx > 0) + s.PutCString(", "); + if (var_value_sp->GetError().Success()) { + if (!var_representation.empty()) + s.Printf("%s=%s", var_name, var_representation.str().c_str()); + else + s.Printf("%s=%s at %s", var_name, + var_value_sp->GetTypeName().GetCString(), + var_value_sp->GetLocationAsCString()); + } else + s.Printf("%s=", var_name); } - return true; + + if (close_paren) + s.PutCString(close_paren); + else + s.PutChar(')'); + + } else { + s.PutCString(cstr); } + return true; + } } else if (sc->symbol) { const char *cstr = sc->symbol->GetName().AsCString(nullptr); if (cstr) { @@ -1754,7 +1746,6 @@ return true; } } - } } return false; @@ -1986,14 +1977,12 @@ else remainder = llvm::StringRef(); // Exact match return entry_def; - } else { - if (entry_def->children) { - return FindEntry(p.second, entry_def, remainder); - } else { - remainder = p.second; - return entry_def; - } } + if (entry_def->children) { + return FindEntry(p.second, entry_def, remainder); + } + remainder = p.second; + return entry_def; } } remainder = format_str; @@ -2331,7 +2320,8 @@ if (variable_name.empty() || variable_name.equals(".fullpath")) { file_spec.Dump(&s); return true; - } else if (variable_name.equals(".basename")) { + } + if (variable_name.equals(".basename")) { s.PutCString(file_spec.GetFilename().AsCString("")); return true; } else if (variable_name.equals(".dirname")) { Index: source/Core/IOHandler.cpp =================================================================== --- source/Core/IOHandler.cpp +++ source/Core/IOHandler.cpp @@ -340,71 +340,71 @@ #ifndef LLDB_DISABLE_LIBEDIT if (m_editline_ap) { return m_editline_ap->GetLine(line, interrupted); - } else { + } #endif - line.clear(); + line.clear(); - FILE *in = GetInputFILE(); - if (in) { - if (GetIsInteractive()) { - const char *prompt = nullptr; + FILE *in = GetInputFILE(); + if (in) { + if (GetIsInteractive()) { + const char *prompt = nullptr; - if (m_multi_line && m_curr_line_idx > 0) - prompt = GetContinuationPrompt(); + if (m_multi_line && m_curr_line_idx > 0) + prompt = GetContinuationPrompt(); - if (prompt == nullptr) - prompt = GetPrompt(); + if (prompt == nullptr) + prompt = GetPrompt(); - if (prompt && prompt[0]) { - FILE *out = GetOutputFILE(); - if (out) { - ::fprintf(out, "%s", prompt); - ::fflush(out); - } + if (prompt && prompt[0]) { + FILE *out = GetOutputFILE(); + if (out) { + ::fprintf(out, "%s", prompt); + ::fflush(out); } } - char buffer[256]; - bool done = false; - bool got_line = false; - m_editing = true; - while (!done) { - if (fgets(buffer, sizeof(buffer), in) == nullptr) { - const int saved_errno = errno; - if (feof(in)) - done = true; - else if (ferror(in)) { - if (saved_errno != EINTR) - done = true; - } - } else { - got_line = true; - size_t buffer_len = strlen(buffer); - assert(buffer[buffer_len] == '\0'); - char last_char = buffer[buffer_len - 1]; - if (last_char == '\r' || last_char == '\n') { + } + char buffer[256]; + bool done = false; + bool got_line = false; + m_editing = true; + while (!done) { + if (fgets(buffer, sizeof(buffer), in) == nullptr) { + const int saved_errno = errno; + if (feof(in)) + done = true; + else if (ferror(in)) { + if (saved_errno != EINTR) done = true; - // Strip trailing newlines - while (last_char == '\r' || last_char == '\n') { - --buffer_len; - if (buffer_len == 0) - break; - last_char = buffer[buffer_len - 1]; - } + } + } else { + got_line = true; + size_t buffer_len = strlen(buffer); + assert(buffer[buffer_len] == '\0'); + char last_char = buffer[buffer_len - 1]; + if (last_char == '\r' || last_char == '\n') { + done = true; + // Strip trailing newlines + while (last_char == '\r' || last_char == '\n') { + --buffer_len; + if (buffer_len == 0) + break; + last_char = buffer[buffer_len - 1]; } - line.append(buffer, buffer_len); } + line.append(buffer, buffer_len); } - m_editing = false; - // We might have gotten a newline on a line by itself make sure to return - // true in this case. - return got_line; - } else { - // No more input file, we are done... - SetIsDone(true); } - return false; -#ifndef LLDB_DISABLE_LIBEDIT + m_editing = false; + // We might have gotten a newline on a line by itself make sure to return + // true in this case. + return got_line; } + // No more input file, we are done... + SetIsDone(true); + + return false; +#ifndef LLDB_DISABLE_LIBEDIT + #endif } @@ -443,12 +443,12 @@ #ifndef LLDB_DISABLE_LIBEDIT if (m_editline_ap) { return m_editline_ap->GetPrompt(); - } else { + } #endif - if (m_prompt.empty()) - return nullptr; + if (m_prompt.empty()) + return nullptr; #ifndef LLDB_DISABLE_LIBEDIT - } + #endif return m_prompt.c_str(); } @@ -498,34 +498,34 @@ #ifndef LLDB_DISABLE_LIBEDIT if (m_editline_ap) { return m_editline_ap->GetLines(m_base_line_number, lines, interrupted); - } else { + } #endif - bool done = false; - Status error; - - while (!done) { - // Show line numbers if we are asked to - std::string line; - if (m_base_line_number > 0 && GetIsInteractive()) { - FILE *out = GetOutputFILE(); - if (out) - ::fprintf(out, "%u%s", m_base_line_number + (uint32_t)lines.GetSize(), - GetPrompt() == nullptr ? " " : ""); - } + bool done = false; + Status error; + + while (!done) { + // Show line numbers if we are asked to + std::string line; + if (m_base_line_number > 0 && GetIsInteractive()) { + FILE *out = GetOutputFILE(); + if (out) + ::fprintf(out, "%u%s", m_base_line_number + (uint32_t)lines.GetSize(), + GetPrompt() == nullptr ? " " : ""); + } - m_curr_line_idx = lines.GetSize(); + m_curr_line_idx = lines.GetSize(); - bool interrupted = false; - if (GetLine(line, interrupted) && !interrupted) { - lines.AppendString(line); - done = m_delegate.IOHandlerIsInputComplete(*this, lines); - } else { - done = true; - } + bool interrupted = false; + if (GetLine(line, interrupted) && !interrupted) { + lines.AppendString(line); + done = m_delegate.IOHandlerIsInputComplete(*this, lines); + } else { + done = true; } - success = lines.GetSize() > 0; -#ifndef LLDB_DISABLE_LIBEDIT } + success = lines.GetSize() > 0; +#ifndef LLDB_DISABLE_LIBEDIT + #endif return success; } @@ -1256,8 +1256,8 @@ bool IsActive() const { if (m_parent) return m_parent->GetActiveWindow().get() == this; - else - return true; // Top level window is always active + + return true; // Top level window is always active } void SelectNextWindowAsActive() { @@ -1673,8 +1673,8 @@ m_selected = 0; if (m_submenus[m_selected]->GetType() == Type::Separator) continue; - else - break; + + break; } return eKeyHandled; } @@ -1688,8 +1688,8 @@ m_selected = num_submenus - 1; if (m_submenus[m_selected]->GetType() == Type::Separator) continue; - else - break; + + break; } return eKeyHandled; } @@ -2972,15 +2972,14 @@ for (auto &row : rows) { if (row_index == 0) return &row; - else { - --row_index; - auto &children = row.GetChildren(); - if (row.expanded && !children.empty()) { - Row *result = GetRowForRowIndexImpl(children, row_index); - if (result) - return result; + + --row_index; + auto &children = row.GetChildren(); + if (row.expanded && !children.empty()) { + Row *result = GetRowForRowIndexImpl(children, row_index); + if (result) + return result; } - } } return nullptr; } @@ -3097,11 +3096,10 @@ Process *process = exe_ctx.GetProcessPtr(); if (process && process->IsAlive()) return true; // Don't do any updating if we are running - else { - // Update the values with an empty list if there is no process or the - // process isn't alive anymore - SetValues(value_list); - } + + // Update the values with an empty list if there is no process or the + // process isn't alive anymore + SetValues(value_list); } return ValueObjectListDelegate::WindowDelegateDraw(window, force); } Index: source/Core/Listener.cpp =================================================================== --- source/Core/Listener.cpp +++ source/Core/Listener.cpp @@ -360,26 +360,26 @@ num_broadcaster_names, event_type_mask, event_sp, true)) { return true; - } else { - std::cv_status result = std::cv_status::no_timeout; - if (!timeout) - m_events_condition.wait(lock); - else - result = m_events_condition.wait_for(lock, *timeout); - - if (result == std::cv_status::timeout) { - log = lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_EVENTS); - if (log) - log->Printf("%p Listener::GetEventInternal() timed out for %s", - static_cast(this), m_name.c_str()); - return false; - } else if (result != std::cv_status::no_timeout) { - log = lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_EVENTS); - if (log) - log->Printf("%p Listener::GetEventInternal() unknown error for %s", - static_cast(this), m_name.c_str()); - return false; - } + } + std::cv_status result = std::cv_status::no_timeout; + if (!timeout) + m_events_condition.wait(lock); + else + result = m_events_condition.wait_for(lock, *timeout); + + if (result == std::cv_status::timeout) { + log = lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_EVENTS); + if (log) + log->Printf("%p Listener::GetEventInternal() timed out for %s", + static_cast(this), m_name.c_str()); + return false; + } + if (result != std::cv_status::no_timeout) { + log = lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_EVENTS); + if (log) + log->Printf("%p Listener::GetEventInternal() unknown error for %s", + static_cast(this), m_name.c_str()); + return false; } } Index: source/Core/Mangled.cpp =================================================================== --- source/Core/Mangled.cpp +++ source/Core/Mangled.cpp @@ -347,11 +347,10 @@ if (m_demangled.IsEmpty()) { // Cannot demangle it, so don't try parsing. return false; - } else { - // Demangled successfully, we can try and parse it with - // CPlusPlusLanguage::MethodName. - return context.FromCxxMethodName(m_demangled); } + // Demangled successfully, we can try and parse it with + // CPlusPlusLanguage::MethodName. + return context.FromCxxMethodName(m_demangled); } } llvm_unreachable("Fully covered switch above!"); @@ -497,7 +496,7 @@ const char *mangled_name = mangled.GetCString(); if (CPlusPlusLanguage::IsCPPMangledName(mangled_name)) return lldb::eLanguageTypeC_plus_plus; - else if (ObjCLanguage::IsPossibleObjCMethodName(mangled_name)) + if (ObjCLanguage::IsPossibleObjCMethodName(mangled_name)) return lldb::eLanguageTypeObjC; } } else { Index: source/Core/Module.cpp =================================================================== --- source/Core/Module.cpp +++ source/Core/Module.cpp @@ -1482,8 +1482,8 @@ bool Module::IsExecutable() { if (GetObjectFile() == nullptr) return false; - else - return GetObjectFile()->IsExecutable(); + + return GetObjectFile()->IsExecutable(); } bool Module::IsLoadedInTarget(Target *target) { @@ -1587,9 +1587,9 @@ if (object_file != nullptr) { changed = object_file->SetLoadAddress(target, value, value_is_offset); return true; - } else { - changed = false; } + changed = false; + return false; } Index: source/Core/ModuleList.cpp =================================================================== --- source/Core/ModuleList.cpp +++ source/Core/ModuleList.cpp @@ -261,8 +261,8 @@ if (pos->unique()) { pos = RemoveImpl(pos); return true; - } else - return false; + } + return false; } } } Index: source/Core/PluginManager.cpp =================================================================== --- source/Core/PluginManager.cpp +++ source/Core/PluginManager.cpp @@ -108,40 +108,39 @@ if (PluginIsLoaded(plugin_file_spec)) return FileSystem::eEnumerateDirectoryResultNext; - else { - PluginInfo plugin_info; - - std::string pluginLoadError; - plugin_info.library = llvm::sys::DynamicLibrary::getPermanentLibrary( - plugin_file_spec.GetPath().c_str(), &pluginLoadError); - if (plugin_info.library.isValid()) { - bool success = false; - plugin_info.plugin_init_callback = CastToFPtr( - plugin_info.library.getAddressOfSymbol("LLDBPluginInitialize")); - if (plugin_info.plugin_init_callback) { - // Call the plug-in "bool LLDBPluginInitialize(void)" function - success = plugin_info.plugin_init_callback(); - } - - if (success) { - // It is ok for the "LLDBPluginTerminate" symbol to be nullptr - plugin_info.plugin_term_callback = CastToFPtr( - plugin_info.library.getAddressOfSymbol("LLDBPluginTerminate")); - } else { - // The initialize function returned FALSE which means the plug-in - // might not be compatible, or might be too new or too old, or might - // not want to run on this machine. Set it to a default-constructed - // instance to invalidate it. - plugin_info = PluginInfo(); - } - - // Regardless of success or failure, cache the plug-in load in our - // plug-in info so we don't try to load it again and again. - SetPluginInfo(plugin_file_spec, plugin_info); - - return FileSystem::eEnumerateDirectoryResultNext; + + PluginInfo plugin_info; + + std::string pluginLoadError; + plugin_info.library = llvm::sys::DynamicLibrary::getPermanentLibrary( + plugin_file_spec.GetPath().c_str(), &pluginLoadError); + if (plugin_info.library.isValid()) { + bool success = false; + plugin_info.plugin_init_callback = CastToFPtr( + plugin_info.library.getAddressOfSymbol("LLDBPluginInitialize")); + if (plugin_info.plugin_init_callback) { + // Call the plug-in "bool LLDBPluginInitialize(void)" function + success = plugin_info.plugin_init_callback(); + } + + if (success) { + // It is ok for the "LLDBPluginTerminate" symbol to be nullptr + plugin_info.plugin_term_callback = CastToFPtr( + plugin_info.library.getAddressOfSymbol("LLDBPluginTerminate")); + } else { + // The initialize function returned FALSE which means the plug-in + // might not be compatible, or might be too new or too old, or might + // not want to run on this machine. Set it to a default-constructed + // instance to invalidate it. + plugin_info = PluginInfo(); + } + + // Regardless of success or failure, cache the plug-in load in our + // plug-in info so we don't try to load it again and again. + SetPluginInfo(plugin_file_spec, plugin_info); + + return FileSystem::eEnumerateDirectoryResultNext; } - } } if (ft == fs::file_type::directory_file || @@ -1640,9 +1639,9 @@ if (idx < instances.size()) { iteration_complete = false; return instances[idx].filter_callback; - } else { - iteration_complete = true; } + iteration_complete = true; + return nullptr; } Index: source/Core/SearchFilter.cpp =================================================================== --- source/Core/SearchFilter.cpp +++ source/Core/SearchFilter.cpp @@ -290,7 +290,7 @@ DoCUIteration(module_sp, context, searcher); if (shouldContinue == Searcher::eCallbackReturnStop) return shouldContinue; - else if (shouldContinue == Searcher::eCallbackReturnPop) + if (shouldContinue == Searcher::eCallbackReturnPop) continue; } } @@ -319,7 +319,7 @@ if (shouldContinue == Searcher::eCallbackReturnPop) return Searcher::eCallbackReturnContinue; - else if (shouldContinue == Searcher::eCallbackReturnStop) + if (shouldContinue == Searcher::eCallbackReturnStop) return shouldContinue; } else { // First make sure this compile unit's functions are parsed @@ -390,15 +390,15 @@ const FileSpec &module_spec) { if (m_target_sp->ModuleIsExcludedForUnconstrainedSearches(module_spec)) return false; - else - return true; + + return true; } bool SearchFilterForUnconstrainedSearches::ModulePasses( const lldb::ModuleSP &module_sp) { if (!module_sp) return true; - else if (m_target_sp->ModuleIsExcludedForUnconstrainedSearches(module_sp)) + if (m_target_sp->ModuleIsExcludedForUnconstrainedSearches(module_sp)) return false; else return true; @@ -574,8 +574,8 @@ m_module_spec_list.FindFileIndex(0, module_sp->GetFileSpec(), false) != UINT32_MAX) return true; - else - return false; + + return false; } bool SearchFilterByModuleList::ModulePasses(const FileSpec &spec) { @@ -584,8 +584,8 @@ if (m_module_spec_list.FindFileIndex(0, spec, true) != UINT32_MAX) return true; - else - return false; + + return false; } bool SearchFilterByModuleList::AddressPasses(Address &address) { @@ -806,8 +806,8 @@ if (module_sp) { bool module_passes = SearchFilterByModuleList::ModulePasses(module_sp); return module_passes; - } else - return true; + } + return true; } else return false; } Index: source/Core/Section.cpp =================================================================== --- source/Core/Section.cpp +++ source/Core/Section.cpp @@ -210,11 +210,10 @@ if (m_file_addr >= file_addr) return parent_sp->SetFileAddress(m_file_addr - file_addr); return false; - } else { - // This section has no parent, so m_file_addr is the file base address - m_file_addr = file_addr; - return true; } + // This section has no parent, so m_file_addr is the file base address + m_file_addr = file_addr; + return true; } lldb::addr_t Section::GetOffset() const { @@ -291,13 +290,12 @@ if (a_sect_uid > b_sect_uid) return 1; return 0; - } else { - // The modules are different, just compare the module pointers - if (a_module_sp.get() < b_module_sp.get()) - return -1; - else - return 1; // We already know the modules aren't equal } + // The modules are different, just compare the module pointers + if (a_module_sp.get() < b_module_sp.get()) + return -1; + + return 1; // We already know the modules aren't equal } void Section::Dump(Stream *s, Target *target, uint32_t depth) const { @@ -478,7 +476,8 @@ if ((*sect_iter)->GetID() == sect_id) { *sect_iter = sect_sp; return true; - } else if (depth > 0) { + } + if (depth > 0) { if ((*sect_iter) ->GetChildren() .ReplaceSection(sect_id, sect_sp, depth - 1)) @@ -539,9 +538,8 @@ if ((*sect_iter)->GetID() == sect_id) { sect_sp = *sect_iter; break; - } else { - sect_sp = (*sect_iter)->GetChildren().FindSectionByID(sect_id); } + sect_sp = (*sect_iter)->GetChildren().FindSectionByID(sect_id); } } return sect_sp; @@ -556,7 +554,8 @@ if (m_sections[idx]->GetType() == sect_type) { sect_sp = m_sections[idx]; break; - } else if (check_children) { + } + if (check_children) { sect_sp = m_sections[idx]->GetChildren().FindSectionByType( sect_type, check_children, 0); if (sect_sp) Index: source/Core/SourceManager.cpp =================================================================== --- source/Core/SourceManager.cpp +++ source/Core/SourceManager.cpp @@ -304,10 +304,9 @@ if (m_last_file_sp) { m_last_line = line; return true; - } else { - m_last_file_sp = old_file_sp; - return false; } + m_last_file_sp = old_file_sp; + return false; } bool SourceManager::GetDefaultFileAndLine(FileSpec &file_spec, uint32_t &line) { @@ -315,7 +314,8 @@ file_spec = m_last_file_sp->GetFileSpec(); line = m_last_line; return true; - } else if (!m_default_set) { + } + if (!m_default_set) { TargetSP target_sp(m_target_wp.lock()); if (target_sp) { @@ -413,8 +413,8 @@ if (test_cu_spec != static_cast(sc.comp_unit)) got_multiple = true; break; - } else - test_cu_spec = sc.comp_unit; + } + test_cu_spec = sc.comp_unit; } } } Index: source/Core/Value.cpp =================================================================== --- source/Core/Value.cpp +++ source/Core/Value.cpp @@ -702,8 +702,8 @@ Value *ValueList::GetValueAtIndex(size_t idx) { if (idx < GetSize()) { return &(m_values[idx]); - } else - return NULL; + } + return NULL; } void ValueList::Clear() { m_values.clear(); } Index: source/Core/ValueObject.cpp =================================================================== --- source/Core/ValueObject.cpp +++ source/Core/ValueObject.cpp @@ -281,8 +281,8 @@ if (m_did_calculate_complete_objc_class_type) { if (m_override_type.IsValid()) return m_override_type; - else - return compiler_type; + + return compiler_type; } CompilerType class_type; @@ -593,8 +593,8 @@ if (m_children_count_valid) { size_t children_count = m_children.GetChildrenCount(); return children_count <= max ? children_count : max; - } else - return CalculateNumChildren(max); + } + return CalculateNumChildren(max); } if (!m_children_count_valid) { @@ -772,44 +772,43 @@ if (error.Fail() || pointee_sp.get() == NULL) return 0; return pointee_sp->GetData(data, error); - } else { - ValueObjectSP child_sp = GetChildAtIndex(0, true); - if (child_sp.get() == NULL) - return 0; - Status error; - return child_sp->GetData(data, error); } - return true; - } else /* (items > 1) */ - { + ValueObjectSP child_sp = GetChildAtIndex(0, true); + if (child_sp.get() == NULL) + return 0; Status error; - lldb_private::DataBufferHeap *heap_buf_ptr = NULL; - lldb::DataBufferSP data_sp(heap_buf_ptr = - new lldb_private::DataBufferHeap()); - - AddressType addr_type; - lldb::addr_t addr = is_pointer_type ? GetPointerValue(&addr_type) - : GetAddressOf(true, &addr_type); - - switch (addr_type) { - case eAddressTypeFile: { - ModuleSP module_sp(GetModule()); - if (module_sp) { - addr = addr + offset; - Address so_addr; - module_sp->ResolveFileAddress(addr, so_addr); - ExecutionContext exe_ctx(GetExecutionContextRef()); - Target *target = exe_ctx.GetTargetPtr(); - if (target) { - heap_buf_ptr->SetByteSize(bytes); - size_t bytes_read = target->ReadMemory( - so_addr, false, heap_buf_ptr->GetBytes(), bytes, error); - if (error.Success()) { - data.SetData(data_sp); - return bytes_read; - } + return child_sp->GetData(data, error); + + return true; + } /* (items > 1) */ + + Status error; + lldb_private::DataBufferHeap *heap_buf_ptr = NULL; + lldb::DataBufferSP data_sp(heap_buf_ptr = new lldb_private::DataBufferHeap()); + + AddressType addr_type; + lldb::addr_t addr = is_pointer_type ? GetPointerValue(&addr_type) + : GetAddressOf(true, &addr_type); + + switch (addr_type) { + case eAddressTypeFile: { + ModuleSP module_sp(GetModule()); + if (module_sp) { + addr = addr + offset; + Address so_addr; + module_sp->ResolveFileAddress(addr, so_addr); + ExecutionContext exe_ctx(GetExecutionContextRef()); + Target *target = exe_ctx.GetTargetPtr(); + if (target) { + heap_buf_ptr->SetByteSize(bytes); + size_t bytes_read = target->ReadMemory( + so_addr, false, heap_buf_ptr->GetBytes(), bytes, error); + if (error.Success()) { + data.SetData(data_sp); + return bytes_read; } } + } } break; case eAddressTypeLoad: { ExecutionContext exe_ctx(GetExecutionContextRef()); @@ -840,8 +839,8 @@ case eAddressTypeInvalid: break; } - } - return 0; + + return 0; } uint64_t ValueObject::GetData(DataExtractor &data, Status &error) { @@ -853,9 +852,8 @@ data = m_data; error.Clear(); return data.GetByteSize(); - } else { - return 0; } + return 0; } data.SetAddressByteSize(m_data.GetAddressByteSize()); data.SetByteOrder(m_data.GetByteOrder()); @@ -995,12 +993,11 @@ buffer_sp.reset(new DataBufferHeap(cstr_len, 0)); memcpy(buffer_sp->GetBytes(), cstr, cstr_len); return {cstr_len, was_capped}; - } else { - s << ""; - error.SetErrorString("invalid address"); - CopyStringDataToBufferSP(s, buffer_sp); - return {0, was_capped}; } + s << ""; + error.SetErrorString("invalid address"); + CopyStringDataToBufferSP(s, buffer_sp); + return {0, was_capped}; } Address cstr_so_addr(cstr_address); @@ -1128,16 +1125,16 @@ if (m_object_desc_str.empty()) return NULL; - else - return m_object_desc_str.c_str(); + + return m_object_desc_str.c_str(); } bool ValueObject::GetValueAsCString(const lldb_private::TypeFormatImpl &format, std::string &destination) { if (UpdateValueIfNeeded(false)) return format.FormatObject(this, destination); - else - return false; + + return false; } bool ValueObject::GetValueAsCString(lldb::Format format, @@ -1698,8 +1695,8 @@ Process *process = exe_ctx.GetProcessPtr(); if (process) return process->IsPossibleDynamicValue(*this); - else - return GetCompilerType().IsPossibleDynamicType(NULL, true, true); + + return GetCompilerType().IsPossibleDynamicType(NULL, true, true); } bool ValueObject::IsRuntimeSupportValue() { @@ -1967,8 +1964,8 @@ } if (m_dynamic_value) return m_dynamic_value->GetSP(); - else - return ValueObjectSP(); + + return ValueObjectSP(); } ValueObjectSP ValueObject::GetStaticValue() { return GetSP(); } @@ -1983,8 +1980,8 @@ if (m_synthetic_value) return m_synthetic_value->GetSP(); - else - return ValueObjectSP(); + + return ValueObjectSP(); } bool ValueObject::HasSyntheticValue() { @@ -1997,8 +1994,8 @@ if (m_synthetic_value) return true; - else - return false; + + return false; } bool ValueObject::GetBaseClassPath(Stream &s) { @@ -2023,8 +2020,8 @@ if (GetParent()) { if (GetParent()->IsBaseClass()) return GetParent()->GetNonBaseClassParent(); - else - return GetParent(); + + return GetParent(); } return NULL; } @@ -2058,15 +2055,13 @@ s.Printf("((%s)0x%" PRIx64 ")", GetTypeName().AsCString("void"), GetValueAsUnsigned(0)); return; - } else { - uint64_t load_addr = - m_value.GetScalar().ULongLong(LLDB_INVALID_ADDRESS); - if (load_addr != LLDB_INVALID_ADDRESS) { - s.Printf("(*( (%s *)0x%" PRIx64 "))", GetTypeName().AsCString("void"), - load_addr); - return; - } } + uint64_t load_addr = m_value.GetScalar().ULongLong(LLDB_INVALID_ADDRESS); + if (load_addr != LLDB_INVALID_ADDRESS) { + s.Printf("(*( (%s *)0x%" PRIx64 "))", GetTypeName().AsCString("void"), + load_addr); + return; + } } if (CanProvideValue()) { @@ -2184,11 +2179,10 @@ if (final_value_type) *final_value_type = ValueObject::eExpressionPathEndResultTypeInvalid; return ValueObjectSP(); - } else { - if (final_task_on_target) - *final_task_on_target = ValueObject::eExpressionPathAftermathNothing; - return final_value; } + if (final_task_on_target) + *final_task_on_target = ValueObject::eExpressionPathAftermathNothing; + return final_value; } if (*final_task_on_target == ValueObject::eExpressionPathAftermathTakeAddress) { @@ -2201,11 +2195,10 @@ if (final_value_type) *final_value_type = ValueObject::eExpressionPathEndResultTypeInvalid; return ValueObjectSP(); - } else { - if (final_task_on_target) - *final_task_on_target = ValueObject::eExpressionPathAftermathNothing; - return final_value; } + if (final_task_on_target) + *final_task_on_target = ValueObject::eExpressionPathAftermathNothing; + return final_value; } } return ret_val; // final_task_on_target will still have its original value, so @@ -2304,44 +2297,41 @@ ValueObject::eExpressionPathScanEndReasonEndOfString; *final_result = ValueObject::eExpressionPathEndResultTypePlain; return child_valobj_sp; - } else { - switch (options.m_synthetic_children_traversal) { - case GetValueForExpressionPathOptions::SyntheticChildrenTraversal:: - None: - break; - case GetValueForExpressionPathOptions::SyntheticChildrenTraversal:: - FromSynthetic: - if (root->IsSynthetic()) { - child_valobj_sp = root->GetNonSyntheticValue(); - if (child_valobj_sp.get()) - child_valobj_sp = - child_valobj_sp->GetChildMemberWithName(child_name, true); - } - break; - case GetValueForExpressionPathOptions::SyntheticChildrenTraversal:: - ToSynthetic: - if (!root->IsSynthetic()) { - child_valobj_sp = root->GetSyntheticValue(); - if (child_valobj_sp.get()) - child_valobj_sp = - child_valobj_sp->GetChildMemberWithName(child_name, true); - } - break; - case GetValueForExpressionPathOptions::SyntheticChildrenTraversal:: - Both: - if (root->IsSynthetic()) { - child_valobj_sp = root->GetNonSyntheticValue(); - if (child_valobj_sp.get()) - child_valobj_sp = - child_valobj_sp->GetChildMemberWithName(child_name, true); - } else { - child_valobj_sp = root->GetSyntheticValue(); - if (child_valobj_sp.get()) - child_valobj_sp = - child_valobj_sp->GetChildMemberWithName(child_name, true); - } - break; + } + switch (options.m_synthetic_children_traversal) { + case GetValueForExpressionPathOptions::SyntheticChildrenTraversal::None: + break; + case GetValueForExpressionPathOptions::SyntheticChildrenTraversal:: + FromSynthetic: + if (root->IsSynthetic()) { + child_valobj_sp = root->GetNonSyntheticValue(); + if (child_valobj_sp.get()) + child_valobj_sp = + child_valobj_sp->GetChildMemberWithName(child_name, true); + } + break; + case GetValueForExpressionPathOptions::SyntheticChildrenTraversal:: + ToSynthetic: + if (!root->IsSynthetic()) { + child_valobj_sp = root->GetSyntheticValue(); + if (child_valobj_sp.get()) + child_valobj_sp = + child_valobj_sp->GetChildMemberWithName(child_name, true); + } + break; + case GetValueForExpressionPathOptions::SyntheticChildrenTraversal::Both: + if (root->IsSynthetic()) { + child_valobj_sp = root->GetNonSyntheticValue(); + if (child_valobj_sp.get()) + child_valobj_sp = + child_valobj_sp->GetChildMemberWithName(child_name, true); + } else { + child_valobj_sp = root->GetSyntheticValue(); + if (child_valobj_sp.get()) + child_valobj_sp = + child_valobj_sp->GetChildMemberWithName(child_name, true); } + break; } // if we are here and options.m_no_synthetic_children is true, @@ -2353,12 +2343,11 @@ ValueObject::eExpressionPathScanEndReasonEndOfString; *final_result = ValueObject::eExpressionPathEndResultTypePlain; return child_valobj_sp; - } else { - *reason_to_stop = - ValueObject::eExpressionPathScanEndReasonNoSuchChild; - *final_result = ValueObject::eExpressionPathEndResultTypeInvalid; - return nullptr; } + *reason_to_stop = ValueObject::eExpressionPathScanEndReasonNoSuchChild; + *final_result = ValueObject::eExpressionPathEndResultTypeInvalid; + return nullptr; + } else // other layers do expand { llvm::StringRef next_separator = temp_expression.substr(next_sep_pos); @@ -2373,44 +2362,41 @@ remainder = next_separator; *final_result = ValueObject::eExpressionPathEndResultTypePlain; continue; - } else { - switch (options.m_synthetic_children_traversal) { - case GetValueForExpressionPathOptions::SyntheticChildrenTraversal:: - None: - break; - case GetValueForExpressionPathOptions::SyntheticChildrenTraversal:: - FromSynthetic: - if (root->IsSynthetic()) { - child_valobj_sp = root->GetNonSyntheticValue(); - if (child_valobj_sp.get()) - child_valobj_sp = - child_valobj_sp->GetChildMemberWithName(child_name, true); - } - break; - case GetValueForExpressionPathOptions::SyntheticChildrenTraversal:: - ToSynthetic: - if (!root->IsSynthetic()) { - child_valobj_sp = root->GetSyntheticValue(); - if (child_valobj_sp.get()) - child_valobj_sp = - child_valobj_sp->GetChildMemberWithName(child_name, true); - } - break; - case GetValueForExpressionPathOptions::SyntheticChildrenTraversal:: - Both: - if (root->IsSynthetic()) { - child_valobj_sp = root->GetNonSyntheticValue(); - if (child_valobj_sp.get()) - child_valobj_sp = - child_valobj_sp->GetChildMemberWithName(child_name, true); - } else { - child_valobj_sp = root->GetSyntheticValue(); - if (child_valobj_sp.get()) - child_valobj_sp = - child_valobj_sp->GetChildMemberWithName(child_name, true); - } - break; + } + switch (options.m_synthetic_children_traversal) { + case GetValueForExpressionPathOptions::SyntheticChildrenTraversal::None: + break; + case GetValueForExpressionPathOptions::SyntheticChildrenTraversal:: + FromSynthetic: + if (root->IsSynthetic()) { + child_valobj_sp = root->GetNonSyntheticValue(); + if (child_valobj_sp.get()) + child_valobj_sp = + child_valobj_sp->GetChildMemberWithName(child_name, true); + } + break; + case GetValueForExpressionPathOptions::SyntheticChildrenTraversal:: + ToSynthetic: + if (!root->IsSynthetic()) { + child_valobj_sp = root->GetSyntheticValue(); + if (child_valobj_sp.get()) + child_valobj_sp = + child_valobj_sp->GetChildMemberWithName(child_name, true); + } + break; + case GetValueForExpressionPathOptions::SyntheticChildrenTraversal::Both: + if (root->IsSynthetic()) { + child_valobj_sp = root->GetNonSyntheticValue(); + if (child_valobj_sp.get()) + child_valobj_sp = + child_valobj_sp->GetChildMemberWithName(child_name, true); + } else { + child_valobj_sp = root->GetSyntheticValue(); + if (child_valobj_sp.get()) + child_valobj_sp = + child_valobj_sp->GetChildMemberWithName(child_name, true); } + break; } // if we are here and options.m_no_synthetic_children is true, @@ -2422,12 +2408,10 @@ remainder = next_separator; *final_result = ValueObject::eExpressionPathEndResultTypePlain; continue; - } else { - *reason_to_stop = - ValueObject::eExpressionPathScanEndReasonNoSuchChild; - *final_result = ValueObject::eExpressionPathEndResultTypeInvalid; - return nullptr; } + *reason_to_stop = ValueObject::eExpressionPathScanEndReasonNoSuchChild; + *final_result = ValueObject::eExpressionPathEndResultTypeInvalid; + return nullptr; } break; } @@ -2467,15 +2451,13 @@ ValueObject::eExpressionPathScanEndReasonEmptyRangeNotAllowed; *final_result = ValueObject::eExpressionPathEndResultTypeInvalid; return nullptr; - } else // even if something follows, we cannot expand unbounded ranges, - // just let the caller do it - { - *reason_to_stop = - ValueObject::eExpressionPathScanEndReasonArrayRangeOperatorMet; - *final_result = - ValueObject::eExpressionPathEndResultTypeUnboundedRange; - return root; - } + } // even if something follows, we cannot expand unbounded ranges, + // just let the caller do it + + *reason_to_stop = + ValueObject::eExpressionPathScanEndReasonArrayRangeOperatorMet; + *final_result = ValueObject::eExpressionPathEndResultTypeUnboundedRange; + return root; } size_t close_bracket_position = temp_expression.find(']', 1); @@ -2523,12 +2505,12 @@ temp_expression.substr(close_bracket_position + 1); // skip ] *final_result = ValueObject::eExpressionPathEndResultTypePlain; continue; - } else { - *reason_to_stop = - ValueObject::eExpressionPathScanEndReasonNoSuchChild; - *final_result = ValueObject::eExpressionPathEndResultTypeInvalid; - return nullptr; } + *reason_to_stop = + ValueObject::eExpressionPathScanEndReasonNoSuchChild; + *final_result = ValueObject::eExpressionPathEndResultTypeInvalid; + return nullptr; + } else if (root_compiler_type_info.Test(eTypeIsPointer)) { if (*what_next == ValueObject:: @@ -2549,10 +2531,10 @@ ValueObject::eExpressionPathScanEndReasonDereferencingFailed; *final_result = ValueObject::eExpressionPathEndResultTypeInvalid; return nullptr; - } else { - *what_next = eExpressionPathAftermathNothing; - continue; } + *what_next = eExpressionPathAftermathNothing; + continue; + } else { if (root->GetCompilerType().GetMinimumLanguage() == eLanguageTypeObjC && @@ -2572,12 +2554,11 @@ ValueObject::eExpressionPathScanEndReasonNoSuchChild; *final_result = ValueObject::eExpressionPathEndResultTypeInvalid; return nullptr; - } else { - remainder = - temp_expression.substr(close_bracket_position + 1); // skip ] - *final_result = ValueObject::eExpressionPathEndResultTypePlain; - continue; } + remainder = + temp_expression.substr(close_bracket_position + 1); // skip ] + *final_result = ValueObject::eExpressionPathEndResultTypePlain; + continue; } } else if (root_compiler_type_info.Test(eTypeIsScalar)) { root = root->GetSyntheticBitFieldChild(index, index, true); @@ -2586,14 +2567,14 @@ ValueObject::eExpressionPathScanEndReasonNoSuchChild; *final_result = ValueObject::eExpressionPathEndResultTypeInvalid; return nullptr; - } else // we do not know how to expand members of bitfields, so we - // just return and let the caller do any further processing - { - *reason_to_stop = ValueObject:: - eExpressionPathScanEndReasonBitfieldRangeOperatorMet; - *final_result = ValueObject::eExpressionPathEndResultTypeBitfield; - return root; - } + } // we do not know how to expand members of bitfields, so we + // just return and let the caller do any further processing + + *reason_to_stop = + ValueObject::eExpressionPathScanEndReasonBitfieldRangeOperatorMet; + *final_result = ValueObject::eExpressionPathEndResultTypeBitfield; + return root; + } else if (root_compiler_type_info.Test(eTypeIsVector)) { root = root->GetChildAtIndex(index, true); if (!root) { @@ -2601,12 +2582,12 @@ ValueObject::eExpressionPathScanEndReasonNoSuchChild; *final_result = ValueObject::eExpressionPathEndResultTypeInvalid; return ValueObjectSP(); - } else { - remainder = - temp_expression.substr(close_bracket_position + 1); // skip ] - *final_result = ValueObject::eExpressionPathEndResultTypePlain; - continue; } + remainder = + temp_expression.substr(close_bracket_position + 1); // skip ] + *final_result = ValueObject::eExpressionPathEndResultTypePlain; + continue; + } else if (options.m_synthetic_children_traversal == GetValueForExpressionPathOptions:: SyntheticChildrenTraversal::ToSynthetic || @@ -2636,12 +2617,12 @@ ValueObject::eExpressionPathScanEndReasonNoSuchChild; *final_result = ValueObject::eExpressionPathEndResultTypeInvalid; return nullptr; - } else { - remainder = - temp_expression.substr(close_bracket_position + 1); // skip ] - *final_result = ValueObject::eExpressionPathEndResultTypePlain; - continue; } + remainder = + temp_expression.substr(close_bracket_position + 1); // skip ] + *final_result = ValueObject::eExpressionPathEndResultTypePlain; + continue; + } else { *reason_to_stop = ValueObject::eExpressionPathScanEndReasonNoSuchChild; @@ -2673,12 +2654,12 @@ ValueObject::eExpressionPathScanEndReasonNoSuchChild; *final_result = ValueObject::eExpressionPathEndResultTypeInvalid; return nullptr; - } else { - *reason_to_stop = ValueObject:: - eExpressionPathScanEndReasonBitfieldRangeOperatorMet; - *final_result = ValueObject::eExpressionPathEndResultTypeBitfield; - return root; } + *reason_to_stop = + ValueObject::eExpressionPathScanEndReasonBitfieldRangeOperatorMet; + *final_result = ValueObject::eExpressionPathEndResultTypeBitfield; + return root; + } else if (root_compiler_type_info.Test( eTypeIsPointer) && // if this is a ptr-to-scalar, I am // accessing it by index and I would @@ -2694,10 +2675,10 @@ ValueObject::eExpressionPathScanEndReasonDereferencingFailed; *final_result = ValueObject::eExpressionPathEndResultTypeInvalid; return nullptr; - } else { - *what_next = ValueObject::eExpressionPathAftermathNothing; - continue; } + *what_next = ValueObject::eExpressionPathAftermathNothing; + continue; + } else { *reason_to_stop = ValueObject::eExpressionPathScanEndReasonArrayRangeOperatorMet; @@ -2853,20 +2834,19 @@ if (m_deref_valobj) { error.Clear(); return m_deref_valobj->GetSP(); - } else { - StreamString strm; - GetExpressionPath(strm, true); - - if (is_pointer_or_reference_type) - error.SetErrorStringWithFormat("dereference failed: (%s) %s", - GetTypeName().AsCString(""), - strm.GetData()); - else - error.SetErrorStringWithFormat("not a pointer or reference type: (%s) %s", - GetTypeName().AsCString(""), - strm.GetData()); - return ValueObjectSP(); } + StreamString strm; + GetExpressionPath(strm, true); + + if (is_pointer_or_reference_type) + error.SetErrorStringWithFormat("dereference failed: (%s) %s", + GetTypeName().AsCString(""), + strm.GetData()); + else + error.SetErrorStringWithFormat("not a pointer or reference type: (%s) %s", + GetTypeName().AsCString(""), + strm.GetData()); + return ValueObjectSP(); } ValueObjectSP ValueObject::AddressOf(Status &error) { Index: source/Core/ValueObjectConstResultImpl.cpp =================================================================== --- source/Core/ValueObjectConstResultImpl.cpp +++ source/Core/ValueObjectConstResultImpl.cpp @@ -138,8 +138,8 @@ m_address_of_backend->GetValue().GetScalar() = m_live_address; return m_address_of_backend; - } else - return m_impl_backend->ValueObject::AddressOf(error); + } + return m_impl_backend->ValueObject::AddressOf(error); } lldb::ValueObjectSP Index: source/Core/ValueObjectDynamicValue.cpp =================================================================== --- source/Core/ValueObjectDynamicValue.cpp +++ source/Core/ValueObjectDynamicValue.cpp @@ -46,8 +46,8 @@ if (success) { if (m_dynamic_type_info.HasType()) return m_value.GetCompilerType(); - else - return m_parent->GetCompilerType(); + + return m_parent->GetCompilerType(); } return m_parent->GetCompilerType(); } @@ -95,8 +95,8 @@ ExecutionContext exe_ctx(GetExecutionContextRef()); auto children_count = GetCompilerType().GetNumChildren(true, &exe_ctx); return children_count <= max ? children_count : max; - } else - return m_parent->GetNumChildren(max); + } + return m_parent->GetNumChildren(max); } uint64_t ValueObjectDynamicValue::GetByteSize() { @@ -104,8 +104,8 @@ if (success && m_dynamic_type_info.HasType()) { ExecutionContext exe_ctx(GetExecutionContextRef()); return m_value.GetValueByteSize(nullptr, &exe_ctx); - } else - return m_parent->GetByteSize(); + } + return m_parent->GetByteSize(); } lldb::ValueType ValueObjectDynamicValue::GetValueType() const { @@ -353,8 +353,8 @@ if (m_parent) return m_parent->GetPreferredDisplayLanguage(); return lldb::eLanguageTypeUnknown; - } else - return m_preferred_display_language; + } + return m_preferred_display_language; } bool ValueObjectDynamicValue::IsSyntheticChildrenGenerated() { Index: source/Core/ValueObjectRegister.cpp =================================================================== --- source/Core/ValueObjectRegister.cpp +++ source/Core/ValueObjectRegister.cpp @@ -199,8 +199,8 @@ } if (valobj) return valobj->GetSP(); - else - return ValueObjectSP(); + + return ValueObjectSP(); } size_t @@ -327,8 +327,8 @@ if (m_reg_ctx_sp->WriteRegister(&m_reg_info, m_reg_value)) { SetNeedsUpdate(); return true; - } else - return false; + } + return false; } else return false; } @@ -339,8 +339,8 @@ if (m_reg_ctx_sp->WriteRegister(&m_reg_info, m_reg_value)) { SetNeedsUpdate(); return true; - } else - return false; + } + return false; } else return false; } Index: source/Core/ValueObjectSyntheticFilter.cpp =================================================================== --- source/Core/ValueObjectSyntheticFilter.cpp +++ source/Core/ValueObjectSyntheticFilter.cpp @@ -94,16 +94,14 @@ GetName().AsCString(), GetTypeName().AsCString(), num_children); return num_children; - } else { - size_t num_children = (m_synthetic_children_count = - m_synth_filter_ap->CalculateNumChildren(max)); - if (log) - log->Printf("[ValueObjectSynthetic::CalculateNumChildren] for VO of name " - "%s and type %s, the filter returned %zu child values", - GetName().AsCString(), GetTypeName().AsCString(), - num_children); - return num_children; } + size_t num_children = (m_synthetic_children_count = + m_synth_filter_ap->CalculateNumChildren(max)); + if (log) + log->Printf("[ValueObjectSynthetic::CalculateNumChildren] for VO of name " + "%s and type %s, the filter returned %zu child values", + GetName().AsCString(), GetTypeName().AsCString(), num_children); + return num_children; } lldb::ValueObjectSP @@ -263,16 +261,16 @@ synth_guy->SetPreferredDisplayLanguageIfNeeded( GetPreferredDisplayLanguage()); return synth_guy; - } else { - if (log) - log->Printf("[ValueObjectSynthetic::GetChildAtIndex] name=%s, child at " - "index %zu not cached and cannot " - "be created (can_create = %s, synth_filter = %p)", - GetName().AsCString(), idx, can_create ? "yes" : "no", - static_cast(m_synth_filter_ap.get())); - - return lldb::ValueObjectSP(); } + if (log) + log->Printf("[ValueObjectSynthetic::GetChildAtIndex] name=%s, child at " + "index %zu not cached and cannot " + "be created (can_create = %s, synth_filter = %p)", + GetName().AsCString(), idx, can_create ? "yes" : "no", + static_cast(m_synth_filter_ap.get())); + + return lldb::ValueObjectSP(); + } else { if (log) log->Printf("[ValueObjectSynthetic::GetChildAtIndex] name=%s, child at " @@ -308,7 +306,8 @@ return index; m_name_toindex.SetValueForKey(name.GetCString(), index); return index; - } else if (!did_find && m_synth_filter_ap.get() == nullptr) + } + if (!did_find && m_synth_filter_ap.get() == nullptr) return UINT32_MAX; else /*if (iter != m_name_toindex.end())*/ return found_index; @@ -360,8 +359,8 @@ if (m_parent) return m_parent->GetPreferredDisplayLanguage(); return lldb::eLanguageTypeUnknown; - } else - return m_preferred_display_language; + } + return m_preferred_display_language; } bool ValueObjectSynthetic::IsSyntheticChildrenGenerated() { Index: source/Core/ValueObjectVariable.cpp =================================================================== --- source/Core/ValueObjectVariable.cpp +++ source/Core/ValueObjectVariable.cpp @@ -275,11 +275,10 @@ StackFrame *frame = exe_ctx.GetFramePtr(); if (frame) { return m_variable_sp->IsInScope(frame); - } else { - // This ValueObject had a frame at one time, but now we can't locate it, - // so return false since we probably aren't in scope. - return false; } + // This ValueObject had a frame at one time, but now we can't locate it, + // so return false since we probably aren't in scope. + return false; } // We have a variable that wasn't tied to a frame, which means it is a global // and is always in scope. @@ -313,8 +312,8 @@ const char *ValueObjectVariable::GetLocationAsCString() { if (m_resolved_value.GetContextType() == Value::eContextTypeRegisterInfo) return GetLocationAsCStringImpl(m_resolved_value, m_data); - else - return ValueObject::GetLocationAsCString(); + + return ValueObject::GetLocationAsCString(); } bool ValueObjectVariable::SetValueFromCString(const char *value_str, @@ -339,10 +338,10 @@ if (reg_ctx->WriteRegister(reg_info, reg_value)) { SetNeedsUpdate(); return true; - } else { - error.SetErrorString("unable to write back to register"); - return false; } + error.SetErrorString("unable to write back to register"); + return false; + } else return ValueObject::SetValueFromCString(value_str, error); } @@ -368,10 +367,10 @@ if (reg_ctx->WriteRegister(reg_info, reg_value)) { SetNeedsUpdate(); return true; - } else { - error.SetErrorString("unable to write back to register"); - return false; } + error.SetErrorString("unable to write back to register"); + return false; + } else return ValueObject::SetData(data, error); } Index: source/DataFormatters/CXXFunctionPointer.cpp =================================================================== --- source/DataFormatters/CXXFunctionPointer.cpp +++ source/DataFormatters/CXXFunctionPointer.cpp @@ -52,6 +52,6 @@ if (sstr.GetSize() > 0) { stream.Printf("(%s)", sstr.GetData()); return true; - } else - return false; + } + return false; } Index: source/DataFormatters/FormatManager.cpp =================================================================== --- source/DataFormatters/FormatManager.cpp +++ source/DataFormatters/FormatManager.cpp @@ -391,8 +391,8 @@ lldb::ScriptedSyntheticChildrenSP synth_sp = GetSyntheticForType(type_sp); if (filter_sp->GetRevision() > synth_sp->GetRevision()) return lldb::SyntheticChildrenSP(filter_sp.get()); - else - return lldb::SyntheticChildrenSP(synth_sp.get()); + + return lldb::SyntheticChildrenSP(synth_sp.get()); } #endif Index: source/DataFormatters/TypeCategory.cpp =================================================================== --- source/DataFormatters/TypeCategory.cpp +++ source/DataFormatters/TypeCategory.cpp @@ -149,7 +149,7 @@ &reason_synth); if (!filter_sp.get() && !synth.get()) return false; - else if (!filter_sp.get() && synth.get()) + if (!filter_sp.get() && synth.get()) pick_synth = true; else if (filter_sp.get() && !synth.get()) @@ -167,12 +167,11 @@ *reason |= lldb_private::eFormatterChoiceCriterionRegularExpressionFilter; entry = synth; return true; - } else { - if (regex_filter && reason) - *reason |= lldb_private::eFormatterChoiceCriterionRegularExpressionFilter; - entry = filter_sp; - return true; } + if (regex_filter && reason) + *reason |= lldb_private::eFormatterChoiceCriterionRegularExpressionFilter; + entry = filter_sp; + return true; #else if (filter_sp) { @@ -508,54 +507,54 @@ TypeCategoryImpl::GetTypeNameSpecifierForSummaryAtIndex(size_t index) { if (index < GetTypeSummariesContainer()->GetCount()) return GetTypeSummariesContainer()->GetTypeNameSpecifierAtIndex(index); - else - return GetRegexTypeSummariesContainer()->GetTypeNameSpecifierAtIndex( - index - GetTypeSummariesContainer()->GetCount()); + + return GetRegexTypeSummariesContainer()->GetTypeNameSpecifierAtIndex( + index - GetTypeSummariesContainer()->GetCount()); } TypeCategoryImpl::FormatContainer::MapValueType TypeCategoryImpl::GetFormatAtIndex(size_t index) { if (index < GetTypeFormatsContainer()->GetCount()) return GetTypeFormatsContainer()->GetAtIndex(index); - else - return GetRegexTypeFormatsContainer()->GetAtIndex( - index - GetTypeFormatsContainer()->GetCount()); + + return GetRegexTypeFormatsContainer()->GetAtIndex( + index - GetTypeFormatsContainer()->GetCount()); } TypeCategoryImpl::SummaryContainer::MapValueType TypeCategoryImpl::GetSummaryAtIndex(size_t index) { if (index < GetTypeSummariesContainer()->GetCount()) return GetTypeSummariesContainer()->GetAtIndex(index); - else - return GetRegexTypeSummariesContainer()->GetAtIndex( - index - GetTypeSummariesContainer()->GetCount()); + + return GetRegexTypeSummariesContainer()->GetAtIndex( + index - GetTypeSummariesContainer()->GetCount()); } TypeCategoryImpl::FilterContainer::MapValueType TypeCategoryImpl::GetFilterAtIndex(size_t index) { if (index < GetTypeFiltersContainer()->GetCount()) return GetTypeFiltersContainer()->GetAtIndex(index); - else - return GetRegexTypeFiltersContainer()->GetAtIndex( - index - GetTypeFiltersContainer()->GetCount()); + + return GetRegexTypeFiltersContainer()->GetAtIndex( + index - GetTypeFiltersContainer()->GetCount()); } lldb::TypeNameSpecifierImplSP TypeCategoryImpl::GetTypeNameSpecifierForFormatAtIndex(size_t index) { if (index < GetTypeFormatsContainer()->GetCount()) return GetTypeFormatsContainer()->GetTypeNameSpecifierAtIndex(index); - else - return GetRegexTypeFormatsContainer()->GetTypeNameSpecifierAtIndex( - index - GetTypeFormatsContainer()->GetCount()); + + return GetRegexTypeFormatsContainer()->GetTypeNameSpecifierAtIndex( + index - GetTypeFormatsContainer()->GetCount()); } lldb::TypeNameSpecifierImplSP TypeCategoryImpl::GetTypeNameSpecifierForFilterAtIndex(size_t index) { if (index < GetTypeFiltersContainer()->GetCount()) return GetTypeFiltersContainer()->GetTypeNameSpecifierAtIndex(index); - else - return GetRegexTypeFiltersContainer()->GetTypeNameSpecifierAtIndex( - index - GetTypeFiltersContainer()->GetCount()); + + return GetRegexTypeFiltersContainer()->GetTypeNameSpecifierAtIndex( + index - GetTypeFiltersContainer()->GetCount()); } #ifndef LLDB_DISABLE_PYTHON @@ -563,18 +562,18 @@ TypeCategoryImpl::GetSyntheticAtIndex(size_t index) { if (index < GetTypeSyntheticsContainer()->GetCount()) return GetTypeSyntheticsContainer()->GetAtIndex(index); - else - return GetRegexTypeSyntheticsContainer()->GetAtIndex( - index - GetTypeSyntheticsContainer()->GetCount()); + + return GetRegexTypeSyntheticsContainer()->GetAtIndex( + index - GetTypeSyntheticsContainer()->GetCount()); } lldb::TypeNameSpecifierImplSP TypeCategoryImpl::GetTypeNameSpecifierForSyntheticAtIndex(size_t index) { if (index < GetTypeSyntheticsContainer()->GetCount()) return GetTypeSyntheticsContainer()->GetTypeNameSpecifierAtIndex(index); - else - return GetRegexTypeSyntheticsContainer()->GetTypeNameSpecifierAtIndex( - index - GetTypeSyntheticsContainer()->GetCount()); + + return GetRegexTypeSyntheticsContainer()->GetTypeNameSpecifierAtIndex( + index - GetTypeSyntheticsContainer()->GetCount()); } #endif @@ -582,18 +581,18 @@ TypeCategoryImpl::GetValidatorAtIndex(size_t index) { if (index < GetTypeValidatorsContainer()->GetCount()) return GetTypeValidatorsContainer()->GetAtIndex(index); - else - return GetRegexTypeValidatorsContainer()->GetAtIndex( - index - GetTypeValidatorsContainer()->GetCount()); + + return GetRegexTypeValidatorsContainer()->GetAtIndex( + index - GetTypeValidatorsContainer()->GetCount()); } lldb::TypeNameSpecifierImplSP TypeCategoryImpl::GetTypeNameSpecifierForValidatorAtIndex(size_t index) { if (index < GetTypeValidatorsContainer()->GetCount()) return GetTypeValidatorsContainer()->GetTypeNameSpecifierAtIndex(index); - else - return GetRegexTypeValidatorsContainer()->GetTypeNameSpecifierAtIndex( - index - GetTypeValidatorsContainer()->GetCount()); + + return GetRegexTypeValidatorsContainer()->GetTypeNameSpecifierAtIndex( + index - GetTypeValidatorsContainer()->GetCount()); } void TypeCategoryImpl::Enable(bool value, uint32_t position) { Index: source/DataFormatters/TypeFormat.cpp =================================================================== --- source/DataFormatters/TypeFormat.cpp +++ source/DataFormatters/TypeFormat.cpp @@ -117,8 +117,8 @@ } } return !dest.empty(); - } else - return false; + } + return false; } std::string TypeFormatImpl_Format::GetDescription() { Index: source/DataFormatters/TypeSummary.cpp =================================================================== --- source/DataFormatters/TypeSummary.cpp +++ source/DataFormatters/TypeSummary.cpp @@ -96,17 +96,15 @@ printer.PrintChildrenOneLiner(HideNames(valobj)); retval = s.GetString(); return true; - } else { - if (FormatEntity::Format(m_format, s, &sc, &exe_ctx, - &sc.line_entry.range.GetBaseAddress(), valobj, - false, false)) { - retval.assign(s.GetString()); - return true; - } else { - retval.assign("error: summary string parsing error"); - return false; - } } + if (FormatEntity::Format(m_format, s, &sc, &exe_ctx, + &sc.line_entry.range.GetBaseAddress(), valobj, false, + false)) { + retval.assign(s.GetString()); + return true; + } + retval.assign("error: summary string parsing error"); + return false; } std::string StringSummaryFormat::GetDescription() { Index: source/DataFormatters/ValueObjectPrinter.cpp =================================================================== --- source/DataFormatters/ValueObjectPrinter.cpp +++ source/DataFormatters/ValueObjectPrinter.cpp @@ -458,7 +458,8 @@ else m_stream->Printf("%s\n", object_desc); return true; - } else if (value_printed == false && summary_printed == false) + } + if (value_printed == false && summary_printed == false) return true; else return false; @@ -653,10 +654,9 @@ m_options.m_pointer_as_array.m_base_element, m_options.m_pointer_as_array.m_stride, idx), true); - } else { - // otherwise, do the usual thing - return synth_valobj->GetChildAtIndex(idx, true); } + // otherwise, do the usual thing + return synth_valobj->GetChildAtIndex(idx, true); } void ValueObjectPrinter::PrintChildren( @@ -776,9 +776,9 @@ // we're done here - get out fast return; - } else - m_printed_instance_pointers->emplace( - instance_ptr_value); // remember this guy for future reference + } + m_printed_instance_pointers->emplace( + instance_ptr_value); // remember this guy for future reference } if (print_children) { Index: source/Expression/DWARFExpression.cpp =================================================================== --- source/Expression/DWARFExpression.cpp +++ source/Expression/DWARFExpression.cpp @@ -368,7 +368,8 @@ if (reg_info.name) { s->PutCString(reg_info.name); break; - } else if (reg_info.alt_name) { + } + if (reg_info.alt_name) { s->PutCString(reg_info.alt_name); break; } @@ -418,7 +419,8 @@ if (reg_info.name) { s->Printf("[%s%+" PRIi64 "]", reg_info.name, reg_offset); break; - } else if (reg_info.alt_name) { + } + if (reg_info.alt_name) { s->Printf("[%s%+" PRIi64 "]", reg_info.alt_name, reg_offset); break; } @@ -436,7 +438,8 @@ if (reg_info.name) { s->PutCString(reg_info.name); break; - } else if (reg_info.alt_name) { + } + if (reg_info.alt_name) { s->PutCString(reg_info.alt_name); break; } @@ -458,7 +461,8 @@ if (reg_info.name) { s->Printf("[%s%+" PRIi64 "]", reg_info.name, reg_offset); break; - } else if (reg_info.alt_name) { + } + if (reg_info.alt_name) { s->Printf("[%s%+" PRIi64 "]", reg_info.alt_name, reg_offset); break; } @@ -677,14 +681,14 @@ if (error_ptr) error_ptr->Clear(); return true; - } else { - // If we get this error, then we need to implement a value buffer in - // the dwarf expression evaluation function... - if (error_ptr) - error_ptr->SetErrorStringWithFormat( - "register %s can't be converted to a scalar value", - reg_info->name); } + // If we get this error, then we need to implement a value buffer in + // the dwarf expression evaluation function... + if (error_ptr) + error_ptr->SetErrorStringWithFormat( + "register %s can't be converted to a scalar value", + reg_info->name); + } else { if (error_ptr) error_ptr->SetErrorStringWithFormat("register %s is not available", @@ -956,8 +960,8 @@ const lldb::addr_t op_file_addr = m_data.GetAddress(&offset); if (curr_op_addr_idx == op_addr_idx) return op_file_addr; - else - ++curr_op_addr_idx; + + ++curr_op_addr_idx; } else if (op == DW_OP_GNU_addr_index) { uint64_t index = m_data.GetULEB128(&offset); if (curr_op_addr_idx == op_addr_idx) { @@ -967,8 +971,8 @@ } return ReadAddressFromDebugAddrSection(m_dwarf_cu, index); - } else - ++curr_op_addr_idx; + } + ++curr_op_addr_idx; } else { const offset_t op_arg_size = GetOpcodeDataSize(m_data, offset, op); if (op_arg_size == LLDB_INVALID_OFFSET) { @@ -1012,12 +1016,11 @@ // the heap data so "m_data" will now correctly manage the heap data. m_data.SetData(DataBufferSP(head_data_ap.release())); return true; - } else { - const offset_t op_arg_size = GetOpcodeDataSize(m_data, offset, op); - if (op_arg_size == LLDB_INVALID_OFFSET) - break; - offset += op_arg_size; } + const offset_t op_arg_size = GetOpcodeDataSize(m_data, offset, op); + if (op_arg_size == LLDB_INVALID_OFFSET) + break; + offset += op_arg_size; } return false; } @@ -1037,8 +1040,8 @@ const offset_t op_arg_size = GetOpcodeDataSize(m_data, offset, op); if (op_arg_size == LLDB_INVALID_OFFSET) return false; - else - offset += op_arg_size; + + offset += op_arg_size; } return false; } @@ -1128,8 +1131,8 @@ const offset_t op_arg_size = GetOpcodeDataSize(m_data, offset, op); if (op_arg_size == LLDB_INVALID_OFFSET) return false; - else - offset += op_arg_size; + + offset += op_arg_size; } } @@ -1886,16 +1889,15 @@ if (error_ptr) error_ptr->SetErrorString("Divide by zero."); return false; - } else { - stack.pop_back(); - stack.back() = - stack.back().ResolveValue(exe_ctx) / tmp.ResolveValue(exe_ctx); - if (!stack.back().ResolveValue(exe_ctx).IsValid()) { - if (error_ptr) - error_ptr->SetErrorString("Divide failed."); - return false; - } } + stack.pop_back(); + stack.back() = + stack.back().ResolveValue(exe_ctx) / tmp.ResolveValue(exe_ctx); + if (!stack.back().ResolveValue(exe_ctx).IsValid()) { + if (error_ptr) + error_ptr->SetErrorString("Divide failed."); + return false; + } } break; @@ -3410,8 +3412,6 @@ MatchBinaryOp(MatchOpType(Instruction::Operand::Type::Sum), MatchRegOp(*reg), MatchImmOp(offset)))(operand); - } else { - return MatchRegOp(*reg)(operand); } + return MatchRegOp(*reg)(operand); } - Index: source/Expression/ExpressionSourceCode.cpp =================================================================== --- source/Expression/ExpressionSourceCode.cpp +++ source/Expression/ExpressionSourceCode.cpp @@ -107,8 +107,8 @@ if (line >= m_current_file_line) return false; - else - return true; + + return true; default: return false; } Index: source/Expression/ExpressionVariable.cpp =================================================================== --- source/Expression/ExpressionVariable.cpp +++ source/Expression/ExpressionVariable.cpp @@ -36,8 +36,8 @@ if (si != m_symbol_map.end()) return si->second; - else - return LLDB_INVALID_ADDRESS; + + return LLDB_INVALID_ADDRESS; } void PersistentExpressionState::RegisterExecutionUnit( Index: source/Expression/IRDynamicChecks.cpp =================================================================== --- source/Expression/IRDynamicChecks.cpp +++ source/Expression/IRDynamicChecks.cpp @@ -84,8 +84,8 @@ if (m_valid_pointer_check && m_valid_pointer_check->ContainsAddress(addr)) { message.Printf("Attempted to dereference an invalid pointer."); return true; - } else if (m_objc_object_check && - m_objc_object_check->ContainsAddress(addr)) { + } + if (m_objc_object_check && m_objc_object_check->ContainsAddress(addr)) { message.Printf("Attempted to dereference an invalid ObjC Object or send it " "an unrecognized selector"); return true; Index: source/Expression/IRExecutionUnit.cpp =================================================================== --- source/Expression/IRExecutionUnit.cpp +++ source/Expression/IRExecutionUnit.cpp @@ -701,7 +701,7 @@ if (param_and_qual_matches.size()) return param_and_qual_matches[0]; // It is assumed that there will be only // one! - else if (param_matches.size()) + if (param_matches.size()) return param_matches[0]; // Return one of them as a best match else return ConstString(); @@ -835,7 +835,8 @@ if (load_address != LLDB_INVALID_ADDRESS) { if (is_external) { return true; - } else if (best_internal_load_address == LLDB_INVALID_ADDRESS) { + } + if (best_internal_load_address == LLDB_INVALID_ADDRESS) { best_internal_load_address = load_address; load_address = LLDB_INVALID_ADDRESS; } @@ -857,9 +858,8 @@ if (get_external_load_address(load_address, sc_list, sc)) { return load_address; - } else { - sc_list.Clear(); } + sc_list.Clear(); if (sc_list.GetSize() == 0 && sc.target_sp) { sc.target_sp->GetImages().FindFunctions(spec.name, spec.mask, @@ -871,9 +871,8 @@ if (get_external_load_address(load_address, sc_list, sc)) { return load_address; - } else { - sc_list.Clear(); } + sc_list.Clear(); if (sc_list.GetSize() == 0 && sc.target_sp) { sc.target_sp->GetImages().FindSymbolsWithNameAndType( @@ -1014,12 +1013,11 @@ m_parent.ReportSymbolLookupError(name_cs); return 0; - } else { - if (log) - log->Printf("IRExecutionUnit::getSymbolAddress(Name=\"%s\") = %" PRIx64, - Name.c_str(), ret); - return ret; } + if (log) + log->Printf("IRExecutionUnit::getSymbolAddress(Name=\"%s\") = %" PRIx64, + Name.c_str(), ret); + return ret; } void *IRExecutionUnit::MemoryManager::getPointerToNamedFunction( Index: source/Expression/IRInterpreter.cpp =================================================================== --- source/Expression/IRInterpreter.cpp +++ source/Expression/IRInterpreter.cpp @@ -174,25 +174,24 @@ return AssignToMatchType(scalar, value_apint.getLimitedValue(), value->getType()); - } else { - lldb::addr_t process_address = ResolveValue(value, module); - size_t value_size = m_target_data.getTypeStoreSize(value->getType()); + } + lldb::addr_t process_address = ResolveValue(value, module); + size_t value_size = m_target_data.getTypeStoreSize(value->getType()); - lldb_private::DataExtractor value_extractor; - lldb_private::Status extract_error; + lldb_private::DataExtractor value_extractor; + lldb_private::Status extract_error; - m_execution_unit.GetMemoryData(value_extractor, process_address, - value_size, extract_error); + m_execution_unit.GetMemoryData(value_extractor, process_address, value_size, + extract_error); - if (!extract_error.Success()) - return false; + if (!extract_error.Success()) + return false; - lldb::offset_t offset = 0; - if (value_size <= 8) { - uint64_t u64value = value_extractor.GetMaxU64(&offset, value_size); - return AssignToMatchType(scalar, u64value, value->getType()); + lldb::offset_t offset = 0; + if (value_size <= 8) { + uint64_t u64value = value_extractor.GetMaxU64(&offset, value_size); + return AssignToMatchType(scalar, u64value, value->getType()); } - } return false; } Index: source/Expression/IRMemoryMap.cpp =================================================================== --- source/Expression/IRMemoryMap.cpp +++ source/Expression/IRMemoryMap.cpp @@ -74,8 +74,8 @@ if (!alloc_error.Success()) return LLDB_INVALID_ADDRESS; - else - return ret; + + return ret; } // At this point we know that we need to hunt. @@ -114,9 +114,9 @@ if (region_info.GetRange().GetRangeEnd() - 1 >= end_of_memory) { ret = LLDB_INVALID_ADDRESS; break; - } else { - ret = region_info.GetRange().GetRangeEnd(); } + ret = region_info.GetRange().GetRangeEnd(); + } else if (ret + size < region_info.GetRange().GetRangeEnd()) { return ret; } else { @@ -598,11 +598,11 @@ scalar.GetAsMemoryData(buf, size, GetByteOrder(), error); if (mem_size > 0) { return WriteMemory(process_address, buf, mem_size, error); - } else { - error.SetErrorToGenericError(); - error.SetErrorString( - "Couldn't write scalar: failed to get scalar as memory data"); } + error.SetErrorToGenericError(); + error.SetErrorString( + "Couldn't write scalar: failed to get scalar as memory data"); + } else { error.SetErrorToGenericError(); error.SetErrorString("Couldn't write scalar: its size was zero"); Index: source/Expression/LLVMUserExpression.cpp =================================================================== --- source/Expression/LLVMUserExpression.cpp +++ source/Expression/LLVMUserExpression.cpp @@ -218,7 +218,8 @@ } return execution_result; - } else if (execution_result == lldb::eExpressionStoppedForDebug) { + } + if (execution_result == lldb::eExpressionStoppedForDebug) { diagnostic_manager.PutString( eDiagnosticSeverityRemark, "Execution was halted at the first instruction of the expression " @@ -238,9 +239,9 @@ if (FinalizeJITExecution(diagnostic_manager, exe_ctx, result, function_stack_bottom, function_stack_top)) { return lldb::eExpressionCompleted; - } else { - return lldb::eExpressionResultUnavailable; } + return lldb::eExpressionResultUnavailable; + } else { diagnostic_manager.PutString( eDiagnosticSeverityError, Index: source/Expression/UserExpression.cpp =================================================================== --- source/Expression/UserExpression.cpp +++ source/Expression/UserExpression.cpp @@ -82,10 +82,10 @@ if (m_address.IsValid()) { if (!frame_sp) return false; - else - return (0 == Address::CompareLoadAddress(m_address, - frame_sp->GetFrameCodeAddress(), - target_sp.get())); + + return (0 == Address::CompareLoadAddress(m_address, + frame_sp->GetFrameCodeAddress(), + target_sp.get())); } return true; Index: source/Host/common/File.cpp =================================================================== --- source/Host/common/File.cpp +++ source/Host/common/File.cpp @@ -44,21 +44,21 @@ if (options & File::eOpenOptionRead) { if (options & File::eOpenOptionCanCreateNewOnly) return "a+x"; - else - return "a+"; + + return "a+"; } else if (options & File::eOpenOptionWrite) { if (options & File::eOpenOptionCanCreateNewOnly) return "ax"; - else - return "a"; + + return "a"; } } else if (options & File::eOpenOptionRead && options & File::eOpenOptionWrite) { if (options & File::eOpenOptionCanCreate) { if (options & File::eOpenOptionCanCreateNewOnly) return "w+x"; - else - return "w+"; + + return "w+"; } else return "r+"; } else if (options & File::eOpenOptionRead) { Index: source/Host/common/Host.cpp =================================================================== --- source/Host/common/Host.cpp +++ source/Host/common/Host.cpp @@ -632,7 +632,7 @@ WaitStatus WaitStatus::Decode(int wstatus) { if (WIFEXITED(wstatus)) return {Exit, uint8_t(WEXITSTATUS(wstatus))}; - else if (WIFSIGNALED(wstatus)) + if (WIFSIGNALED(wstatus)) return {Signal, uint8_t(WTERMSIG(wstatus))}; else if (WIFSTOPPED(wstatus)) return {Stop, uint8_t(WSTOPSIG(wstatus))}; Index: source/Host/common/NativeProcessProtocol.cpp =================================================================== --- source/Host/common/NativeProcessProtocol.cpp +++ source/Host/common/NativeProcessProtocol.cpp @@ -630,8 +630,8 @@ bool hardware) { if (hardware) return RemoveHardwareBreakpoint(addr); - else - return RemoveSoftwareBreakpoint(addr); + + return RemoveSoftwareBreakpoint(addr); } Status NativeProcessProtocol::ReadMemoryWithoutTrap(lldb::addr_t addr, Index: source/Host/common/NativeRegisterContext.cpp =================================================================== --- source/Host/common/NativeRegisterContext.cpp +++ source/Host/common/NativeRegisterContext.cpp @@ -200,11 +200,11 @@ "%" PRIu64, __FUNCTION__, value.GetAsUInt64()); return value.GetAsUInt64(); - } else { - if (log) - log->Printf("NativeRegisterContext::%s ReadRegister() failed, error %s", - __FUNCTION__, error.AsCString()); } + if (log) + log->Printf("NativeRegisterContext::%s ReadRegister() failed, error %s", + __FUNCTION__, error.AsCString()); + } else { if (log) log->Printf("NativeRegisterContext::%s ReadRegister() null reg_info", Index: source/Host/common/Symbols.cpp =================================================================== --- source/Host/common/Symbols.cpp +++ source/Host/common/Symbols.cpp @@ -158,42 +158,42 @@ log->Printf("dSYM with matching UUID & arch found at %s", dsym_fspec.GetPath().c_str()); } return true; - } else { - FileSpec parent_dirs = exec_fspec; - - // Remove the binary name from the FileSpec - parent_dirs.RemoveLastPathComponent(); - - // Add a ".dSYM" name to each directory component of the path, - // stripping off components. e.g. we may have a binary like - // /S/L/F/Foundation.framework/Versions/A/Foundation and - // /S/L/F/Foundation.framework.dSYM - // - // so we'll need to start with - // /S/L/F/Foundation.framework/Versions/A, add the .dSYM part to the - // "A", and if that doesn't exist, strip off the "A" and try it again - // with "Versions", etc., until we find a dSYM bundle or we've - // stripped off enough path components that there's no need to - // continue. - - for (int i = 0; i < 4; i++) { - // Does this part of the path have a "." character - could it be a - // bundle's top level directory? - const char *fn = parent_dirs.GetFilename().AsCString(); - if (fn == nullptr) - break; - if (::strchr(fn, '.') != nullptr) { - if (::LookForDsymNextToExecutablePath (module_spec, parent_dirs, dsym_fspec)) { - if (log) { - log->Printf("dSYM with matching UUID & arch found at %s", - dsym_fspec.GetPath().c_str()); - } - return true; + } + FileSpec parent_dirs = exec_fspec; + + // Remove the binary name from the FileSpec + parent_dirs.RemoveLastPathComponent(); + + // Add a ".dSYM" name to each directory component of the path, + // stripping off components. e.g. we may have a binary like + // /S/L/F/Foundation.framework/Versions/A/Foundation and + // /S/L/F/Foundation.framework.dSYM + // + // so we'll need to start with + // /S/L/F/Foundation.framework/Versions/A, add the .dSYM part to the + // "A", and if that doesn't exist, strip off the "A" and try it again + // with "Versions", etc., until we find a dSYM bundle or we've + // stripped off enough path components that there's no need to + // continue. + + for (int i = 0; i < 4; i++) { + // Does this part of the path have a "." character - could it be a + // bundle's top level directory? + const char *fn = parent_dirs.GetFilename().AsCString(); + if (fn == nullptr) + break; + if (::strchr(fn, '.') != nullptr) { + if (::LookForDsymNextToExecutablePath(module_spec, parent_dirs, + dsym_fspec)) { + if (log) { + log->Printf("dSYM with matching UUID & arch found at %s", + dsym_fspec.GetPath().c_str()); } + return true; } - parent_dirs.RemoveLastPathComponent(); } - } + parent_dirs.RemoveLastPathComponent(); + } } dsym_fspec.Clear(); return false; Index: source/Host/common/UDPSocket.cpp =================================================================== --- source/Host/common/UDPSocket.cpp +++ source/Host/common/UDPSocket.cpp @@ -101,8 +101,8 @@ final_socket.reset(new UDPSocket(send_fd)); final_socket->m_sockaddr = service_info_ptr; break; - } else - continue; + } + continue; } ::freeaddrinfo(service_info_list); Index: source/Host/common/XML.cpp =================================================================== --- source/Host/common/XML.cpp +++ source/Host/common/XML.cpp @@ -103,8 +103,8 @@ #if defined(LIBXML2_DEFINED) if (IsValid()) return XMLNode(m_node->parent); - else - return XMLNode(); + + return XMLNode(); #else return XMLNode(); #endif @@ -114,8 +114,8 @@ #if defined(LIBXML2_DEFINED) if (IsValid()) return XMLNode(m_node->next); - else - return XMLNode(); + + return XMLNode(); #else return XMLNode(); #endif @@ -126,8 +126,8 @@ if (IsValid()) return XMLNode(m_node->children); - else - return XMLNode(); + + return XMLNode(); #else return XMLNode(); #endif @@ -147,8 +147,8 @@ #endif if (attr_value) return llvm::StringRef(attr_value); - else - return llvm::StringRef(); + + return llvm::StringRef(); } bool XMLNode::GetAttributeValueAsUnsigned(const char *name, uint64_t &value, @@ -377,13 +377,12 @@ if (IsValid()) { if (path.empty()) return *this; - else { - XMLNode node = FindFirstChildElementWithName(path[0].c_str()); - const size_t n = path.size(); - for (size_t i = 1; node && i < n; ++i) - node = node.FindFirstChildElementWithName(path[i].c_str()); - return node; - } + + XMLNode node = FindFirstChildElementWithName(path[0].c_str()); + const size_t n = path.size(); + for (size_t i = 1; node && i < n; ++i) + node = node.FindFirstChildElementWithName(path[i].c_str()); + return node; } #endif @@ -463,7 +462,8 @@ // The text value _is_ the element name itself... value = element_name.str(); return true; - } else if (element_name == "dict" || element_name == "array") + } + if (element_name == "dict" || element_name == "array") return false; // dictionaries and arrays have no text value, so we fail else return node.GetElementText(value); @@ -486,7 +486,8 @@ return true; // Keep iterating through all child elements of the array }); return array_sp; - } else if (element_name == "dict") { + } + if (element_name == "dict") { XMLNode key_node; std::shared_ptr dict_sp( new StructuredData::Dictionary()); Index: source/Host/macosx/Symbols.cpp =================================================================== --- source/Host/macosx/Symbols.cpp +++ source/Host/macosx/Symbols.cpp @@ -622,16 +622,15 @@ if (num_values == 1) { return GetModuleSpecInfoFromUUIDDictionary(values[0], module_spec); - } else { - for (CFIndex i = 0; i < num_values; ++i) { - ModuleSpec curr_module_spec; - if (GetModuleSpecInfoFromUUIDDictionary(values[i], - curr_module_spec)) { - if (module_spec.GetArchitecture().IsCompatibleMatch( - curr_module_spec.GetArchitecture())) { - module_spec = curr_module_spec; - return true; - } + } + for (CFIndex i = 0; i < num_values; ++i) { + ModuleSpec curr_module_spec; + if (GetModuleSpecInfoFromUUIDDictionary(values[i], + curr_module_spec)) { + if (module_spec.GetArchitecture().IsCompatibleMatch( + curr_module_spec.GetArchitecture())) { + module_spec = curr_module_spec; + return true; } } } Index: source/Host/macosx/objcxx/Host.mm =================================================================== --- source/Host/macosx/objcxx/Host.mm +++ source/Host/macosx/objcxx/Host.mm @@ -915,7 +915,8 @@ // If the service is state-full, this is the time to initialize the new // service. return; - } else if (event == XPC_ERROR_CONNECTION_INVALID) { + } + if (event == XPC_ERROR_CONNECTION_INVALID) { // The service is invalid. Either the service name supplied to // xpc_connection_create() is incorrect // or we (this process) have canceled the service; we can do any cleanup @@ -1358,11 +1359,10 @@ error.SetErrorStringWithFormat( "cwd does not exist; cannot launch with shell argument expansion"); return error; - } else { - FileSpec working_dir(wd); - free(wd); - launch_info.SetWorkingDirectory(working_dir); } + FileSpec working_dir(wd); + free(wd); + launch_info.SetWorkingDirectory(working_dir); } RunShellCommand(expand_command, cwd, &status, nullptr, &output, std::chrono::seconds(10)); Index: source/Host/posix/ConnectionFileDescriptorPosix.cpp =================================================================== --- source/Host/posix/ConnectionFileDescriptorPosix.cpp +++ source/Host/posix/ConnectionFileDescriptorPosix.cpp @@ -164,7 +164,8 @@ if ((addr = GetURLAddress(path, LISTEN_SCHEME))) { // listen://HOST:PORT return SocketListenAndAccept(*addr, error_ptr); - } else if ((addr = GetURLAddress(path, ACCEPT_SCHEME))) { + } + if ((addr = GetURLAddress(path, ACCEPT_SCHEME))) { // unix://SOCKNAME return NamedSocketAccept(*addr, error_ptr); } else if ((addr = GetURLAddress(path, UNIX_ACCEPT_SCHEME))) { @@ -202,32 +203,31 @@ m_read_sp.reset(); m_write_sp.reset(); return eConnectionStatusError; - } else { - // Don't take ownership of a file descriptor that gets passed to us - // since someone else opened the file descriptor and handed it to us. - // TODO: Since are using a URL to open connection we should - // eventually parse options using the web standard where we have - // "fd://123?opt1=value;opt2=value" and we can have an option be - // "owns=1" or "owns=0" or something like this to allow us to specify - // this. For now, we assume we must assume we don't own it. - - std::unique_ptr tcp_socket; - tcp_socket.reset(new TCPSocket(fd, false, false)); - // Try and get a socket option from this file descriptor to see if - // this is a socket and set m_is_socket accordingly. - int resuse; - bool is_socket = - !!tcp_socket->GetOption(SOL_SOCKET, SO_REUSEADDR, resuse); - if (is_socket) { - m_read_sp = std::move(tcp_socket); - m_write_sp = m_read_sp; + } + // Don't take ownership of a file descriptor that gets passed to us + // since someone else opened the file descriptor and handed it to us. + // TODO: Since are using a URL to open connection we should + // eventually parse options using the web standard where we have + // "fd://123?opt1=value;opt2=value" and we can have an option be + // "owns=1" or "owns=0" or something like this to allow us to specify + // this. For now, we assume we must assume we don't own it. + + std::unique_ptr tcp_socket; + tcp_socket.reset(new TCPSocket(fd, false, false)); + // Try and get a socket option from this file descriptor to see if + // this is a socket and set m_is_socket accordingly. + int resuse; + bool is_socket = + !!tcp_socket->GetOption(SOL_SOCKET, SO_REUSEADDR, resuse); + if (is_socket) { + m_read_sp = std::move(tcp_socket); + m_write_sp = m_read_sp; } else { m_read_sp.reset(new File(fd, false)); m_write_sp.reset(new File(fd, false)); } m_uri = *addr; return eConnectionStatusSuccess; - } } if (error_ptr) Index: source/Interpreter/CommandInterpreter.cpp =================================================================== --- source/Interpreter/CommandInterpreter.cpp +++ source/Interpreter/CommandInterpreter.cpp @@ -941,7 +941,7 @@ if (num_user_matches + num_cmd_matches + num_alias_matches == 1) { if (num_cmd_matches) return real_match_sp; - else if (num_alias_matches) + if (num_alias_matches) return alias_match_sp; else return user_match_sp; @@ -1017,36 +1017,37 @@ if (cmd_words.GetArgumentCount() == 1) return GetCommandSP(cmd_str, include_aliases, true, nullptr); - else { - // We have a multi-word command (seemingly), so we need to do more work. - // First, get the cmd_obj_sp for the first word in the command. - CommandObjectSP cmd_obj_sp = GetCommandSP(llvm::StringRef(cmd_words.GetArgumentAtIndex(0)), - include_aliases, true, nullptr); - if (cmd_obj_sp.get() != nullptr) { - // Loop through the rest of the words in the command (everything passed - // in was supposed to be part of a command name), and find the - // appropriate sub-command SP for each command word.... - size_t end = cmd_words.GetArgumentCount(); - for (size_t j = 1; j < end; ++j) { - if (cmd_obj_sp->IsMultiwordObject()) { - cmd_obj_sp = - cmd_obj_sp->GetSubcommandSP(cmd_words.GetArgumentAtIndex(j)); - if (cmd_obj_sp.get() == nullptr) - // The sub-command name was invalid. Fail and return the empty - // 'ret_val'. - return ret_val; - } else - // We have more words in the command name, but we don't have a - // multiword object. Fail and return empty 'ret_val'. + + // We have a multi-word command (seemingly), so we need to do more work. + // First, get the cmd_obj_sp for the first word in the command. + CommandObjectSP cmd_obj_sp = + GetCommandSP(llvm::StringRef(cmd_words.GetArgumentAtIndex(0)), + include_aliases, true, nullptr); + if (cmd_obj_sp.get() != nullptr) { + // Loop through the rest of the words in the command (everything passed + // in was supposed to be part of a command name), and find the + // appropriate sub-command SP for each command word.... + size_t end = cmd_words.GetArgumentCount(); + for (size_t j = 1; j < end; ++j) { + if (cmd_obj_sp->IsMultiwordObject()) { + cmd_obj_sp = + cmd_obj_sp->GetSubcommandSP(cmd_words.GetArgumentAtIndex(j)); + if (cmd_obj_sp.get() == nullptr) + // The sub-command name was invalid. Fail and return the empty + // 'ret_val'. return ret_val; - } - // We successfully looped through all the command words and got valid - // command objects for them. Assign the last object retrieved to - // 'ret_val'. - ret_val = cmd_obj_sp; + } else + // We have more words in the command name, but we don't have a + // multiword object. Fail and return empty 'ret_val'. + return ret_val; } - } - return ret_val; + // We successfully looped through all the command words and got valid + // command objects for them. Assign the last object retrieved to + // 'ret_val'. + ret_val = cmd_obj_sp; + } + + return ret_val; } CommandObject * @@ -1095,27 +1096,25 @@ if (exact_match) { full_name.assign(cmd); return exact_match; - } else { - StringList matches; - size_t num_alias_matches; - num_alias_matches = - AddNamesMatchingPartialString(m_alias_dict, cmd, matches); - if (num_alias_matches == 1) { - // Make sure this isn't shadowing a command in the regular command space: - StringList regular_matches; - const bool include_aliases = false; - const bool exact = false; - CommandObjectSP cmd_obj_sp( - GetCommandSP(cmd, include_aliases, exact, ®ular_matches)); - if (cmd_obj_sp || regular_matches.GetSize() > 0) - return false; - else { - full_name.assign(matches.GetStringAtIndex(0)); - return true; - } - } else - return false; } + StringList matches; + size_t num_alias_matches; + num_alias_matches = AddNamesMatchingPartialString(m_alias_dict, cmd, matches); + if (num_alias_matches == 1) { + // Make sure this isn't shadowing a command in the regular command space: + StringList regular_matches; + const bool include_aliases = false; + const bool exact = false; + CommandObjectSP cmd_obj_sp( + GetCommandSP(cmd, include_aliases, exact, ®ular_matches)); + if (cmd_obj_sp || regular_matches.GetSize() > 0) + return false; + + full_name.assign(matches.GetStringAtIndex(0)); + return true; + + } else + return false; } bool CommandInterpreter::AliasExists(llvm::StringRef cmd) const { @@ -1466,7 +1465,7 @@ const size_t end_backtick = command.find('`', expr_content_start); if (end_backtick == std::string::npos) return error; - else if (end_backtick == expr_content_start) { + if (end_backtick == expr_content_start) { // Empty expression (two backticks in a row) command.erase(start_backtick, 2); } else { @@ -1511,12 +1510,12 @@ command.insert(start_backtick, value_strm.GetString()); pos = start_backtick + value_string_size; continue; - } else { - error.SetErrorStringWithFormat("expression value didn't result " - "in a scalar value for the " - "expression '%s'", - expr_str.c_str()); } + error.SetErrorStringWithFormat("expression value didn't result " + "in a scalar value for the " + "expression '%s'", + expr_str.c_str()); + } else { error.SetErrorStringWithFormat("expression value didn't result " "in a scalar value for the " @@ -1657,17 +1656,17 @@ result.AppendError("empty command"); result.SetStatus(eReturnStatusFailed); return false; - } else { - command_line = m_repeat_command.c_str(); - command_string = command_line; - original_command_string = command_line; - if (m_repeat_command.empty()) { - result.AppendErrorWithFormat("No auto repeat.\n"); - result.SetStatus(eReturnStatusFailed); - return false; - } } - add_to_history = false; + command_line = m_repeat_command.c_str(); + command_string = command_line; + original_command_string = command_line; + if (m_repeat_command.empty()) { + result.AppendErrorWithFormat("No auto repeat.\n"); + result.SetStatus(eReturnStatusFailed); + return false; + } + + add_to_history = false; } else { result.SetStatus(eReturnStatusSuccessFinishNoResult); return true; @@ -1808,11 +1807,10 @@ GetCommandObject(request.GetParsedLine().GetArgumentAtIndex(0)); if (command_object == nullptr) { return 0; - } else { - request.GetParsedLine().Shift(); - request.SetCursorIndex(request.GetCursorIndex() - 1); - num_command_matches = command_object->HandleCompletion(request); } + request.GetParsedLine().Shift(); + request.SetCursorIndex(request.GetCursorIndex() - 1); + num_command_matches = command_object->HandleCompletion(request); } return num_command_matches; @@ -1833,13 +1831,13 @@ if (first_arg) { if (first_arg[0] == m_comment_char) return 0; - else if (first_arg[0] == CommandHistory::g_repeat_char) { + if (first_arg[0] == CommandHistory::g_repeat_char) { if (auto hist_str = m_command_history.FindString(first_arg)) { matches.InsertStringAtIndex(0, *hist_str); descriptions.InsertStringAtIndex(0, "Previous command history event"); return -2; - } else - return 0; + } + return 0; } } @@ -2258,7 +2256,8 @@ result.SetStatus(eReturnStatusFailed); m_debugger.SetAsyncExecution(old_async_execution); return; - } else if (options.GetPrintResults()) { + } + if (options.GetPrintResults()) { result.AppendMessageWithFormat( "Command #%" PRIu64 " '%s' failed with %s", (uint64_t)idx + 1, cmd, error_msg.str().c_str()); Index: source/Interpreter/CommandObject.cpp =================================================================== --- source/Interpreter/CommandObject.cpp +++ source/Interpreter/CommandObject.cpp @@ -268,25 +268,24 @@ // FIXME: Abstract telling the completion to insert the completion // character. return -1; - } else { - // Can we do anything generic with the options? - Options *cur_options = GetOptions(); - CommandReturnObject result; - OptionElementVector opt_element_vector; - - if (cur_options != nullptr) { - opt_element_vector = cur_options->ParseForCompletion( - request.GetParsedLine(), request.GetCursorIndex()); - - bool handled_by_options = cur_options->HandleOptionCompletion( - request, opt_element_vector, GetCommandInterpreter()); - if (handled_by_options) - return request.GetNumberOfMatches(); + } + // Can we do anything generic with the options? + Options *cur_options = GetOptions(); + CommandReturnObject result; + OptionElementVector opt_element_vector; + + if (cur_options != nullptr) { + opt_element_vector = cur_options->ParseForCompletion( + request.GetParsedLine(), request.GetCursorIndex()); + + bool handled_by_options = cur_options->HandleOptionCompletion( + request, opt_element_vector, GetCommandInterpreter()); + if (handled_by_options) + return request.GetNumberOfMatches(); } // If we got here, the last word is not an option or an option argument. return HandleArgumentCompletion(request, opt_element_vector); - } } bool CommandObject::HelpTextContainsWord(llvm::StringRef search_word, @@ -948,8 +947,8 @@ if (process) return process->GetThreadList().GetSelectedThread().get(); - else - return nullptr; + + return nullptr; } bool CommandObjectParsed::Execute(const char *args_string, Index: source/Interpreter/CommandObjectRegexCommand.cpp =================================================================== --- source/Interpreter/CommandObjectRegexCommand.cpp +++ source/Interpreter/CommandObjectRegexCommand.cpp @@ -94,8 +94,8 @@ CommandCompletions::InvokeCommonCompletionCallbacks( GetCommandInterpreter(), m_completion_type_mask, request, nullptr); return request.GetNumberOfMatches(); - } else { - request.SetWordComplete(false); } + request.SetWordComplete(false); + return 0; } Index: source/Interpreter/OptionArgParser.cpp =================================================================== --- source/Interpreter/OptionArgParser.cpp +++ source/Interpreter/OptionArgParser.cpp @@ -24,8 +24,9 @@ if (ref.equals_lower("false") || ref.equals_lower("off") || ref.equals_lower("no") || ref.equals_lower("0")) { return false; - } else if (ref.equals_lower("true") || ref.equals_lower("on") || - ref.equals_lower("yes") || ref.equals_lower("1")) { + } + if (ref.equals_lower("true") || ref.equals_lower("on") || + ref.equals_lower("yes") || ref.equals_lower("1")) { return true; } if (success_ptr) @@ -196,14 +197,13 @@ if (error_ptr) error_ptr->Clear(); return addr; - } else { - if (error_ptr) { - error_set = true; - error_ptr->SetErrorStringWithFormat( - "address expression \"%s\" resulted in a value whose type " - "can't be converted to an address: %s", - s.str().c_str(), valobj_sp->GetTypeName().GetCString()); - } + } + if (error_ptr) { + error_set = true; + error_ptr->SetErrorStringWithFormat( + "address expression \"%s\" resulted in a value whose type " + "can't be converted to an address: %s", + s.str().c_str(), valobj_sp->GetTypeName().GetCString()); } } else { @@ -230,8 +230,8 @@ if (addr != LLDB_INVALID_ADDRESS) { if (add) return addr + offset; - else - return addr - offset; + + return addr - offset; } } } Index: source/Interpreter/OptionGroupFormat.cpp =================================================================== --- source/Interpreter/OptionGroupFormat.cpp +++ source/Interpreter/OptionGroupFormat.cpp @@ -47,8 +47,8 @@ if (m_byte_size.GetDefaultValue() < UINT64_MAX) { if (m_count.GetDefaultValue() < UINT64_MAX) return result; - else - return result.take_front(3); + + return result.take_front(3); } return result.take_front(2); } Index: source/Interpreter/OptionValueArray.cpp =================================================================== --- source/Interpreter/OptionValueArray.cpp +++ source/Interpreter/OptionValueArray.cpp @@ -124,8 +124,8 @@ if (!sub_value.empty()) return m_values[new_idx]->GetSubValue(exe_ctx, sub_value, will_modify, error); - else - return m_values[new_idx]; + + return m_values[new_idx]; } } else { if (array_count == 0) @@ -212,8 +212,8 @@ if (idx >= size) { all_indexes_valid = false; break; - } else - remove_indexes.push_back(idx); + } + remove_indexes.push_back(idx); } if (all_indexes_valid) { Index: source/Interpreter/OptionValuePathMappings.cpp =================================================================== --- source/Interpreter/OptionValuePathMappings.cpp +++ source/Interpreter/OptionValuePathMappings.cpp @@ -21,8 +21,8 @@ static bool VerifyPathExists(const char *path) { if (path && path[0]) return FileSystem::Instance().Exists(path); - else - return false; + + return false; } } Index: source/Interpreter/OptionValueProperties.cpp =================================================================== --- source/Interpreter/OptionValueProperties.cpp +++ source/Interpreter/OptionValueProperties.cpp @@ -169,10 +169,9 @@ // Still more subvalue string to evaluate return value_sp->GetSubValue(exe_ctx, rest, will_modify, error); - } else { - // We have a match! - break; } + // We have a match! + break; } } } @@ -290,11 +289,10 @@ const OptionValueArray *array = value->GetAsArray(); if (array) return array->GetArgs(args); - else { - const OptionValueDictionary *dict = value->GetAsDictionary(); - if (dict) - return dict->GetArgs(args); - } + + const OptionValueDictionary *dict = value->GetAsDictionary(); + if (dict) + return dict->GetArgs(args); } } return false; @@ -309,11 +307,10 @@ OptionValueArray *array = value->GetAsArray(); if (array) return array->SetArgs(args, eVarSetOperationAssign).Success(); - else { - OptionValueDictionary *dict = value->GetAsDictionary(); - if (dict) - return dict->SetArgs(args, eVarSetOperationAssign).Success(); - } + + OptionValueDictionary *dict = value->GetAsDictionary(); + if (dict) + return dict->SetArgs(args, eVarSetOperationAssign).Success(); } } return false; Index: source/Interpreter/Options.cpp =================================================================== --- source/Interpreter/Options.cpp +++ source/Interpreter/Options.cpp @@ -682,7 +682,8 @@ } return true; - } else if (opt_defs_index == OptionArgElement::eBareDoubleDash) { + } + if (opt_defs_index == OptionArgElement::eBareDoubleDash) { std::string full_name("--"); for (auto &def : opt_defs) { if (!def.short_option) @@ -705,10 +706,10 @@ full_name.append(opt_defs[opt_defs_index].long_option); request.AddCompletion(full_name.c_str()); return true; - } else { - request.AddCompletion(request.GetCursorArgument()); - return true; } + request.AddCompletion(request.GetCursorArgument()); + return true; + } else { // FIXME - not handling wrong options yet: // Check to see if they are writing a long option & complete it. @@ -744,10 +745,9 @@ interpreter); request.SetWordComplete(subrequest.GetWordComplete()); return true; - } else { - // No completion callback means no completions... - return true; } + // No completion callback means no completions... + return true; } else { // Not the last element, keep going. @@ -1199,8 +1199,8 @@ OptionArgElement(OptionArgElement::eBareDoubleDash, dash_dash_pos, OptionArgElement::eBareDoubleDash)); continue; - } else - break; + } + break; } else break; } else if (val == '?') { Index: source/Plugins/ABI/MacOSX-arm/ABIMacOSX_arm.cpp =================================================================== --- source/Plugins/ABI/MacOSX-arm/ABIMacOSX_arm.cpp +++ source/Plugins/ABI/MacOSX-arm/ABIMacOSX_arm.cpp @@ -1517,13 +1517,13 @@ } } return false; - } else { - if (sp == 0) { - // Read the stack pointer if it already hasn't been read - sp = reg_ctx->GetSP(0); - if (sp == 0) - return false; - } + } + if (sp == 0) { + // Read the stack pointer if it already hasn't been read + sp = reg_ctx->GetSP(0); + if (sp == 0) + return false; + } // Arguments 5 on up are on the stack const uint32_t arg_byte_size = (bit_width + (8 - 1)) / 8; @@ -1533,7 +1533,6 @@ return false; sp += arg_byte_size; - } } } } Index: source/Plugins/ABI/MacOSX-arm64/ABIMacOSX_arm64.cpp =================================================================== --- source/Plugins/ABI/MacOSX-arm64/ABIMacOSX_arm64.cpp +++ source/Plugins/ABI/MacOSX-arm64/ABIMacOSX_arm64.cpp @@ -1824,13 +1824,13 @@ } } return false; - } else { - if (sp == 0) { - // Read the stack pointer if we already haven't read it - sp = reg_ctx->GetSP(0); - if (sp == 0) - return false; - } + } + if (sp == 0) { + // Read the stack pointer if we already haven't read it + sp = reg_ctx->GetSP(0); + if (sp == 0) + return false; + } // Arguments 5 on up are on the stack const uint32_t arg_byte_size = (bit_width + (8 - 1)) / 8; @@ -1846,7 +1846,6 @@ sp += 1; sp <<= 3; } - } } } } Index: source/Plugins/ABI/SysV-arm/ABISysV_arm.cpp =================================================================== --- source/Plugins/ABI/SysV-arm/ABISysV_arm.cpp +++ source/Plugins/ABI/SysV-arm/ABISysV_arm.cpp @@ -1501,13 +1501,13 @@ } } return false; - } else { - if (sp == 0) { - // Read the stack pointer if it already hasn't been read - sp = reg_ctx->GetSP(0); - if (sp == 0) - return false; - } + } + if (sp == 0) { + // Read the stack pointer if it already hasn't been read + sp = reg_ctx->GetSP(0); + if (sp == 0) + return false; + } // Arguments 5 on up are on the stack const uint32_t arg_byte_size = (bit_width + (8 - 1)) / 8; @@ -1517,7 +1517,6 @@ return false; sp += arg_byte_size; - } } } } @@ -1749,8 +1748,8 @@ if (index != 0 && vfp_byte_size != base_type.GetByteSize(nullptr)) break; - else - vfp_byte_size = base_type.GetByteSize(nullptr); + + vfp_byte_size = base_type.GetByteSize(nullptr); } else break; } else @@ -1827,9 +1826,8 @@ return ValueObjectConstResult::Create(&thread, compiler_type, ConstString(""), data); - } else { // Some error occurred while getting values from registers - return return_valobj_sp; - } + } // Some error occurred while getting values from registers + return return_valobj_sp; } // If we get here, we have a valid Value, so make our ValueObject out of it: Index: source/Plugins/ABI/SysV-arm64/ABISysV_arm64.cpp =================================================================== --- source/Plugins/ABI/SysV-arm64/ABISysV_arm64.cpp +++ source/Plugins/ABI/SysV-arm64/ABISysV_arm64.cpp @@ -1795,13 +1795,13 @@ } } return false; - } else { - // TODO: Verify for stack layout for SysV - if (sp == 0) { - // Read the stack pointer if we already haven't read it - sp = reg_ctx->GetSP(0); - if (sp == 0) - return false; + } + // TODO: Verify for stack layout for SysV + if (sp == 0) { + // Read the stack pointer if we already haven't read it + sp = reg_ctx->GetSP(0); + if (sp == 0) + return false; } // Arguments 5 on up are on the stack @@ -1818,7 +1818,6 @@ sp += 1; sp <<= 3; } - } } } } Index: source/Plugins/ABI/SysV-ppc/ABISysV_ppc.cpp =================================================================== --- source/Plugins/ABI/SysV-ppc/ABISysV_ppc.cpp +++ source/Plugins/ABI/SysV-ppc/ABISysV_ppc.cpp @@ -738,7 +738,8 @@ if (field_bit_width == 128) { is_memory = true; break; - } else if (field_bit_width == 64) { + } + if (field_bit_width == 64) { copy_from_offset = 0; fp_bytes += field_byte_width; } else if (field_bit_width == 32) { Index: source/Plugins/ABI/SysV-ppc64/ABISysV_ppc64.cpp =================================================================== --- source/Plugins/ABI/SysV-ppc64/ABISysV_ppc64.cpp +++ source/Plugins/ABI/SysV-ppc64/ABISysV_ppc64.cpp @@ -53,10 +53,9 @@ if (GetByteOrder() == lldb::eByteOrderLittle) { count = llvm::array_lengthof(g_register_infos_ppc64le); return g_register_infos_ppc64le; - } else { - count = llvm::array_lengthof(g_register_infos_ppc64); - return g_register_infos_ppc64; } + count = llvm::array_lengthof(g_register_infos_ppc64); + return g_register_infos_ppc64; } size_t ABISysV_ppc64::GetRedZoneSize() const { return 224; } @@ -445,8 +444,8 @@ std::string GetName() const { if (m_type == GPR) return ("r" + llvm::Twine(m_index + 3)).str(); - else - return ("f" + llvm::Twine(m_index + 1)).str(); + + return ("f" + llvm::Twine(m_index + 1)).str(); } // get raw register data @@ -530,9 +529,8 @@ if (type_flags & eTypeIsComplex) { LLDB_LOG(m_log, LOG_PREFIX "Complex numbers are not supported yet"); return ValueObjectSP(); - } else { - value_sp = GetFloatValue(m_type, 0); } + value_sp = GetFloatValue(m_type, 0); } } else if (type_flags & eTypeIsPointer) { value_sp = GetPointerValue(0); Index: source/Plugins/ABI/SysV-x86_64/ABISysV_x86_64.cpp =================================================================== --- source/Plugins/ABI/SysV-x86_64/ABISysV_x86_64.cpp +++ source/Plugins/ABI/SysV-x86_64/ABISysV_x86_64.cpp @@ -1664,7 +1664,8 @@ if (field_bit_width == 128) { is_memory = true; break; - } else if (field_bit_width == 64) { + } + if (field_bit_width == 64) { // These have to be in a single xmm register. if (fp_bytes == 0) copy_from_extractor = &xmm0_data; Index: source/Plugins/Architecture/Mips/ArchitectureMips.cpp =================================================================== --- source/Plugins/Architecture/Mips/ArchitectureMips.cpp +++ source/Plugins/Architecture/Mips/ArchitectureMips.cpp @@ -197,7 +197,7 @@ inst_to_choose = 1; break; } - else if (insn_size == 4) { + if (insn_size == 4) { // This instruction claims its a valid 4-byte instruction. But it // could be a part of it's upper 4-byte instruction. Lets try // scanning upper 2 bytes to verify this. Index: source/Plugins/Disassembler/llvm/DisassemblerLLVMC.cpp =================================================================== --- source/Plugins/Disassembler/llvm/DisassemblerLLVMC.cpp +++ source/Plugins/Disassembler/llvm/DisassemblerLLVMC.cpp @@ -369,14 +369,13 @@ } m_mnemonics = mnemonic_strm.GetString(); return; - } else { - if (m_does_branch == eLazyBoolCalculate) { - const bool can_branch = mc_disasm_ptr->CanBranch(inst); - if (can_branch) - m_does_branch = eLazyBoolYes; - else - m_does_branch = eLazyBoolNo; - } + } + if (m_does_branch == eLazyBoolCalculate) { + const bool can_branch = mc_disasm_ptr->CanBranch(inst); + if (can_branch) + m_does_branch = eLazyBoolYes; + else + m_does_branch = eLazyBoolNo; } static RegularExpression s_regex( @@ -463,9 +462,9 @@ if (*osi >= '0' && *osi <= '9') { if (str.empty()) { return std::make_pair(Operand(), osi); - } else { - str.push_back(*osi); } + str.push_back(*osi); + } else if (*osi >= 'a' && *osi <= 'z') { str.push_back(*osi); } else { @@ -623,12 +622,11 @@ deref.m_type = Operand::Type::Dereference; deref.m_children.push_back(offset); return std::make_pair(deref, osi); - } else { - Operand deref; - deref.m_type = Operand::Type::Dereference; - deref.m_children.push_back(index); - return std::make_pair(deref, osi); } + Operand deref; + deref.m_type = Operand::Type::Dereference; + deref.m_children.push_back(index); + return std::make_pair(deref, osi); } // -0x10(%rbp) @@ -670,12 +668,11 @@ deref.m_type = Operand::Type::Dereference; deref.m_children.push_back(offset); return std::make_pair(deref, osi); - } else { - Operand deref; - deref.m_type = Operand::Type::Dereference; - deref.m_children.push_back(base_and_iterator.first); - return std::make_pair(deref, osi); } + Operand deref; + deref.m_type = Operand::Type::Dereference; + deref.m_children.push_back(base_and_iterator.first); + return std::make_pair(deref, osi); } // [sp, #8]! @@ -1023,8 +1020,8 @@ llvm::nulls(), llvm::nulls()); if (status == llvm::MCDisassembler::Success) return new_inst_size; - else - return 0; + + return 0; } void DisassemblerLLVMC::MCDisasmInstance::PrintMCInst( @@ -1338,8 +1335,8 @@ triple.getArch() == llvm::Triple::x86_64) { if (strcmp(flavor, "intel") == 0 || strcmp(flavor, "att") == 0) return true; - else - return false; + + return false; } else return false; } Index: source/Plugins/DynamicLoader/Hexagon-DYLD/DynamicLoaderHexagonDYLD.cpp =================================================================== --- source/Plugins/DynamicLoader/Hexagon-DYLD/DynamicLoaderHexagonDYLD.cpp +++ source/Plugins/DynamicLoader/Hexagon-DYLD/DynamicLoaderHexagonDYLD.cpp @@ -304,9 +304,9 @@ // check we have successfully set bp return (dyld_break != nullptr); - } else - // rendezvous already set - return true; + } + // rendezvous already set + return true; } // We have just hit our breakpoint at <_rtld_debug_state> @@ -559,8 +559,8 @@ addr, sizeof(uint32_t), 0, error); if (error.Fail()) return -1; - else - return value; + + return value; } lldb::addr_t @@ -611,6 +611,6 @@ if (tls_block == LLDB_INVALID_ADDRESS) return LLDB_INVALID_ADDRESS; - else - return tls_block + tls_file_addr; + + return tls_block + tls_file_addr; } Index: source/Plugins/DynamicLoader/Hexagon-DYLD/HexagonDYLDRendezvous.cpp =================================================================== --- source/Plugins/DynamicLoader/Hexagon-DYLD/HexagonDYLDRendezvous.cpp +++ source/Plugins/DynamicLoader/Hexagon-DYLD/HexagonDYLDRendezvous.cpp @@ -140,7 +140,7 @@ // accordingly. if (m_previous.state == eAdd) return UpdateSOEntriesForAddition(); - else if (m_previous.state == eDelete) + if (m_previous.state == eDelete) return UpdateSOEntriesForDeletion(); return false; @@ -252,10 +252,9 @@ return std::string(); if (c == 0) break; - else { - str.push_back(c); - addr++; - } + + str.push_back(c); + addr++; } return str; Index: source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderDarwin.h =================================================================== --- source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderDarwin.h +++ source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderDarwin.h @@ -147,8 +147,8 @@ if (header.cputype) { if (header.cputype & llvm::MachO::CPU_ARCH_ABI64) return 8; - else - return 4; + + return 4; } return 0; } Index: source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.cpp =================================================================== --- source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.cpp +++ source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.cpp @@ -697,9 +697,8 @@ } } return true; - } else { - return false; } + return false; } //---------------------------------------------------------------------- @@ -727,13 +726,12 @@ // and then we'll // figure it out when we hit the added breakpoint. return false; - } else { - if (!AddModulesUsingImageInfosAddress( - m_dyld_all_image_infos.dylib_info_addr, - m_dyld_all_image_infos.dylib_info_count)) { - DEBUG_PRINTF("%s", "unable to read all data for all_dylib_infos."); - m_dyld_image_infos.clear(); - } + } + if (!AddModulesUsingImageInfosAddress( + m_dyld_all_image_infos.dylib_info_addr, + m_dyld_all_image_infos.dylib_info_count)) { + DEBUG_PRINTF("%s", "unable to read all data for all_dylib_infos."); + m_dyld_image_infos.clear(); } // Now we have one more bit of business. If there is a library left in the @@ -765,8 +763,8 @@ } return true; - } else - return false; + } + return false; } //---------------------------------------------------------------------- Index: source/Plugins/DynamicLoader/POSIX-DYLD/AuxVector.cpp =================================================================== --- source/Plugins/DynamicLoader/POSIX-DYLD/AuxVector.cpp +++ source/Plugins/DynamicLoader/POSIX-DYLD/AuxVector.cpp @@ -37,8 +37,8 @@ DataBufferSP AuxVector::GetAuxvData() { if (m_process) return m_process->GetAuxvData(); - else - return DataBufferSP(); + + return DataBufferSP(); } void AuxVector::ParseAuxv(DataExtractor &data) { Index: source/Plugins/DynamicLoader/POSIX-DYLD/DYLDRendezvous.cpp =================================================================== --- source/Plugins/DynamicLoader/POSIX-DYLD/DYLDRendezvous.cpp +++ source/Plugins/DynamicLoader/POSIX-DYLD/DYLDRendezvous.cpp @@ -221,7 +221,7 @@ // accordingly. if (m_previous.state == eAdd) return fromRemote ? AddSOEntriesFromRemote(module_list) : AddSOEntries(); - else if (m_previous.state == eDelete) + if (m_previous.state == eDelete) return fromRemote ? RemoveSOEntriesFromRemote(module_list) : RemoveSOEntries(); Index: source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.cpp =================================================================== --- source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.cpp +++ source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.cpp @@ -703,8 +703,8 @@ if (tls_block == LLDB_INVALID_ADDRESS) return LLDB_INVALID_ADDRESS; - else - return tls_block + tls_file_addr; + + return tls_block + tls_file_addr; } void DynamicLoaderPOSIXDYLD::ResolveExecutableModule( Index: source/Plugins/ExpressionParser/Clang/ClangASTSource.cpp =================================================================== --- source/Plugins/ExpressionParser/Clang/ClangASTSource.cpp +++ source/Plugins/ExpressionParser/Clang/ClangASTSource.cpp @@ -533,7 +533,8 @@ return GetMergerUnchecked().FindExternalLexicalDecls(decl_context, predicate, decls); - } else if (!m_ast_importer_sp) + } + if (!m_ast_importer_sp) return; ClangASTMetrics::RegisterLexicalQuery(); @@ -1990,7 +1991,8 @@ clang::ASTContext &from_context = src_decl->getASTContext(); if (m_ast_importer_sp) { return m_ast_importer_sp->CopyDecl(m_ast_context, &from_context, src_decl); - } else if (m_merger_up) { + } + if (m_merger_up) { if (!m_merger_up->HasImporterForOrigin(from_context)) { lldbassert(0 && "Couldn't find the importer for a source context!"); return nullptr; @@ -2009,7 +2011,8 @@ if (m_ast_importer_sp) { return m_ast_importer_sp->ResolveDeclOrigin(decl, original_decl, original_ctx); - } else if (m_merger_up) { + } + if (m_merger_up) { return false; // Implement this correctly in ExternalASTMerger } else { // this can happen early enough that no ExternalASTSource is installed. @@ -2198,7 +2201,8 @@ m_decls.push_back(typedef_name_decl); return (NamedDecl *)typedef_name_decl; - } else if (const TagType *tag_type = qual_type->getAs()) { + } + if (const TagType *tag_type = qual_type->getAs()) { TagDecl *tag_decl = tag_type->getDecl(); m_decls.push_back(tag_decl); Index: source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.h =================================================================== --- source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.h +++ source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.h @@ -355,7 +355,7 @@ Target *GetTarget() { if (m_exe_ctx.GetTargetPtr()) return m_exe_ctx.GetTargetPtr(); - else if (m_sym_ctx.target_sp) + if (m_sym_ctx.target_sp) m_sym_ctx.target_sp.get(); return NULL; } Index: source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp =================================================================== --- source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp +++ source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp @@ -289,7 +289,8 @@ target.getASTContext(), source.getASTContext(), parser_type.GetOpaqueQualType()), &target); - } else if (m_merger_up) { + } + if (m_merger_up) { clang::FileID source_file = source.getASTContext()->getSourceManager().getFileID( source.getASTContext()->getTranslationUnitDecl()->getLocation()); @@ -1090,52 +1091,51 @@ } return; - } else { - // This branch will get hit if we are executing code in the context of - // a function that claims to have an object pointer (through - // DW_AT_object_pointer?) but is not formally a method of the class. - // In that case, just look up the "self" variable in the current scope - // and use its type. + } + // This branch will get hit if we are executing code in the context of + // a function that claims to have an object pointer (through + // DW_AT_object_pointer?) but is not formally a method of the class. + // In that case, just look up the "self" variable in the current scope + // and use its type. - VariableList *vars = frame->GetVariableList(false); + VariableList *vars = frame->GetVariableList(false); - lldb::VariableSP self_var = vars->FindVariable(ConstString("self")); + lldb::VariableSP self_var = vars->FindVariable(ConstString("self")); - if (self_var && self_var->IsInScope(frame) && - self_var->LocationIsValidForFrame(frame)) { - Type *self_type = self_var->GetType(); + if (self_var && self_var->IsInScope(frame) && + self_var->LocationIsValidForFrame(frame)) { + Type *self_type = self_var->GetType(); - if (!self_type) - return; + if (!self_type) + return; - CompilerType self_clang_type = self_type->GetFullCompilerType(); + CompilerType self_clang_type = self_type->GetFullCompilerType(); - if (ClangASTContext::IsObjCClassType(self_clang_type)) { - return; - } else if (ClangASTContext::IsObjCObjectPointerType( - self_clang_type)) { - self_clang_type = self_clang_type.GetPointeeType(); + if (ClangASTContext::IsObjCClassType(self_clang_type)) { + return; + } + if (ClangASTContext::IsObjCObjectPointerType(self_clang_type)) { + self_clang_type = self_clang_type.GetPointeeType(); - if (!self_clang_type) - return; + if (!self_clang_type) + return; - if (log) { - ASTDumper ast_dumper(self_type->GetFullCompilerType()); - log->Printf(" FEVD[%u] Adding type for $__lldb_objc_class: %s", - current_id, ast_dumper.GetCString()); - } + if (log) { + ASTDumper ast_dumper(self_type->GetFullCompilerType()); + log->Printf(" FEVD[%u] Adding type for $__lldb_objc_class: %s", + current_id, ast_dumper.GetCString()); + } - TypeFromUser class_user_type(self_clang_type); + TypeFromUser class_user_type(self_clang_type); - AddOneType(context, class_user_type, current_id); + AddOneType(context, class_user_type, current_id); - TypeFromUser self_user_type(self_type->GetFullCompilerType()); + TypeFromUser self_user_type(self_type->GetFullCompilerType()); - m_struct_vars->m_object_pointer_type = self_user_type; - return; - } + m_struct_vars->m_object_pointer_type = self_user_type; + return; + } } - } return; } @@ -2013,11 +2013,10 @@ context.AddNamedDecl(copied_function_decl); return; - } else { - if (log) { - log->Printf(" Failed to import the function decl for '%s'", - src_function_decl->getName().str().c_str()); - } + } + if (log) { + log->Printf(" Failed to import the function decl for '%s'", + src_function_decl->getName().str().c_str()); } } } Index: source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp =================================================================== --- source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp +++ source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp @@ -1009,7 +1009,7 @@ // FIXME - do we want to try to propagate specific errors here? if (!commit.isCommitable()) return false; - else if (!editor.commit(commit)) + if (!editor.commit(commit)) return false; // Now play all the edits, and stash the result in the diagnostic manager. @@ -1070,11 +1070,10 @@ err.SetErrorStringWithFormat("Couldn't find %s() in the module", m_expr.FunctionName()); return err; - } else { - if (log) - log->Printf("Found function %s for %s", function_name.AsCString(), - m_expr.FunctionName()); } + if (log) + log->Printf("Found function %s for %s", function_name.AsCString(), + m_expr.FunctionName()); } SymbolContext sc; Index: source/Plugins/ExpressionParser/Clang/ClangExpressionVariable.h =================================================================== --- source/Plugins/ExpressionParser/Clang/ClangExpressionVariable.h +++ source/Plugins/ExpressionParser/Clang/ClangExpressionVariable.h @@ -170,8 +170,8 @@ if (i == m_parser_vars.end()) return NULL; - else - return &i->second; + + return &i->second; } //---------------------------------------------------------------------- @@ -210,8 +210,8 @@ if (i == m_jit_vars.end()) return NULL; - else - return &i->second; + + return &i->second; } TypeFromUser GetTypeFromUser(); Index: source/Plugins/ExpressionParser/Clang/ClangPersistentVariables.cpp =================================================================== --- source/Plugins/ExpressionParser/Clang/ClangPersistentVariables.cpp +++ source/Plugins/ExpressionParser/Clang/ClangPersistentVariables.cpp @@ -74,6 +74,6 @@ if (i == m_persistent_decls.end()) return NULL; - else - return i->second; + + return i->second; } Index: source/Plugins/ExpressionParser/Clang/ClangUserExpression.cpp =================================================================== --- source/Plugins/ExpressionParser/Clang/ClangUserExpression.cpp +++ source/Plugins/ExpressionParser/Clang/ClangUserExpression.cpp @@ -272,8 +272,8 @@ if (ClangASTContext::IsObjCClassType(self_clang_type)) { return; - } else if (ClangASTContext::IsObjCObjectPointerType( - self_clang_type)) { + } + if (ClangASTContext::IsObjCObjectPointerType(self_clang_type)) { m_in_objectivec_method = true; m_needs_object_ptr = true; } else { Index: source/Plugins/ExpressionParser/Clang/ClangUtilityFunction.cpp =================================================================== --- source/Plugins/ExpressionParser/Clang/ClangUtilityFunction.cpp +++ source/Plugins/ExpressionParser/Clang/ClangUtilityFunction.cpp @@ -142,16 +142,15 @@ if (jit_error.Success()) { return true; - } else { - const char *error_cstr = jit_error.AsCString(); - if (error_cstr && error_cstr[0]) { - diagnostic_manager.Printf(eDiagnosticSeverityError, "%s", error_cstr); + } + const char *error_cstr = jit_error.AsCString(); + if (error_cstr && error_cstr[0]) { + diagnostic_manager.Printf(eDiagnosticSeverityError, "%s", error_cstr); } else { diagnostic_manager.PutString(eDiagnosticSeverityError, "expression can't be interpreted or run"); } return false; - } } void ClangUtilityFunction::ClangUtilityFunctionHelper::ResetDeclMap( Index: source/Plugins/ExpressionParser/Clang/IRForTarget.cpp =================================================================== --- source/Plugins/ExpressionParser/Clang/IRForTarget.cpp +++ source/Plugins/ExpressionParser/Clang/IRForTarget.cpp @@ -1265,8 +1265,9 @@ return false; return true; - } else if (ConstantDataArray *array_initializer = - dyn_cast(initializer)) { + } + if (ConstantDataArray *array_initializer = + dyn_cast(initializer)) { if (array_initializer->isString()) { std::string array_initializer_string = array_initializer->getAsString(); memcpy(data, array_initializer_string.c_str(), @@ -1396,8 +1397,8 @@ value_size, value_alignment)) { if (!global_variable->hasExternalLinkage()) return true; - else - return true; + + return true; } } else if (dyn_cast(llvm_value_ptr)) { if (log) @@ -1979,12 +1980,11 @@ LoadInst *load = new LoadInst(bit_cast, "", entry_instruction); return load; - } else { - BitCastInst *bit_cast = new BitCastInst( - get_element_ptr, value->getType(), "", entry_instruction); - - return bit_cast; } + BitCastInst *bit_cast = new BitCastInst( + get_element_ptr, value->getType(), "", entry_instruction); + + return bit_cast; }); if (Constant *constant = dyn_cast(value)) { Index: source/Plugins/Instruction/ARM/EmulateInstructionARM.cpp =================================================================== --- source/Plugins/Instruction/ARM/EmulateInstructionARM.cpp +++ source/Plugins/Instruction/ARM/EmulateInstructionARM.cpp @@ -661,8 +661,8 @@ uint32_t ITSession::GetCond() { if (InITBlock()) return Bits32(ITState, 7, 4); - else - return COND_AL; + + return COND_AL; } // ARM constants used during decoding @@ -760,7 +760,7 @@ bool EmulateInstructionARM::SetTargetTriple(const ArchSpec &arch) { if (arch.GetTriple().getArch() == llvm::Triple::arm) return true; - else if (arch.GetTriple().getArch() == llvm::Triple::thumb) + if (arch.GetTriple().getArch() == llvm::Triple::thumb) return true; return false; @@ -8784,60 +8784,60 @@ if (!CurrentModeIsPrivileged()) // UNPREDICTABLE; return false; - else { - uint64_t Rn = - ReadRegisterUnsigned(eRegisterKindDWARF, dwarf_r0 + n, 0, &success); - if (!success) - return false; - addr_t address; - // address = if increment then R[n] else R[n]-8; - if (increment) - address = Rn; - else - address = Rn - 8; + uint64_t Rn = + ReadRegisterUnsigned(eRegisterKindDWARF, dwarf_r0 + n, 0, &success); + if (!success) + return false; - // if wordhigher then address = address+4; - if (wordhigher) - address = address + 4; + addr_t address; + // address = if increment then R[n] else R[n]-8; + if (increment) + address = Rn; + else + address = Rn - 8; - // CPSRWriteByInstr(MemA[address+4,4], '1111', TRUE); - RegisterInfo base_reg; - GetRegisterInfo(eRegisterKindDWARF, dwarf_r0 + n, base_reg); + // if wordhigher then address = address+4; + if (wordhigher) + address = address + 4; - EmulateInstruction::Context context; - context.type = eContextReturnFromException; - context.SetRegisterPlusOffset(base_reg, address - Rn); + // CPSRWriteByInstr(MemA[address+4,4], '1111', TRUE); + RegisterInfo base_reg; + GetRegisterInfo(eRegisterKindDWARF, dwarf_r0 + n, base_reg); - uint64_t data = MemARead(context, address + 4, 4, 0, &success); - if (!success) - return false; + EmulateInstruction::Context context; + context.type = eContextReturnFromException; + context.SetRegisterPlusOffset(base_reg, address - Rn); - CPSRWriteByInstr(data, 15, true); + uint64_t data = MemARead(context, address + 4, 4, 0, &success); + if (!success) + return false; - // BranchWritePC(MemA[address,4]); - uint64_t data2 = MemARead(context, address, 4, 0, &success); - if (!success) - return false; + CPSRWriteByInstr(data, 15, true); + + // BranchWritePC(MemA[address,4]); + uint64_t data2 = MemARead(context, address, 4, 0, &success); + if (!success) + return false; - BranchWritePC(context, data2); + BranchWritePC(context, data2); - // if wback then R[n] = if increment then R[n]+8 else R[n]-8; - if (wback) { - context.type = eContextAdjustBaseRegister; - if (increment) { - context.SetOffset(8); - if (!WriteRegisterUnsigned(context, eRegisterKindDWARF, dwarf_r0 + n, - Rn + 8)) - return false; - } else { - context.SetOffset(-8); - if (!WriteRegisterUnsigned(context, eRegisterKindDWARF, dwarf_r0 + n, - Rn - 8)) - return false; - } + // if wback then R[n] = if increment then R[n]+8 else R[n]-8; + if (wback) { + context.type = eContextAdjustBaseRegister; + if (increment) { + context.SetOffset(8); + if (!WriteRegisterUnsigned(context, eRegisterKindDWARF, dwarf_r0 + n, + Rn + 8)) + return false; + } else { + context.SetOffset(-8); + if (!WriteRegisterUnsigned(context, eRegisterKindDWARF, dwarf_r0 + n, + Rn - 8)) + return false; + } } // if wback - } + } // if ConditionPassed() return true; } @@ -14203,8 +14203,8 @@ bool EmulateInstructionARM::LoadWritePC(Context &context, uint32_t addr) { if (ArchVersion() >= ARMv5T) return BXWritePC(context, addr); - else - return BranchWritePC((const Context)context, addr); + + return BranchWritePC((const Context)context, addr); } // Dispatches to either BXWritePC or BranchWritePC based on architecture @@ -14212,8 +14212,8 @@ bool EmulateInstructionARM::ALUWritePC(Context &context, uint32_t addr) { if (ArchVersion() >= ARMv7 && CurrentInstrSet() == eModeARM) return BXWritePC(context, addr); - else - return BranchWritePC((const Context)context, addr); + + return BranchWritePC((const Context)context, addr); } EmulateInstructionARM::Mode EmulateInstructionARM::CurrentInstrSet() { Index: source/Plugins/Instruction/ARM/EmulationStateARM.cpp =================================================================== --- source/Plugins/Instruction/ARM/EmulationStateARM.cpp +++ source/Plugins/Instruction/ARM/EmulationStateARM.cpp @@ -199,7 +199,8 @@ pseudo_state->StoreToPseudoAddress(addr, value); return length; - } else if (length == 8) { + } + if (length == 8) { uint32_t value1; uint32_t value2; memcpy (&value1, dst, sizeof (uint32_t)); @@ -294,8 +295,8 @@ value_sp = mem_dict->GetValueForKey(address_key); if (value_sp.get() == NULL) return false; - else - start_address = value_sp->GetUInt64Value(); + + start_address = value_sp->GetUInt64Value(); value_sp = mem_dict->GetValueForKey(data_key); OptionValueArray *mem_array = value_sp->GetAsArray(); Index: source/Plugins/Instruction/ARM64/EmulateInstructionARM64.cpp =================================================================== --- source/Plugins/Instruction/ARM64/EmulateInstructionARM64.cpp +++ source/Plugins/Instruction/ARM64/EmulateInstructionARM64.cpp @@ -163,7 +163,7 @@ bool EmulateInstructionARM64::SetTargetTriple(const ArchSpec &arch) { if (arch.GetTriple().getArch() == llvm::Triple::arm) return true; - else if (arch.GetTriple().getArch() == llvm::Triple::thumb) + if (arch.GetTriple().getArch() == llvm::Triple::thumb) return true; return false; Index: source/Plugins/Instruction/MIPS/EmulateInstructionMIPS.cpp =================================================================== --- source/Plugins/Instruction/MIPS/EmulateInstructionMIPS.cpp +++ source/Plugins/Instruction/MIPS/EmulateInstructionMIPS.cpp @@ -1042,15 +1042,14 @@ GetAddressByteSize()); m_next_inst_size = GetSizeOfInstruction(data, next_inst_addr); return true; - } else { - /* - * If the address class is not AddressClass::eCodeAlternateISA then - * the function is not microMIPS. In this case instruction size is - * always 4 bytes. - */ - m_next_inst_size = 4; - return true; } + /* + * If the address class is not AddressClass::eCodeAlternateISA then + * the function is not microMIPS. In this case instruction size is + * always 4 bytes. + */ + m_next_inst_size = 4; + return true; } return false; } @@ -1404,7 +1403,8 @@ WriteRegisterUnsigned(context, eRegisterKindDWARF, dwarf_sp_mips, result); return true; - } else if (src == dwarf_sp_mips) { + } + if (src == dwarf_sp_mips) { rt = m_reg_info->getEncodingValue(insn.getOperand(2).getReg()); /* read register */ Index: source/Plugins/Instruction/MIPS64/EmulateInstructionMIPS64.cpp =================================================================== --- source/Plugins/Instruction/MIPS64/EmulateInstructionMIPS64.cpp +++ source/Plugins/Instruction/MIPS64/EmulateInstructionMIPS64.cpp @@ -1314,7 +1314,8 @@ WriteRegisterUnsigned(context, eRegisterKindDWARF, dwarf_sp_mips64, result); return true; - } else if (src == dwarf_sp_mips64) { + } + if (src == dwarf_sp_mips64) { rt = m_reg_info->getEncodingValue(insn.getOperand(2).getReg()); /* read register */ Index: source/Plugins/Instruction/PPC64/EmulateInstructionPPC64.cpp =================================================================== --- source/Plugins/Instruction/PPC64/EmulateInstructionPPC64.cpp +++ source/Plugins/Instruction/PPC64/EmulateInstructionPPC64.cpp @@ -69,7 +69,7 @@ bool EmulateInstructionPPC64::SetTargetTriple(const ArchSpec &arch) { if (arch.GetTriple().getArch() == llvm::Triple::ppc64) return true; - else if (arch.GetTriple().getArch() == llvm::Triple::ppc64le) + if (arch.GetTriple().getArch() == llvm::Triple::ppc64le) return true; return false; Index: source/Plugins/InstrumentationRuntime/ASan/ASanRuntime.cpp =================================================================== --- source/Plugins/InstrumentationRuntime/ASan/ASanRuntime.cpp +++ source/Plugins/InstrumentationRuntime/ASan/ASanRuntime.cpp @@ -273,8 +273,8 @@ "report.\n"); } return true; // Return true to stop the target - } else - return false; // Let target run + } + return false; // Let target run } void AddressSanitizerRuntime::Activate() { Index: source/Plugins/InstrumentationRuntime/TSan/TSanRuntime.cpp =================================================================== --- source/Plugins/InstrumentationRuntime/TSan/TSanRuntime.cpp +++ source/Plugins/InstrumentationRuntime/TSan/TSanRuntime.cpp @@ -495,7 +495,8 @@ if (description == "data-race") { return "Data race"; - } else if (description == "data-race-vptr") { + } + if (description == "data-race-vptr") { return "Data race on C++ virtual pointer"; } else if (description == "heap-use-after-free") { return "Use of deallocated memory"; @@ -872,8 +873,8 @@ "report.\n"); } return true; // Return true to stop the target - } else - return false; // Let target run + } + return false; // Let target run } const RegularExpression &ThreadSanitizerRuntime::GetPatternForRuntimeLibrary() { Index: source/Plugins/JITLoader/GDB/JITLoaderGDB.cpp =================================================================== --- source/Plugins/JITLoader/GDB/JITLoaderGDB.cpp +++ source/Plugins/JITLoader/GDB/JITLoaderGDB.cpp @@ -260,8 +260,8 @@ bool JITLoaderGDB::ReadJITDescriptor(bool all_entries) { if (m_process->GetTarget().GetArchitecture().GetAddressByteSize() == 8) return ReadJITDescriptorImpl(all_entries); - else - return ReadJITDescriptorImpl(all_entries); + + return ReadJITDescriptorImpl(all_entries); } template Index: source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp =================================================================== --- source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp +++ source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp @@ -176,15 +176,14 @@ if (IsTrivialBasename(m_basename)) { return true; - } else { - // The C++ basename doesn't match our regular expressions so this can't - // be a valid C++ method, clear everything out and indicate an error - m_context = llvm::StringRef(); - m_basename = llvm::StringRef(); - m_arguments = llvm::StringRef(); - m_qualifiers = llvm::StringRef(); - return false; } + // The C++ basename doesn't match our regular expressions so this can't + // be a valid C++ method, clear everything out and indicate an error + m_context = llvm::StringRef(); + m_basename = llvm::StringRef(); + m_arguments = llvm::StringRef(); + m_qualifiers = llvm::StringRef(); + return false; } return false; } Index: source/Plugins/Language/CPlusPlus/CPlusPlusNameParser.cpp =================================================================== --- source/Plugins/Language/CPlusPlus/CPlusPlusNameParser.cpp +++ source/Plugins/Language/CPlusPlus/CPlusPlusNameParser.cpp @@ -596,9 +596,8 @@ } start_position.Remove(); return result; - } else { - return None; } + return None; } llvm::StringRef CPlusPlusNameParser::GetTextForRange(const Range &range) { Index: source/Plugins/Language/CPlusPlus/LibCxx.cpp =================================================================== --- source/Plugins/Language/CPlusPlus/LibCxx.cpp +++ source/Plugins/Language/CPlusPlus/LibCxx.cpp @@ -120,21 +120,19 @@ if (ptr_sp->GetValueAsUnsigned(0) == 0) { stream.Printf("nullptr"); return true; - } else { - bool print_pointee = false; - Status error; - ValueObjectSP pointee_sp = ptr_sp->Dereference(error); - if (pointee_sp && error.Success()) { - if (pointee_sp->DumpPrintableRepresentation( - stream, ValueObject::eValueObjectRepresentationStyleSummary, - lldb::eFormatInvalid, - ValueObject::PrintableRepresentationSpecialCases::eDisable, - false)) - print_pointee = true; + } + bool print_pointee = false; + Status error; + ValueObjectSP pointee_sp = ptr_sp->Dereference(error); + if (pointee_sp && error.Success()) { + if (pointee_sp->DumpPrintableRepresentation( + stream, ValueObject::eValueObjectRepresentationStyleSummary, + lldb::eFormatInvalid, + ValueObject::PrintableRepresentationSpecialCases::eDisable, false)) + print_pointee = true; } if (!print_pointee) stream.Printf("ptr = 0x%" PRIx64, ptr_sp->GetValueAsUnsigned(0)); - } if (count_sp) stream.Printf(" strong=%" PRIu64, 1 + count_sp->GetValueAsUnsigned(0)); @@ -367,21 +365,20 @@ shared_owners_sp->GetCompilerType()); } return m_count_sp; - } else /* if (idx == 2) */ - { - if (!m_weak_count_sp) { - ValueObjectSP shared_weak_owners_sp(m_cntrl->GetChildMemberWithName( - ConstString("__shared_weak_owners_"), true)); - if (!shared_weak_owners_sp) - return lldb::ValueObjectSP(); - uint64_t count = 1 + shared_weak_owners_sp->GetValueAsUnsigned(0); - DataExtractor data(&count, 8, m_byte_order, m_ptr_size); - m_weak_count_sp = CreateValueObjectFromData( - "count", data, valobj_sp->GetExecutionContextRef(), - shared_weak_owners_sp->GetCompilerType()); - } - return m_weak_count_sp; + } /* if (idx == 2) */ + + if (!m_weak_count_sp) { + ValueObjectSP shared_weak_owners_sp(m_cntrl->GetChildMemberWithName( + ConstString("__shared_weak_owners_"), true)); + if (!shared_weak_owners_sp) + return lldb::ValueObjectSP(); + uint64_t count = 1 + shared_weak_owners_sp->GetValueAsUnsigned(0); + DataExtractor data(&count, 8, m_byte_order, m_ptr_size); + m_weak_count_sp = CreateValueObjectFromData( + "count", data, valobj_sp->GetExecutionContextRef(), + shared_weak_owners_sp->GetCompilerType()); } + return m_weak_count_sp; } bool lldb_private::formatters::LibcxxSharedPtrSyntheticFrontEnd::Update() { @@ -512,20 +509,19 @@ ? size_mode_value : ((size_mode_value >> 1) % 256); return (location_sp.get() != nullptr); - } else { - ValueObjectSP l(D->GetChildAtIndex(0, true)); - if (!l) - return false; - // we can use the layout_decider object as the data pointer - location_sp = (layout == eLibcxxStringLayoutModeDSC) - ? layout_decider - : l->GetChildAtIndex(2, true); - ValueObjectSP size_vo(l->GetChildAtIndex(1, true)); - if (!size_vo || !location_sp) - return false; - size = size_vo->GetValueAsUnsigned(0); - return true; } + ValueObjectSP l(D->GetChildAtIndex(0, true)); + if (!l) + return false; + // we can use the layout_decider object as the data pointer + location_sp = (layout == eLibcxxStringLayoutModeDSC) + ? layout_decider + : l->GetChildAtIndex(2, true); + ValueObjectSP size_vo(l->GetChildAtIndex(1, true)); + if (!size_vo || !location_sp) + return false; + size = size_vo->GetValueAsUnsigned(0); + return true; } bool lldb_private::formatters::LibcxxWStringSummaryProvider( Index: source/Plugins/Language/CPlusPlus/LibCxxList.cpp =================================================================== --- source/Plugins/Language/CPlusPlus/LibCxxList.cpp +++ source/Plugins/Language/CPlusPlus/LibCxxList.cpp @@ -340,25 +340,24 @@ } if (m_count != UINT32_MAX) { return m_count; - } else { - uint64_t next_val = m_head->GetValueAsUnsigned(0); - uint64_t prev_val = m_tail->GetValueAsUnsigned(0); - if (next_val == 0 || prev_val == 0) - return 0; - if (next_val == m_node_address) - return 0; - if (next_val == prev_val) - return 1; - uint64_t size = 2; - ListEntry current(m_head); - while (current.next() && current.next().value() != m_node_address) { - size++; - current = current.next(); - if (size > m_list_capping_size) - break; + } + uint64_t next_val = m_head->GetValueAsUnsigned(0); + uint64_t prev_val = m_tail->GetValueAsUnsigned(0); + if (next_val == 0 || prev_val == 0) + return 0; + if (next_val == m_node_address) + return 0; + if (next_val == prev_val) + return 1; + uint64_t size = 2; + ListEntry current(m_head); + while (current.next() && current.next().value() != m_node_address) { + size++; + current = current.next(); + if (size > m_list_capping_size) + break; } return m_count = (size - 1); - } } lldb::ValueObjectSP ListFrontEnd::GetChildAtIndex(size_t idx) { Index: source/Plugins/Language/CPlusPlus/LibCxxMap.cpp =================================================================== --- source/Plugins/Language/CPlusPlus/LibCxxMap.cpp +++ source/Plugins/Language/CPlusPlus/LibCxxMap.cpp @@ -279,10 +279,9 @@ 0, name, &bit_offset_ptr, &bitfield_bit_size_ptr, &is_bitfield_ptr); m_element_type = m_element_type.GetTypedefedType(); return m_element_type.IsValid(); - } else { - m_element_type = m_backend.GetCompilerType().GetTypeTemplateArgument(0); - return m_element_type.IsValid(); } + m_element_type = m_backend.GetCompilerType().GetTypeTemplateArgument(0); + return m_element_type.IsValid(); } void lldb_private::formatters::LibcxxStdMapSyntheticFrontEnd::GetValueOffset( Index: source/Plugins/Language/CPlusPlus/LibStdcpp.cpp =================================================================== --- source/Plugins/Language/CPlusPlus/LibStdcpp.cpp +++ source/Plugins/Language/CPlusPlus/LibStdcpp.cpp @@ -265,8 +265,8 @@ StringPrinter::StringElementType::UTF8>(options)) { stream.Printf("Summary Unavailable"); return true; - } else - return true; + } + return true; } break; case eAddressTypeHost: break; @@ -362,8 +362,8 @@ if (idx == 0) return valobj_sp->GetChildMemberWithName(ConstString("_M_ptr"), true); - else - return lldb::ValueObjectSP(); + + return lldb::ValueObjectSP(); } bool LibStdcppSharedPtrSyntheticFrontEnd::Update() { return false; } Index: source/Plugins/Language/ClangCommon/ClangHighlighter.cpp =================================================================== --- source/Plugins/Language/ClangCommon/ClangHighlighter.cpp +++ source/Plugins/Language/ClangCommon/ClangHighlighter.cpp @@ -54,7 +54,8 @@ // If we were in a preprocessor directive before, we now left it. in_pp_directive = false; return options.comment; - } else if (in_pp_directive || token.getKind() == tok::hash) { + } + if (in_pp_directive || token.getKind() == tok::hash) { // Let's assume that the rest of the line is a PP directive. in_pp_directive = true; // Preprocessor directives are hard to match, so we have to hack this in. Index: source/Plugins/Language/ObjC/NSArray.cpp =================================================================== --- source/Plugins/Language/ObjC/NSArray.cpp +++ source/Plugins/Language/ObjC/NSArray.cpp @@ -206,10 +206,9 @@ if (process.GetAddressByteSize() == 4) { return __NSArrayMSize_Impl>(process, valobj_addr, error); - } else { - return __NSArrayMSize_Impl>(process, valobj_addr, - error); } + return __NSArrayMSize_Impl>(process, valobj_addr, + error); } } @@ -446,8 +445,8 @@ auto iter = map.find(class_name), end = map.end(); if (iter != end) return iter->second(valobj, stream, options); - else - return false; + + return false; } std::string prefix, suffix; @@ -845,8 +844,8 @@ return (new Foundation1436::NSArrayISyntheticFrontEnd(valobj_sp)); if (runtime->GetFoundationVersion() >= 1430) return (new Foundation1430::NSArrayISyntheticFrontEnd(valobj_sp)); - else - return (new Foundation1300::NSArrayISyntheticFrontEnd(valobj_sp)); + + return (new Foundation1300::NSArrayISyntheticFrontEnd(valobj_sp)); } else if (class_name == g_NSArrayI_Transfer) { return (new Foundation1436::NSArrayI_TransferSyntheticFrontEnd(valobj_sp)); } else if (class_name == g_NSArray0) { @@ -863,8 +862,8 @@ return (new Foundation1428::NSArrayMSyntheticFrontEnd(valobj_sp)); if (runtime->GetFoundationVersion() >= 1100) return (new Foundation1010::NSArrayMSyntheticFrontEnd(valobj_sp)); - else - return (new Foundation109::NSArrayMSyntheticFrontEnd(valobj_sp)); + + return (new Foundation109::NSArrayMSyntheticFrontEnd(valobj_sp)); } else if (class_name == g_NSCallStackArray) { return (new CallStackArray::NSCallStackArraySyntheticFrontEnd(valobj_sp)); } else { Index: source/Plugins/Language/ObjC/NSDictionary.cpp =================================================================== --- source/Plugins/Language/ObjC/NSDictionary.cpp +++ source/Plugins/Language/ObjC/NSDictionary.cpp @@ -344,10 +344,9 @@ if (process.GetAddressByteSize() == 4) { return __NSDictionaryMSize_Impl(process, valobj_addr, error); - } else { - return __NSDictionaryMSize_Impl(process, valobj_addr, - error); } + return __NSDictionaryMSize_Impl(process, valobj_addr, + error); } } @@ -489,16 +488,18 @@ if (class_name == g_DictionaryI) { return (new NSDictionaryISyntheticFrontEnd(valobj_sp)); - } else if (class_name == g_DictionaryM) { + } + if (class_name == g_DictionaryM) { if (runtime->GetFoundationVersion() >= 1437) { return (new Foundation1437::NSDictionaryMSyntheticFrontEnd(valobj_sp)); - } else if (runtime->GetFoundationVersion() >= 1428) { + } + if (runtime->GetFoundationVersion() >= 1428) { return (new Foundation1428::NSDictionaryMSyntheticFrontEnd(valobj_sp)); } else { return (new Foundation1100::NSDictionaryMSyntheticFrontEnd(valobj_sp)); } } else if (class_name == g_DictionaryMLegacy) { - return (new Foundation1100::NSDictionaryMSyntheticFrontEnd(valobj_sp)); + return (new Foundation1100::NSDictionaryMSyntheticFrontEnd(valobj_sp)); } else if (class_name == g_Dictionary1) { return (new NSDictionary1SyntheticFrontEnd(valobj_sp)); } else { Index: source/Plugins/Language/ObjC/NSError.cpp =================================================================== --- source/Plugins/Language/ObjC/NSError.cpp +++ source/Plugins/Language/ObjC/NSError.cpp @@ -101,10 +101,9 @@ stream.Printf("domain: %s - code: %" PRIu64, domain_str_summary.GetData(), code); return true; - } else { - stream.Printf("domain: nil - code: %" PRIu64, code); - return true; } + stream.Printf("domain: nil - code: %" PRIu64, code); + return true; } class NSErrorSyntheticFrontEnd : public SyntheticChildrenFrontEnd { @@ -207,7 +206,7 @@ if (!strcmp(class_name, "NSError")) return (new NSErrorSyntheticFrontEnd(valobj_sp)); - else if (!strcmp(class_name, "__NSCFError")) + if (!strcmp(class_name, "__NSCFError")) return (new NSErrorSyntheticFrontEnd(valobj_sp)); return nullptr; Index: source/Plugins/Language/ObjC/NSException.cpp =================================================================== --- source/Plugins/Language/ObjC/NSException.cpp +++ source/Plugins/Language/ObjC/NSException.cpp @@ -113,8 +113,8 @@ stream.Printf("name: %s - reason: %s", name_str_summary.GetData(), reason_str_summary.GetData()); return true; - } else - return false; + } + return false; } class NSExceptionSyntheticFrontEnd : public SyntheticChildrenFrontEnd { @@ -202,7 +202,7 @@ if (!strcmp(class_name, "NSException")) return (new NSExceptionSyntheticFrontEnd(valobj_sp)); - else if (!strcmp(class_name, "NSCFException")) + if (!strcmp(class_name, "NSCFException")) return (new NSExceptionSyntheticFrontEnd(valobj_sp)); else if (!strcmp(class_name, "__NSCFException")) return (new NSExceptionSyntheticFrontEnd(valobj_sp)); Index: source/Plugins/Language/ObjC/NSSet.cpp =================================================================== --- source/Plugins/Language/ObjC/NSSet.cpp +++ source/Plugins/Language/ObjC/NSSet.cpp @@ -202,9 +202,8 @@ Status &error) { if (process.GetAddressByteSize() == 4) { return __NSSetMSize_Impl(process, valobj_addr, error); - } else { - return __NSSetMSize_Impl(process, valobj_addr, error); } + return __NSSetMSize_Impl(process, valobj_addr, error); } } @@ -291,8 +290,8 @@ auto iter = map.find(class_name_cs), end = map.end(); if (iter != end) return iter->second(valobj, stream, options); - else - return false; + + return false; } std::string prefix, suffix; @@ -346,13 +345,14 @@ if (!strcmp(class_name, "__NSSetI") || !strcmp(class_name, "__NSOrderedSetI")) { return (new NSSetISyntheticFrontEnd(valobj_sp)); - } else if (!strcmp(class_name, "__NSSetM")) { + } + if (!strcmp(class_name, "__NSSetM")) { AppleObjCRuntime *apple_runtime = llvm::dyn_cast_or_null(runtime); if (apple_runtime) { if (apple_runtime->GetFoundationVersion() >= 1437) return (new Foundation1437::NSSetMSyntheticFrontEnd(valobj_sp)); - else if (apple_runtime->GetFoundationVersion() >= 1428) + if (apple_runtime->GetFoundationVersion() >= 1428) return (new Foundation1428::NSSetMSyntheticFrontEnd(valobj_sp)); else return (new Foundation1300::NSSetMSyntheticFrontEnd(valobj_sp)); Index: source/Plugins/Language/ObjC/NSString.cpp =================================================================== --- source/Plugins/Language/ObjC/NSString.cpp +++ source/Plugins/Language/ObjC/NSString.cpp @@ -181,19 +181,19 @@ options.SetLanguage(summary_options.GetLanguage()); return StringPrinter::ReadStringAndDumpToStream< StringPrinter::StringElementType::UTF16>(options); - } else { - options.SetLocation(location + 1); - options.SetProcessSP(process_sp); - options.SetStream(&stream); - options.SetSourceSize(explicit_length); - options.SetNeedsZeroTermination(false); - options.SetIgnoreMaxLength(summary_options.GetCapping() == - TypeSummaryCapping::eTypeSummaryUncapped); - options.SetBinaryZeroIsTerminator(false); - options.SetLanguage(summary_options.GetLanguage()); - return StringPrinter::ReadStringAndDumpToStream< - StringPrinter::StringElementType::ASCII>(options); } + options.SetLocation(location + 1); + options.SetProcessSP(process_sp); + options.SetStream(&stream); + options.SetSourceSize(explicit_length); + options.SetNeedsZeroTermination(false); + options.SetIgnoreMaxLength(summary_options.GetCapping() == + TypeSummaryCapping::eTypeSummaryUncapped); + options.SetBinaryZeroIsTerminator(false); + options.SetLanguage(summary_options.GetLanguage()); + return StringPrinter::ReadStringAndDumpToStream< + StringPrinter::StringElementType::ASCII>(options); + } else if (is_inline && has_explicit_length && !is_unicode && !is_path_store && !is_mutable) { uint64_t location = 3 * ptr_size + valobj_addr; @@ -213,8 +213,8 @@ if (is_inline) { if (!has_explicit_length) { return false; - } else - location += ptr_size; + } + location += ptr_size; } else { location = process_sp->ReadPointerFromMemory(location, error); if (error.Fail()) @@ -278,9 +278,9 @@ if (has_explicit_length) return StringPrinter::ReadStringAndDumpToStream< StringPrinter::StringElementType::UTF8>(options); - else - return StringPrinter::ReadStringAndDumpToStream< - StringPrinter::StringElementType::ASCII>(options); + + return StringPrinter::ReadStringAndDumpToStream< + StringPrinter::StringElementType::ASCII>(options); } else { uint64_t location = valobj_addr + 2 * ptr_size; location = process_sp->ReadPointerFromMemory(location, error); Index: source/Plugins/Language/ObjC/ObjCLanguage.h =================================================================== --- source/Plugins/Language/ObjC/ObjCLanguage.h +++ source/Plugins/Language/ObjC/ObjCLanguage.h @@ -149,7 +149,7 @@ if (strchr(name, ':') == nullptr) return true; - else if (name[strlen(name) - 1] == ':') + if (name[strlen(name) - 1] == ':') return true; else return false; Index: source/Plugins/LanguageRuntime/CPlusPlus/ItaniumABI/ItaniumABILanguageRuntime.cpp =================================================================== --- source/Plugins/LanguageRuntime/CPlusPlus/ItaniumABI/ItaniumABILanguageRuntime.cpp +++ source/Plugins/LanguageRuntime/CPlusPlus/ItaniumABI/ItaniumABILanguageRuntime.cpp @@ -311,8 +311,8 @@ // Can we maybe ask Clang about this? if (strstr(name, "_vptr$") == name) return true; - else - return false; + + return false; } //------------------------------------------------------------------ @@ -329,8 +329,8 @@ language == eLanguageTypeC_plus_plus_11 || language == eLanguageTypeC_plus_plus_14) return new ItaniumABILanguageRuntime(process); - else - return NULL; + + return NULL; } class CommandObjectMultiwordItaniumABI_Demangle : public CommandObjectParsed { @@ -486,9 +486,8 @@ filter_modules.Append(FileSpec("libc++abi.dylib")); filter_modules.Append(FileSpec("libSystem.B.dylib")); return target.GetSearchFilterForModuleList(&filter_modules); - } else { - return LanguageRuntime::CreateExceptionSearchFilter(); } + return LanguageRuntime::CreateExceptionSearchFilter(); } lldb::BreakpointSP ItaniumABILanguageRuntime::CreateExceptionBreakpoint( @@ -558,8 +557,8 @@ DynamicTypeCache::const_iterator pos = m_dynamic_type_map.find(vtable_addr); if (pos == m_dynamic_type_map.end()) return TypeAndOrName(); - else - return pos->second; + + return pos->second; } void ItaniumABILanguageRuntime::SetDynamicTypeInfo( Index: source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCDeclVendor.cpp =================================================================== --- source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCDeclVendor.cpp +++ source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCDeclVendor.cpp @@ -345,12 +345,11 @@ selector_components.push_back( &ast_ctx.Idents.get(llvm::StringRef(name_cursor))); break; - } else { - is_zero_argument = false; - selector_components.push_back(&ast_ctx.Idents.get( - llvm::StringRef(name_cursor, colon_loc - name_cursor))); - name_cursor = colon_loc + 1; } + is_zero_argument = false; + selector_components.push_back(&ast_ctx.Idents.get( + llvm::StringRef(name_cursor, colon_loc - name_cursor))); + name_cursor = colon_loc + 1; } clang::IdentifierInfo **identifier_infos = selector_components.data(); @@ -602,13 +601,13 @@ decls.push_back(result_iface_decl); ret++; break; - } else { - if (log) - log->Printf("AOCTV::FT [%u] There's something in the ASTContext, but " - "it's not something we know about", - current_id); - break; } + if (log) + log->Printf("AOCTV::FT [%u] There's something in the ASTContext, but " + "it's not something we know about", + current_id); + break; + } else if (log) { log->Printf("AOCTV::FT [%u] Couldn't find %s in the ASTContext", current_id, name.AsCString()); Index: source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.cpp =================================================================== --- source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.cpp +++ source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.cpp @@ -305,8 +305,8 @@ } } return LLDB_INVALID_MODULE_VERSION; - } else - return m_Foundation_major.getValue(); + } + return m_Foundation_major.getValue(); } void AppleObjCRuntime::GetValuesForGlobalCFBooleans(lldb::addr_t &cf_true, @@ -327,8 +327,8 @@ if (m_objc_trampoline_handler_ap.get() != NULL) { m_read_objc_library = true; return true; - } else - return false; + } + return false; } ThreadPlanSP AppleObjCRuntime::GetStepThroughTrampolinePlan(Thread &thread, @@ -446,8 +446,8 @@ target.GetImages().FindSymbolsWithNameAndType(s_arclite_method_signature, eSymbolTypeCode, sc_list)) return true; - else - return false; + + return false; } lldb::SearchFilterSP AppleObjCRuntime::CreateExceptionSearchFilter() { @@ -457,9 +457,8 @@ FileSpecList filter_modules; filter_modules.Append(std::get<0>(GetExceptionThrowLocation())); return target.GetSearchFilterForModuleList(&filter_modules); - } else { - return LanguageRuntime::CreateExceptionSearchFilter(); } + return LanguageRuntime::CreateExceptionSearchFilter(); } std::tuple Index: source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV1.cpp =================================================================== --- source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV1.cpp +++ source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV1.cpp @@ -76,8 +76,8 @@ if (AppleObjCRuntime::GetObjCVersion(process, objc_module_sp) == ObjCRuntimeVersions::eAppleObjC_V1) return new AppleObjCRuntimeV1(process); - else - return NULL; + + return NULL; } else return NULL; } Index: source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp =================================================================== --- source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp +++ source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp @@ -364,8 +364,8 @@ if (read_value) return process->ReadUnsignedIntegerFromMemory( symbol_load_addr, byte_size, default_value, error); - else - return symbol_load_addr; + + return symbol_load_addr; } else { error.SetErrorString("symbol address invalid"); return default_value; @@ -471,8 +471,8 @@ if (AppleObjCRuntime::GetObjCVersion(process, objc_module_sp) == ObjCRuntimeVersions::eAppleObjC_V2) return new AppleObjCRuntimeV2(process, objc_module_sp); - else - return NULL; + + return NULL; } else return NULL; } @@ -628,11 +628,10 @@ } result.SetStatus(lldb::eReturnStatusSuccessFinishResult); return true; - } else { - result.AppendError("current process has no Objective-C runtime loaded"); - result.SetStatus(lldb::eReturnStatusFailed); - return false; } + result.AppendError("current process has no Objective-C runtime loaded"); + result.SetStatus(lldb::eReturnStatusFailed); + return false; } CommandOptions m_options; @@ -714,11 +713,10 @@ } result.SetStatus(lldb::eReturnStatusSuccessFinishResult); return true; - } else { - result.AppendError("current process has no Objective-C runtime loaded"); - result.SetStatus(lldb::eReturnStatusFailed); - return false; } + result.AppendError("current process has no Objective-C runtime loaded"); + result.SetStatus(lldb::eReturnStatusFailed); + return false; } }; @@ -1177,26 +1175,25 @@ // tagged pointer if (IsTaggedPointer(isa_pointer)) { return m_tagged_pointer_vendor_ap->GetClassDescriptor(isa_pointer); - } else { - ExecutionContext exe_ctx(valobj.GetExecutionContextRef()); + } + ExecutionContext exe_ctx(valobj.GetExecutionContextRef()); - Process *process = exe_ctx.GetProcessPtr(); - if (process) { - Status error; - ObjCISA isa = process->ReadPointerFromMemory(isa_pointer, error); - if (isa != LLDB_INVALID_ADDRESS) { - objc_class_sp = GetClassDescriptorFromISA(isa); - if (isa && !objc_class_sp) { - Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_PROCESS)); - if (log) - log->Printf("0x%" PRIx64 - ": AppleObjCRuntimeV2::GetClassDescriptor() ISA was " - "not in class descriptor cache 0x%" PRIx64, - isa_pointer, isa); - } + Process *process = exe_ctx.GetProcessPtr(); + if (process) { + Status error; + ObjCISA isa = process->ReadPointerFromMemory(isa_pointer, error); + if (isa != LLDB_INVALID_ADDRESS) { + objc_class_sp = GetClassDescriptorFromISA(isa); + if (isa && !objc_class_sp) { + Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_PROCESS)); + if (log) + log->Printf("0x%" PRIx64 + ": AppleObjCRuntimeV2::GetClassDescriptor() ISA was " + "not in class descriptor cache 0x%" PRIx64, + isa_pointer, isa); } } - } + } } return objc_class_sp; } Index: source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTrampolineHandler.cpp =================================================================== --- source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTrampolineHandler.cpp +++ source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTrampolineHandler.cpp @@ -708,7 +708,8 @@ get_impl_name.AsCString()); } return; - } else if (m_impl_stret_fn_addr == LLDB_INVALID_ADDRESS) { + } + if (m_impl_stret_fn_addr == LLDB_INVALID_ADDRESS) { // It there is no stret return lookup function, assume that it is the same // as the straight lookup: m_impl_stret_fn_addr = m_impl_fn_addr; Index: source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTypeEncodingParser.cpp =================================================================== --- source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTypeEncodingParser.cpp +++ source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTypeEncodingParser.cpp @@ -119,13 +119,12 @@ if (type.NextIf(closer)) { in_union = false; break; - } else { - auto element = ReadStructElement(ast_ctx, type, for_expression); - if (element.type.isNull()) - break; - else - elements.push_back(element); } + auto element = ReadStructElement(ast_ctx, type, for_expression); + if (element.type.isNull()) + break; + + elements.push_back(element); } if (in_union) return clang::QualType(); @@ -238,8 +237,8 @@ if (less_than_pos != std::string::npos) { if (less_than_pos == 0) return ast_ctx.getObjCIdType(); - else - name.erase(less_than_pos); + + name.erase(less_than_pos); } DeclVendor *decl_vendor = m_runtime.GetDeclVendor(); @@ -265,10 +264,9 @@ return ClangUtil::GetQualType( ClangASTContext::GetTypeForDecl(decls[0]).GetPointerType()); - } else { - // We're going to resolve this dynamically anyway, so just smile and wave. - return ast_ctx.getObjCIdType(); } + // We're going to resolve this dynamically anyway, so just smile and wave. + return ast_ctx.getObjCIdType(); } clang::QualType @@ -342,14 +340,14 @@ if (bitfield_bit_size) { *bitfield_bit_size = size; return ast_ctx.UnsignedIntTy; // FIXME: the spec is fairly vague here. - } else - return clang::QualType(); + } + return clang::QualType(); } case 'r': { clang::QualType target_type = BuildType(ast_ctx, type, for_expression); if (target_type.isNull()) return clang::QualType(); - else if (target_type == ast_ctx.UnknownAnyTy) + if (target_type == ast_ctx.UnknownAnyTy) return ast_ctx.UnknownAnyTy; else return ast_ctx.getConstType(target_type); @@ -362,15 +360,14 @@ // nothing exists') but is way better than outright failure in many // practical cases return ast_ctx.VoidPtrTy; - } else { - clang::QualType target_type = BuildType(ast_ctx, type, for_expression); - if (target_type.isNull()) - return clang::QualType(); - else if (target_type == ast_ctx.UnknownAnyTy) - return ast_ctx.UnknownAnyTy; - else - return ast_ctx.getPointerType(target_type); } + clang::QualType target_type = BuildType(ast_ctx, type, for_expression); + if (target_type.isNull()) + return clang::QualType(); + if (target_type == ast_ctx.UnknownAnyTy) + return ast_ctx.UnknownAnyTy; + else + return ast_ctx.getPointerType(target_type); } case '?': return for_expression ? ast_ctx.UnknownAnyTy : clang::QualType(); Index: source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleThreadPlanStepThroughObjCTrampoline.cpp =================================================================== --- source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleThreadPlanStepThroughObjCTrampoline.cpp +++ source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleThreadPlanStepThroughObjCTrampoline.cpp @@ -120,13 +120,12 @@ if (m_func_sp) { if (!m_func_sp->IsPlanComplete()) { return false; - } else { - if (!m_func_sp->PlanSucceeded()) { - SetPlanComplete(false); - return true; - } - m_func_sp.reset(); } + if (!m_func_sp->PlanSucceeded()) { + SetPlanComplete(false); + return true; + } + m_func_sp.reset(); } // Second stage, if all went well with the function calling, then fetch the @@ -189,7 +188,8 @@ m_thread.QueueThreadPlan(m_run_to_sp, false); m_run_to_sp->SetPrivate(true); return false; - } else if (m_thread.IsThreadPlanDone(m_run_to_sp.get())) { + } + if (m_thread.IsThreadPlanDone(m_run_to_sp.get())) { // Third stage, work the run to target plan. SetPlanComplete(); return true; @@ -202,8 +202,8 @@ bool AppleThreadPlanStepThroughObjCTrampoline::MischiefManaged() { if (IsPlanComplete()) return true; - else - return false; + + return false; } bool AppleThreadPlanStepThroughObjCTrampoline::WillStop() { return true; } Index: source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.cpp =================================================================== --- source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.cpp +++ source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.cpp @@ -494,8 +494,8 @@ name.AsCString(), offset); } return true; - } else - return false; + } + return false; } } // anonymous namespace @@ -798,8 +798,8 @@ if (language == eLanguageTypeExtRenderScript) return new RenderScriptRuntime(process); - else - return nullptr; + + return nullptr; } // Callback with a module to search for matching symbols. We first check that @@ -1170,7 +1170,8 @@ log->Printf("%s - Error while reading the function parameters", __FUNCTION__); return; - } else if (log) { + } + if (log) { log->Printf("%s - groupName : 0x%" PRIx64, __FUNCTION__, addr_t(args[eGroupName])); log->Printf("%s - groupNameSize: %" PRIu64, __FUNCTION__, @@ -1193,10 +1194,10 @@ if (log) log->Printf("Error reading scriptgroup name from target"); return; - } else { - if (log) - log->Printf("Extracted scriptgroup name %s", buffer.get()); } + if (log) + log->Printf("Extracted scriptgroup name %s", buffer.get()); + // write back the script group name group_name.SetCString(buffer.get()); } @@ -1634,11 +1635,10 @@ "with symbol '%s'.", __FUNCTION__, hook_defn->name, symbol_name); continue; - } else { - if (log) - log->Printf("%s - function %s, address resolved at 0x%" PRIx64, - __FUNCTION__, hook_defn->name, addr); } + if (log) + log->Printf("%s - function %s, address resolved at 0x%" PRIx64, + __FUNCTION__, hook_defn->name, addr); RuntimeHookSP hook(new RuntimeHook()); hook->address = addr; @@ -1901,7 +1901,8 @@ if (log) log->Printf("%s - encoding error in snprintf().", __FUNCTION__); return false; - } else if (written >= jit_max_expr_size) { + } + if (written >= jit_max_expr_size) { if (log) log->Printf("%s - expression too long.", __FUNCTION__); return false; @@ -1939,7 +1940,8 @@ if (log) log->Printf("%s - encoding error in snprintf().", __FUNCTION__); return false; - } else if (written >= jit_max_expr_size) { + } + if (written >= jit_max_expr_size) { if (log) log->Printf("%s - expression too long.", __FUNCTION__); return false; @@ -1989,7 +1991,8 @@ if (log) log->Printf("%s - encoding error in snprintf().", __FUNCTION__); return false; - } else if (written >= jit_max_expr_size) { + } + if (written >= jit_max_expr_size) { if (log) log->Printf("%s - expression too long.", __FUNCTION__); return false; @@ -2048,7 +2051,8 @@ if (log) log->Printf("%s - encoding error in snprintf().", __FUNCTION__); return false; - } else if (written >= jit_max_expr_size) { + } + if (written >= jit_max_expr_size) { if (log) log->Printf("%s - expression too long.", __FUNCTION__); return false; @@ -2115,7 +2119,8 @@ if (log) log->Printf("%s - encoding error in snprintf().", __FUNCTION__); return false; - } else if (written >= jit_max_expr_size) { + } + if (written >= jit_max_expr_size) { if (log) log->Printf("%s - expression too long.", __FUNCTION__); return false; @@ -2221,7 +2226,8 @@ if (log) log->Printf("%s - encoding error in snprintf().", __FUNCTION__); return false; - } else if (written >= jit_max_expr_size) { + } + if (written >= jit_max_expr_size) { if (log) log->Printf("%s - expression too long.", __FUNCTION__); return false; @@ -2261,7 +2267,8 @@ if (log) log->Printf("%s - encoding error in snprintf().", __FUNCTION__); return false; - } else if (written >= jit_max_expr_size) { + } + if (written >= jit_max_expr_size) { if (log) log->Printf("%s - expression too long.", __FUNCTION__); return false; @@ -2315,9 +2322,9 @@ if (!elem.type_name.IsEmpty()) // Name already set return; - else - elem.type_name = Element::GetFallbackStructName(); // Default type name if - // we don't succeed + + elem.type_name = Element::GetFallbackStructName(); // Default type name if + // we don't succeed // Find all the global variables from the script rs modules VariableList var_list; @@ -2987,7 +2994,8 @@ log->Error("Error parsing RenderScript reduction spec. wrong number " "of fields"); return false; - } else if (log) + } + if (log) log->Warning("Extraneous members in reduction spec: '%s'", lines->str().c_str()); } @@ -4937,10 +4945,9 @@ if (success) { result.SetStatus(eReturnStatusSuccessFinishResult); return true; - } else { - result.SetStatus(eReturnStatusFailed); - return false; } + result.SetStatus(eReturnStatusFailed); + return false; } }; Index: source/Plugins/ObjectContainer/BSD-Archive/ObjectContainerBSDArchive.cpp =================================================================== --- source/Plugins/ObjectContainer/BSD-Archive/ObjectContainerBSDArchive.cpp +++ source/Plugins/ObjectContainer/BSD-Archive/ObjectContainerBSDArchive.cpp @@ -215,19 +215,18 @@ if (match) { if (pos->second->GetModificationTime() == time) { return pos->second; - } else { - // We have a file at the same path with the same architecture whose - // modification time doesn't match. It doesn't make sense for us to - // continue to use this BSD archive since we cache only the object info - // which consists of file time info and also the file offset and file - // size of any contained objects. Since this information is now out of - // date, we won't get the correct information if we go and extract the - // file data, so we should remove the old and outdated entry. - archive_map.erase(pos); - pos = archive_map.find(file); - continue; // Continue to next iteration so we don't increment pos - // below... } + // We have a file at the same path with the same architecture whose + // modification time doesn't match. It doesn't make sense for us to + // continue to use this BSD archive since we cache only the object info + // which consists of file time info and also the file offset and file + // size of any contained objects. Since this information is now out of + // date, we won't get the correct information if we go and extract the + // file data, so we should remove the old and outdated entry. + archive_map.erase(pos); + pos = archive_map.find(file); + continue; // Continue to next iteration so we don't increment pos + // below... } ++pos; } @@ -331,7 +330,8 @@ // We already have this archive in our cache, use it container_ap->SetArchive(archive_sp); return container_ap.release(); - } else if (container_ap->ParseHeader()) + } + if (container_ap->ParseHeader()) return container_ap.release(); } } Index: source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp =================================================================== --- source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp +++ source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp @@ -174,64 +174,64 @@ lldb::offset_t *offset) { if (reloc.is()) return reloc.get()->Parse(data, offset); - else - return reloc.get()->Parse(data, offset); + + return reloc.get()->Parse(data, offset); } unsigned ELFRelocation::RelocType32(const ELFRelocation &rel) { if (rel.reloc.is()) return ELFRel::RelocType32(*rel.reloc.get()); - else - return ELFRela::RelocType32(*rel.reloc.get()); + + return ELFRela::RelocType32(*rel.reloc.get()); } unsigned ELFRelocation::RelocType64(const ELFRelocation &rel) { if (rel.reloc.is()) return ELFRel::RelocType64(*rel.reloc.get()); - else - return ELFRela::RelocType64(*rel.reloc.get()); + + return ELFRela::RelocType64(*rel.reloc.get()); } unsigned ELFRelocation::RelocSymbol32(const ELFRelocation &rel) { if (rel.reloc.is()) return ELFRel::RelocSymbol32(*rel.reloc.get()); - else - return ELFRela::RelocSymbol32(*rel.reloc.get()); + + return ELFRela::RelocSymbol32(*rel.reloc.get()); } unsigned ELFRelocation::RelocSymbol64(const ELFRelocation &rel) { if (rel.reloc.is()) return ELFRel::RelocSymbol64(*rel.reloc.get()); - else - return ELFRela::RelocSymbol64(*rel.reloc.get()); + + return ELFRela::RelocSymbol64(*rel.reloc.get()); } unsigned ELFRelocation::RelocOffset32(const ELFRelocation &rel) { if (rel.reloc.is()) return rel.reloc.get()->r_offset; - else - return rel.reloc.get()->r_offset; + + return rel.reloc.get()->r_offset; } unsigned ELFRelocation::RelocOffset64(const ELFRelocation &rel) { if (rel.reloc.is()) return rel.reloc.get()->r_offset; - else - return rel.reloc.get()->r_offset; + + return rel.reloc.get()->r_offset; } unsigned ELFRelocation::RelocAddend32(const ELFRelocation &rel) { if (rel.reloc.is()) return 0; - else - return rel.reloc.get()->r_addend; + + return rel.reloc.get()->r_addend; } unsigned ELFRelocation::RelocAddend64(const ELFRelocation &rel) { if (rel.reloc.is()) return 0; - else - return rel.reloc.get()->r_addend; + + return rel.reloc.get()->r_addend; } } // end anonymous namespace @@ -917,7 +917,8 @@ // We have the full build id uuid. *uuid = m_uuid; return true; - } else if (GetType() == ObjectFile::eTypeCoreFile) { + } + if (GetType() == ObjectFile::eTypeCoreFile) { uint32_t core_notes_crc = 0; if (!ParseProgramHeaders()) @@ -1004,9 +1005,9 @@ } // MIPS executables uses DT_MIPS_RLD_MAP_REL to support PIE. DT_MIPS_RLD_MAP // exists in non-PIE. - else if ((symbol.d_tag == DT_MIPS_RLD_MAP || - symbol.d_tag == DT_MIPS_RLD_MAP_REL) && - target) { + if ((symbol.d_tag == DT_MIPS_RLD_MAP || + symbol.d_tag == DT_MIPS_RLD_MAP_REL) && + target) { addr_t offset = i * dynsym_hdr->sh_entsize + GetAddressByteSize(); addr_t dyn_base = dynsym_section_sp->GetLoadBaseAddress(target); if (dyn_base == LLDB_INVALID_ADDRESS) Index: source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp =================================================================== --- source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp +++ source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp @@ -1047,9 +1047,9 @@ if (is_64_bit) *data_offset_ptr += 4; return true; - } else { - memset(&header, 0, sizeof(header)); } + memset(&header, 0, sizeof(header)); + return false; } @@ -1938,9 +1938,9 @@ if (m_section_infos[n_sect].vm_range.Contains(file_addr)) { // Symbol is in section. return m_section_infos[n_sect].section_sp; - } else if (m_section_infos[n_sect].vm_range.GetByteSize() == 0 && - m_section_infos[n_sect].vm_range.GetBaseAddress() == - file_addr) { + } + if (m_section_infos[n_sect].vm_range.GetByteSize() == 0 && + m_section_infos[n_sect].vm_range.GetBaseAddress() == file_addr) { // Symbol is in section with zero size, but has the same start address // as the section. This can happen with linker symbols (symbols that // start with the letter 'l' or 'L'. @@ -4986,41 +4986,41 @@ triple.setVendorName(llvm::StringRef()); } return true; - } else { - struct load_command load_cmd; - llvm::SmallString<16> os_name; - llvm::raw_svector_ostream os(os_name); + } + struct load_command load_cmd; + llvm::SmallString<16> os_name; + llvm::raw_svector_ostream os(os_name); - // See if there is an LC_VERSION_MIN_* load command that can give - // us the OS type. - lldb::offset_t offset = lc_offset; - for (uint32_t i = 0; i < header.ncmds; ++i) { - const lldb::offset_t cmd_offset = offset; - if (data.GetU32(&offset, &load_cmd, 2) == NULL) - break; + // See if there is an LC_VERSION_MIN_* load command that can give + // us the OS type. + lldb::offset_t offset = lc_offset; + for (uint32_t i = 0; i < header.ncmds; ++i) { + const lldb::offset_t cmd_offset = offset; + if (data.GetU32(&offset, &load_cmd, 2) == NULL) + break; - struct version_min_command version_min; - switch (load_cmd.cmd) { - case llvm::MachO::LC_VERSION_MIN_IPHONEOS: - case llvm::MachO::LC_VERSION_MIN_MACOSX: - case llvm::MachO::LC_VERSION_MIN_TVOS: - case llvm::MachO::LC_VERSION_MIN_WATCHOS: { - if (load_cmd.cmdsize != sizeof(version_min)) - break; - if (data.ExtractBytes(cmd_offset, sizeof(version_min), - data.GetByteOrder(), &version_min) == 0) - break; - MinOS min_os(version_min.version); - os << GetOSName(load_cmd.cmd) << min_os.major_version << '.' - << min_os.minor_version << '.' << min_os.patch_version; - triple.setOSName(os.str()); - return true; - } - default: + struct version_min_command version_min; + switch (load_cmd.cmd) { + case llvm::MachO::LC_VERSION_MIN_IPHONEOS: + case llvm::MachO::LC_VERSION_MIN_MACOSX: + case llvm::MachO::LC_VERSION_MIN_TVOS: + case llvm::MachO::LC_VERSION_MIN_WATCHOS: { + if (load_cmd.cmdsize != sizeof(version_min)) break; - } + if (data.ExtractBytes(cmd_offset, sizeof(version_min), + data.GetByteOrder(), &version_min) == 0) + break; + MinOS min_os(version_min.version); + os << GetOSName(load_cmd.cmd) << min_os.major_version << '.' + << min_os.minor_version << '.' << min_os.patch_version; + triple.setOSName(os.str()); + return true; + } + default: + break; + } - offset = cmd_offset + load_cmd.cmdsize; + offset = cmd_offset + load_cmd.cmdsize; } // See if there is an LC_BUILD_VERSION load command that can give @@ -5063,7 +5063,6 @@ triple.setVendor(llvm::Triple::UnknownVendor); triple.setVendorName(llvm::StringRef()); } - } } return arch.IsValid(); } Index: source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp =================================================================== --- source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp +++ source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp @@ -299,7 +299,7 @@ uint32_t ObjectFilePECOFF::GetAddressByteSize() const { if (m_coff_header_opt.magic == OPT_HEADER_MAGIC_PE32_PLUS) return 8; - else if (m_coff_header_opt.magic == OPT_HEADER_MAGIC_PE32) + if (m_coff_header_opt.magic == OPT_HEADER_MAGIC_PE32) return 4; return 4; } @@ -1172,8 +1172,8 @@ if (m_coff_header.machine != 0) { if ((m_coff_header.flags & llvm::COFF::IMAGE_FILE_DLL) == 0) return eTypeExecutable; - else - return eTypeSharedLibrary; + + return eTypeSharedLibrary; } return eTypeExecutable; } Index: source/Plugins/Platform/Android/AdbClient.cpp =================================================================== --- source/Plugins/Platform/Android/AdbClient.cpp +++ source/Plugins/Platform/Android/AdbClient.cpp @@ -499,7 +499,8 @@ if (error.Fail()) return Status("Failed to read DONE error message: %s", error.AsCString()); return Status("Failed to push file: %s", error_message.c_str()); - } else if (response_id != kOKAY) + } + if (response_id != kOKAY) return Status("Got unexpected DONE response: %s", response_id.c_str()); // If there was an error reading the source file, finish the adb file Index: source/Plugins/Platform/Android/PlatformAndroid.cpp =================================================================== --- source/Plugins/Platform/Android/PlatformAndroid.cpp +++ source/Plugins/Platform/Android/PlatformAndroid.cpp @@ -137,17 +137,16 @@ if (is_host) { static ConstString g_host_name(Platform::GetHostPlatformName()); return g_host_name; - } else { - static ConstString g_remote_name("remote-android"); - return g_remote_name; } + static ConstString g_remote_name("remote-android"); + return g_remote_name; } const char *PlatformAndroid::GetPluginDescriptionStatic(bool is_host) { if (is_host) return "Local Android user platform plug-in."; - else - return "Remote Android user platform plug-in."; + + return "Remote Android user platform plug-in."; } ConstString PlatformAndroid::GetPluginName() { Index: source/Plugins/Platform/FreeBSD/PlatformFreeBSD.cpp =================================================================== --- source/Plugins/Platform/FreeBSD/PlatformFreeBSD.cpp +++ source/Plugins/Platform/FreeBSD/PlatformFreeBSD.cpp @@ -77,17 +77,16 @@ if (is_host) { static ConstString g_host_name(Platform::GetHostPlatformName()); return g_host_name; - } else { - static ConstString g_remote_name("remote-freebsd"); - return g_remote_name; } + static ConstString g_remote_name("remote-freebsd"); + return g_remote_name; } const char *PlatformFreeBSD::GetPluginDescriptionStatic(bool is_host) { if (is_host) return "Local FreeBSD user platform plug-in."; - else - return "Remote FreeBSD user platform plug-in."; + + return "Remote FreeBSD user platform plug-in."; } ConstString PlatformFreeBSD::GetPluginName() { @@ -137,7 +136,8 @@ if (idx == 0) { arch = hostArch; return arch.IsValid(); - } else if (idx == 1) { + } + if (idx == 1) { // If the default host architecture is 64-bit, look for a 32-bit // variant if (hostArch.IsValid() && hostArch.GetTriple().isArch64Bit()) { Index: source/Plugins/Platform/Linux/PlatformLinux.cpp =================================================================== --- source/Plugins/Platform/Linux/PlatformLinux.cpp +++ source/Plugins/Platform/Linux/PlatformLinux.cpp @@ -76,17 +76,16 @@ if (is_host) { static ConstString g_host_name(Platform::GetHostPlatformName()); return g_host_name; - } else { - static ConstString g_remote_name("remote-linux"); - return g_remote_name; } + static ConstString g_remote_name("remote-linux"); + return g_remote_name; } const char *PlatformLinux::GetPluginDescriptionStatic(bool is_host) { if (is_host) return "Local Linux user platform plug-in."; - else - return "Remote Linux user platform plug-in."; + + return "Remote Linux user platform plug-in."; } ConstString PlatformLinux::GetPluginName() { @@ -136,7 +135,8 @@ if (idx == 0) { arch = hostArch; return arch.IsValid(); - } else if (idx == 1) { + } + if (idx == 1) { // If the default host architecture is 64-bit, look for a 32-bit // variant if (hostArch.IsValid() && hostArch.GetTriple().isArch64Bit()) { @@ -258,10 +258,9 @@ bool PlatformLinux::CanDebugProcess() { if (IsHost()) { return true; - } else { - // If we're connected, we can debug. - return IsConnected(); } + // If we're connected, we can debug. + return IsConnected(); } // For local debugging, Linux will override the debug logic to use llgs-launch Index: source/Plugins/Platform/MacOSX/PlatformAppleSimulator.cpp =================================================================== --- source/Plugins/Platform/MacOSX/PlatformAppleSimulator.cpp +++ source/Plugins/Platform/MacOSX/PlatformAppleSimulator.cpp @@ -69,8 +69,8 @@ if (spawned) { launch_info.SetProcessID(spawned.GetPID()); return Status(); - } else - return spawned.GetError(); + } + return spawned.GetError(); #else Status err; err.SetErrorString(UNSUPPORTED_ERROR); @@ -138,9 +138,8 @@ if (arg_str == device.GetUDID() || arg_str == device.GetName()) { m_device = device; return false; // Stop iterating - } else { - return true; // Keep iterating } + return true; // Keep iterating }); if (!m_device) error.SetErrorStringWithFormat( @@ -259,7 +258,7 @@ if (m_device.hasValue()) return m_device.getValue(); - else - return CoreSimulatorSupport::Device(); + + return CoreSimulatorSupport::Device(); } #endif Index: source/Plugins/Platform/MacOSX/PlatformAppleTVSimulator.cpp =================================================================== --- source/Plugins/Platform/MacOSX/PlatformAppleTVSimulator.cpp +++ source/Plugins/Platform/MacOSX/PlatformAppleTVSimulator.cpp @@ -213,8 +213,8 @@ if (error.Success()) { if (exe_module_sp && exe_module_sp->GetObjectFile()) break; - else - error.SetErrorToGenericError(); + + error.SetErrorToGenericError(); } if (idx > 0) Index: source/Plugins/Platform/MacOSX/PlatformAppleWatchSimulator.cpp =================================================================== --- source/Plugins/Platform/MacOSX/PlatformAppleWatchSimulator.cpp +++ source/Plugins/Platform/MacOSX/PlatformAppleWatchSimulator.cpp @@ -213,8 +213,8 @@ if (error.Success()) { if (exe_module_sp && exe_module_sp->GetObjectFile()) break; - else - error.SetErrorToGenericError(); + + error.SetErrorToGenericError(); } if (idx > 0) Index: source/Plugins/Platform/MacOSX/PlatformDarwin.cpp =================================================================== --- source/Plugins/Platform/MacOSX/PlatformDarwin.cpp +++ source/Plugins/Platform/MacOSX/PlatformDarwin.cpp @@ -332,8 +332,8 @@ module_sp.reset(new Module(local_spec)); module_sp->SetPlatformFileSpec(module_spec.GetFileSpec()); return Status(); - } else - return Status("unable to obtain valid module file"); + } + return Status("unable to obtain valid module file"); } else return Status("no cache path"); } else @@ -491,8 +491,8 @@ ObjectFile::Type obj_type = obj_file->GetType(); if (obj_type == ObjectFile::eTypeDynamicLinker) return true; - else - return false; + + return false; } bool PlatformDarwin::x86GetSupportedArchitectureAtIndex(uint32_t idx, @@ -519,7 +519,8 @@ if (idx == 0) { arch = HostInfo::GetArchitecture(HostInfo::eArchKindDefault); return arch.IsValid(); - } else if (idx == 1) { + } + if (idx == 1) { ArchSpec platform_arch( HostInfo::GetArchitecture(HostInfo::eArchKindDefault)); ArchSpec platform_arch64( @@ -1265,9 +1266,9 @@ if (launch_info.GetEnvironment().lookup("COMMAND_MODE") == "legacy") return 2; return 1; - } else if (strcmp(shell_name, "csh") == 0 || - strcmp(shell_name, "tcsh") == 0 || - strcmp(shell_name, "zsh") == 0) { + } + if (strcmp(shell_name, "csh") == 0 || strcmp(shell_name, "tcsh") == 0 || + strcmp(shell_name, "zsh") == 0) { // csh and tcsh always seem to re-exec themselves. return 2; } else @@ -1436,8 +1437,8 @@ if (FileSystem::Instance().IsDirectory(enumerator_info.found_path)) return enumerator_info.found_path; - else - return FileSpec(); + + return FileSpec(); } FileSpec PlatformDarwin::GetSDKDirectoryForModules(SDKType sdk_type) { Index: source/Plugins/Platform/MacOSX/PlatformDarwinKernel.cpp =================================================================== --- source/Plugins/Platform/MacOSX/PlatformDarwinKernel.cpp +++ source/Plugins/Platform/MacOSX/PlatformDarwinKernel.cpp @@ -566,9 +566,8 @@ if (log_verbose) log_verbose->Printf ("PlatformDarwinKernel descending into directory '%s'", file_spec.GetPath().c_str()); return FileSystem::eEnumerateDirectoryResultEnter; - } else { - return FileSystem::eEnumerateDirectoryResultNext; } + return FileSystem::eEnumerateDirectoryResultNext; } void PlatformDarwinKernel::AddKextToMap(PlatformDarwinKernel *thisp, @@ -731,16 +730,15 @@ process->GetTarget().GetImages().AppendIfNeeded(module_sp); error.Clear(); return error; - } else { - error = ModuleList::GetSharedModule(kern_spec, module_sp, NULL, - NULL, NULL); - if (module_sp && module_sp->GetObjectFile() && - module_sp->GetObjectFile()->GetType() != - ObjectFile::Type::eTypeCoreFile) { - return error; + } + error = ModuleList::GetSharedModule(kern_spec, module_sp, NULL, NULL, + NULL); + if (module_sp && module_sp->GetObjectFile() && + module_sp->GetObjectFile()->GetType() != + ObjectFile::Type::eTypeCoreFile) { + return error; } module_sp.reset(); - } } } } @@ -767,16 +765,15 @@ process->GetTarget().GetImages().AppendIfNeeded(module_sp); error.Clear(); return error; - } else { - error = ModuleList::GetSharedModule(kern_spec, module_sp, NULL, - NULL, NULL); - if (module_sp && module_sp->GetObjectFile() && - module_sp->GetObjectFile()->GetType() != - ObjectFile::Type::eTypeCoreFile) { - return error; + } + error = ModuleList::GetSharedModule(kern_spec, module_sp, NULL, NULL, + NULL); + if (module_sp && module_sp->GetObjectFile() && + module_sp->GetObjectFile()->GetType() != + ObjectFile::Type::eTypeCoreFile) { + return error; } module_sp.reset(); - } } } } Index: source/Plugins/Platform/MacOSX/PlatformMacOSX.cpp =================================================================== --- source/Plugins/Platform/MacOSX/PlatformMacOSX.cpp +++ source/Plugins/Platform/MacOSX/PlatformMacOSX.cpp @@ -134,17 +134,16 @@ if (is_host) { static ConstString g_host_name(Platform::GetHostPlatformName()); return g_host_name; - } else { - static ConstString g_remote_name("remote-macosx"); - return g_remote_name; } + static ConstString g_remote_name("remote-macosx"); + return g_remote_name; } const char *PlatformMacOSX::GetDescriptionStatic(bool is_host) { if (is_host) return "Local Mac OS X user platform plug-in."; - else - return "Remote Mac OS X user platform plug-in."; + + return "Remote Mac OS X user platform plug-in."; } //------------------------------------------------------------------ @@ -260,15 +259,15 @@ // same OS version: the local file is good enough local_file = platform_file; return Status(); - } else { - // try to find the file in the cache - std::string cache_path(GetLocalCacheDirectory()); - std::string module_path(platform_file.GetPath()); - cache_path.append(module_path); - FileSpec module_cache_spec(cache_path); - if (FileSystem::Instance().Exists(module_cache_spec)) { - local_file = module_cache_spec; - return Status(); + } + // try to find the file in the cache + std::string cache_path(GetLocalCacheDirectory()); + std::string module_path(platform_file.GetPath()); + cache_path.append(module_path); + FileSpec module_cache_spec(cache_path); + if (FileSystem::Instance().Exists(module_cache_spec)) { + local_file = module_cache_spec; + return Status(); } // bring in the remote module file FileSpec module_cache_folder = @@ -284,9 +283,8 @@ if (FileSystem::Instance().Exists(module_cache_spec)) { local_file = module_cache_spec; return Status(); - } else - return Status("unable to obtain valid module file"); - } + } + return Status("unable to obtain valid module file"); } local_file = platform_file; return Status(); Index: source/Plugins/Platform/MacOSX/PlatformRemoteDarwinDevice.cpp =================================================================== --- source/Plugins/Platform/MacOSX/PlatformRemoteDarwinDevice.cpp +++ source/Plugins/Platform/MacOSX/PlatformRemoteDarwinDevice.cpp @@ -105,8 +105,8 @@ if (error.Success()) { if (exe_module_sp && exe_module_sp->GetObjectFile()) break; - else - error.SetErrorToGenericError(); + + error.SetErrorToGenericError(); } if (idx > 0) Index: source/Plugins/Platform/MacOSX/PlatformiOSSimulator.cpp =================================================================== --- source/Plugins/Platform/MacOSX/PlatformiOSSimulator.cpp +++ source/Plugins/Platform/MacOSX/PlatformiOSSimulator.cpp @@ -219,8 +219,8 @@ if (error.Success()) { if (exe_module_sp && exe_module_sp->GetObjectFile()) break; - else - error.SetErrorToGenericError(); + + error.SetErrorToGenericError(); } if (idx > 0) @@ -402,7 +402,8 @@ // 32/64: return "x86_64-apple-macosx" for architecture 1 arch = platform_arch64; return true; - } else if (idx == 2 || idx == 3) { + } + if (idx == 2 || idx == 3) { arch = HostInfo::GetArchitecture(HostInfo::eArchKind32); if (arch.IsValid()) { if (idx == 2) Index: source/Plugins/Platform/MacOSX/objcxx/PlatformiOSSimulatorCoreSimulatorSupport.mm =================================================================== --- source/Plugins/Platform/MacOSX/objcxx/PlatformiOSSimulatorCoreSimulatorSupport.mm +++ source/Plugins/Platform/MacOSX/objcxx/PlatformiOSSimulatorCoreSimulatorSupport.mm @@ -134,9 +134,8 @@ m_family.clear(); m_versions.clear(); return; - } else { - m_family.push_back(c); } + m_family.push_back(c); } } @@ -180,8 +179,8 @@ if (m_model_identifier.hasValue()) return m_model_identifier.getValue(); - else - return ModelIdentifier(); + + return ModelIdentifier(); } CoreSimulatorSupport::OSVersion @@ -218,8 +217,8 @@ auto utf8_udid = [[[m_dev UDID] UUIDString] UTF8String]; if (utf8_udid) return std::string(utf8_udid); - else - return std::string(); + + return std::string(); } CoreSimulatorSupport::DeviceType CoreSimulatorSupport::Device::GetDeviceType() { @@ -364,10 +363,9 @@ if ([m_dev bootWithOptions:options error:&nserror]) { err.Clear(); return true; - } else { - err.SetErrorString([[nserror description] UTF8String]); - return false; } + err.SetErrorString([[nserror description] UTF8String]); + return false; } bool CoreSimulatorSupport::Device::Shutdown(Status &err) { @@ -375,10 +373,9 @@ if ([m_dev shutdownWithError:&nserror]) { err.Clear(); return true; - } else { - err.SetErrorString([[nserror description] UTF8String]); - return false; } + err.SetErrorString([[nserror description] UTF8String]); + return false; } static Status HandleFileAction(ProcessLaunchInfo &launch_info, @@ -433,12 +430,11 @@ file.SetDescriptor(created_fd, true); [options setValue:[NSNumber numberWithInteger:created_fd] forKey:key]; return error; // Success - } else { - posix_error.SetErrorToErrno(); - error.SetErrorStringWithFormat("unable to open file '%s': %s", - file_spec.GetPath().c_str(), - posix_error.AsCString()); } + posix_error.SetErrorToErrno(); + error.SetErrorStringWithFormat("unable to open file '%s': %s", + file_spec.GetPath().c_str(), + posix_error.AsCString()); } } break; } Index: source/Plugins/Platform/NetBSD/PlatformNetBSD.cpp =================================================================== --- source/Plugins/Platform/NetBSD/PlatformNetBSD.cpp +++ source/Plugins/Platform/NetBSD/PlatformNetBSD.cpp @@ -69,17 +69,16 @@ if (is_host) { static ConstString g_host_name(Platform::GetHostPlatformName()); return g_host_name; - } else { - static ConstString g_remote_name("remote-netbsd"); - return g_remote_name; } + static ConstString g_remote_name("remote-netbsd"); + return g_remote_name; } const char *PlatformNetBSD::GetPluginDescriptionStatic(bool is_host) { if (is_host) return "Local NetBSD user platform plug-in."; - else - return "Remote NetBSD user platform plug-in."; + + return "Remote NetBSD user platform plug-in."; } ConstString PlatformNetBSD::GetPluginName() { @@ -129,7 +128,8 @@ if (idx == 0) { arch = hostArch; return arch.IsValid(); - } else if (idx == 1) { + } + if (idx == 1) { // If the default host architecture is 64-bit, look for a 32-bit // variant if (hostArch.IsValid() && hostArch.GetTriple().isArch64Bit()) { @@ -227,10 +227,9 @@ bool PlatformNetBSD::CanDebugProcess() { if (IsHost()) { return true; - } else { - // If we're connected, we can debug. - return IsConnected(); } + // If we're connected, we can debug. + return IsConnected(); } // For local debugging, NetBSD will override the debug logic to use llgs-launch Index: source/Plugins/Platform/OpenBSD/PlatformOpenBSD.cpp =================================================================== --- source/Plugins/Platform/OpenBSD/PlatformOpenBSD.cpp +++ source/Plugins/Platform/OpenBSD/PlatformOpenBSD.cpp @@ -75,17 +75,16 @@ if (is_host) { static ConstString g_host_name(Platform::GetHostPlatformName()); return g_host_name; - } else { - static ConstString g_remote_name("remote-openbsd"); - return g_remote_name; } + static ConstString g_remote_name("remote-openbsd"); + return g_remote_name; } const char *PlatformOpenBSD::GetPluginDescriptionStatic(bool is_host) { if (is_host) return "Local OpenBSD user platform plug-in."; - else - return "Remote OpenBSD user platform plug-in."; + + return "Remote OpenBSD user platform plug-in."; } ConstString PlatformOpenBSD::GetPluginName() { Index: source/Plugins/Platform/POSIX/PlatformPOSIX.cpp =================================================================== --- source/Plugins/Platform/POSIX/PlatformPOSIX.cpp +++ source/Plugins/Platform/POSIX/PlatformPOSIX.cpp @@ -84,7 +84,7 @@ bool PlatformPOSIX::IsConnected() const { if (IsHost()) return true; - else if (m_remote_platform_sp) + if (m_remote_platform_sp) return m_remote_platform_sp->IsConnected(); return false; } @@ -102,13 +102,12 @@ if (IsHost()) return Host::RunShellCommand(command, working_dir, status_ptr, signo_ptr, command_output, timeout); - else { - if (m_remote_platform_sp) - return m_remote_platform_sp->RunShellCommand( - command, working_dir, status_ptr, signo_ptr, command_output, timeout); - else - return Status("unable to run a remote command without a platform"); - } + + if (m_remote_platform_sp) + return m_remote_platform_sp->RunShellCommand( + command, working_dir, status_ptr, signo_ptr, command_output, timeout); + + return Status("unable to run a remote command without a platform"); } Status @@ -224,8 +223,8 @@ if (error.Success()) { if (exe_module_sp && exe_module_sp->GetObjectFile()) break; - else - error.SetErrorToGenericError(); + + error.SetErrorToGenericError(); } if (idx > 0) @@ -289,8 +288,8 @@ uint32_t file_permissions) { if (m_remote_platform_sp) return m_remote_platform_sp->MakeDirectory(file_spec, file_permissions); - else - return Platform::MakeDirectory(file_spec, file_permissions); + + return Platform::MakeDirectory(file_spec, file_permissions); } Status PlatformPOSIX::GetFilePermissions(const FileSpec &file_spec, @@ -298,8 +297,8 @@ if (m_remote_platform_sp) return m_remote_platform_sp->GetFilePermissions(file_spec, file_permissions); - else - return Platform::GetFilePermissions(file_spec, file_permissions); + + return Platform::GetFilePermissions(file_spec, file_permissions); } Status PlatformPOSIX::SetFilePermissions(const FileSpec &file_spec, @@ -307,8 +306,8 @@ if (m_remote_platform_sp) return m_remote_platform_sp->SetFilePermissions(file_spec, file_permissions); - else - return Platform::SetFilePermissions(file_spec, file_permissions); + + return Platform::SetFilePermissions(file_spec, file_permissions); } lldb::user_id_t PlatformPOSIX::OpenFile(const FileSpec &file_spec, @@ -316,7 +315,7 @@ Status &error) { if (IsHost()) return FileCache::GetInstance().OpenFile(file_spec, flags, mode, error); - else if (m_remote_platform_sp) + if (m_remote_platform_sp) return m_remote_platform_sp->OpenFile(file_spec, flags, mode, error); else return Platform::OpenFile(file_spec, flags, mode, error); @@ -325,7 +324,7 @@ bool PlatformPOSIX::CloseFile(lldb::user_id_t fd, Status &error) { if (IsHost()) return FileCache::GetInstance().CloseFile(fd, error); - else if (m_remote_platform_sp) + if (m_remote_platform_sp) return m_remote_platform_sp->CloseFile(fd, error); else return Platform::CloseFile(fd, error); @@ -335,7 +334,7 @@ uint64_t dst_len, Status &error) { if (IsHost()) return FileCache::GetInstance().ReadFile(fd, offset, dst, dst_len, error); - else if (m_remote_platform_sp) + if (m_remote_platform_sp) return m_remote_platform_sp->ReadFile(fd, offset, dst, dst_len, error); else return Platform::ReadFile(fd, offset, dst, dst_len, error); @@ -346,7 +345,7 @@ Status &error) { if (IsHost()) return FileCache::GetInstance().WriteFile(fd, offset, src, src_len, error); - else if (m_remote_platform_sp) + if (m_remote_platform_sp) return m_remote_platform_sp->WriteFile(fd, offset, src, src_len, error); else return Platform::WriteFile(fd, offset, src, src_len, error); @@ -403,7 +402,8 @@ if (chown_file(this, dst_path.c_str(), uid, gid) != 0) return Status("unable to perform chown"); return Status(); - } else if (m_remote_platform_sp) { + } + if (m_remote_platform_sp) { if (GetSupportsRSync()) { std::string src_path(source.GetPath()); if (src_path.empty()) @@ -446,7 +446,8 @@ if (llvm::sys::fs::file_size(file_spec.GetPath(), Size)) return 0; return Size; - } else if (m_remote_platform_sp) + } + if (m_remote_platform_sp) return m_remote_platform_sp->GetFileSize(file_spec); else return Platform::GetFileSize(file_spec); @@ -455,7 +456,7 @@ Status PlatformPOSIX::CreateSymlink(const FileSpec &src, const FileSpec &dst) { if (IsHost()) return FileSystem::Instance().Symlink(src, dst); - else if (m_remote_platform_sp) + if (m_remote_platform_sp) return m_remote_platform_sp->CreateSymlink(src, dst); else return Platform::CreateSymlink(src, dst); @@ -464,7 +465,7 @@ bool PlatformPOSIX::GetFileExists(const FileSpec &file_spec) { if (IsHost()) return FileSystem::Instance().Exists(file_spec); - else if (m_remote_platform_sp) + if (m_remote_platform_sp) return m_remote_platform_sp->GetFileExists(file_spec); else return Platform::GetFileExists(file_spec); @@ -473,7 +474,7 @@ Status PlatformPOSIX::Unlink(const FileSpec &file_spec) { if (IsHost()) return llvm::sys::fs::remove(file_spec.GetPath()); - else if (m_remote_platform_sp) + if (m_remote_platform_sp) return m_remote_platform_sp->Unlink(file_spec); else return Platform::Unlink(file_spec); @@ -505,7 +506,8 @@ if (status != 0) return Status("unable to perform copy"); return Status(); - } else if (m_remote_platform_sp) { + } + if (m_remote_platform_sp) { if (GetSupportsRSync()) { StreamString command; if (GetIgnoresRemoteHostname()) { @@ -618,8 +620,8 @@ stream.Printf("cache dir: %s", GetLocalCacheDirectory()); if (stream.GetSize()) return stream.GetString(); - else - return ""; + + return ""; } bool PlatformPOSIX::CalculateMD5(const FileSpec &file_spec, uint64_t &low, @@ -640,15 +642,15 @@ FileSpec PlatformPOSIX::GetRemoteWorkingDirectory() { if (IsRemote() && m_remote_platform_sp) return m_remote_platform_sp->GetRemoteWorkingDirectory(); - else - return Platform::GetRemoteWorkingDirectory(); + + return Platform::GetRemoteWorkingDirectory(); } bool PlatformPOSIX::SetRemoteWorkingDirectory(const FileSpec &working_dir) { if (IsRemote() && m_remote_platform_sp) return m_remote_platform_sp->SetRemoteWorkingDirectory(working_dir); - else - return Platform::SetRemoteWorkingDirectory(working_dir); + + return Platform::SetRemoteWorkingDirectory(working_dir); } bool PlatformPOSIX::GetRemoteOSVersion() { Index: source/Plugins/Platform/Windows/PlatformWindows.cpp =================================================================== --- source/Plugins/Platform/Windows/PlatformWindows.cpp +++ source/Plugins/Platform/Windows/PlatformWindows.cpp @@ -106,10 +106,9 @@ if (is_host) { static ConstString g_host_name(Platform::GetHostPlatformName()); return g_host_name; - } else { - static ConstString g_remote_name("remote-windows"); - return g_remote_name; } + static ConstString g_remote_name("remote-windows"); + return g_remote_name; } const char *PlatformWindows::GetPluginDescriptionStatic(bool is_host) { @@ -249,8 +248,8 @@ if (error.Success()) { if (exe_module_sp && exe_module_sp->GetObjectFile()) break; - else - error.SetErrorToGenericError(); + + error.SetErrorToGenericError(); } if (idx > 0) @@ -319,7 +318,7 @@ bool PlatformWindows::IsConnected() const { if (IsHost()) return true; - else if (m_remote_platform_sp) + if (m_remote_platform_sp) return m_remote_platform_sp->IsConnected(); return false; } @@ -436,18 +435,17 @@ // This is a process attach. Don't need to launch anything. ProcessAttachInfo attach_info(launch_info); return Attach(attach_info, debugger, target, error); - } else { - ProcessSP process_sp = - target->CreateProcess(launch_info.GetListenerForProcess(debugger), - launch_info.GetProcessPluginName(), nullptr); + } + ProcessSP process_sp = + target->CreateProcess(launch_info.GetListenerForProcess(debugger), + launch_info.GetProcessPluginName(), nullptr); - // We need to launch and attach to the process. - launch_info.GetFlags().Set(eLaunchFlagDebug); - if (process_sp) - error = process_sp->Launch(launch_info); + // We need to launch and attach to the process. + launch_info.GetFlags().Set(eLaunchFlagDebug); + if (process_sp) + error = process_sp->Launch(launch_info); - return process_sp; - } + return process_sp; } lldb::ProcessSP PlatformWindows::Attach(ProcessAttachInfo &attach_info, Index: source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.cpp =================================================================== --- source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.cpp +++ source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.cpp @@ -128,8 +128,8 @@ if (error.Success()) { if (exe_module_sp && exe_module_sp->GetObjectFile()) break; - else - error.SetErrorToGenericError(); + + error.SetErrorToGenericError(); } if (idx > 0) @@ -217,8 +217,9 @@ if (idx == 0) { arch = remote_arch; return arch.IsValid(); - } else if (idx == 1 && remote_arch.IsValid() && - remote_arch.GetTriple().isArch64Bit()) { + } + if (idx == 1 && remote_arch.IsValid() && + remote_arch.GetTriple().isArch64Bit()) { arch.SetTriple(remote_arch.GetTriple().get32BitArchVariant()); return arch.IsValid(); } @@ -259,9 +260,8 @@ "PlatformRemoteGDBServer::GetRemoteWorkingDirectory() -> '%s'", working_dir.GetCString()); return working_dir; - } else { - return Platform::GetRemoteWorkingDirectory(); } + return Platform::GetRemoteWorkingDirectory(); } bool PlatformRemoteGDBServer::SetRemoteWorkingDirectory( @@ -274,8 +274,8 @@ log->Printf("PlatformRemoteGDBServer::SetRemoteWorkingDirectory('%s')", working_dir.GetCString()); return m_gdb_client.SetWorkingDir(working_dir) == 0; - } else - return Platform::SetRemoteWorkingDirectory(working_dir); + } + return Platform::SetRemoteWorkingDirectory(working_dir); } bool PlatformRemoteGDBServer::IsConnected() const { Index: source/Plugins/Process/MacOSX-Kernel/CommunicationKDP.cpp =================================================================== --- source/Plugins/Process/MacOSX-Kernel/CommunicationKDP.cpp +++ source/Plugins/Process/MacOSX-Kernel/CommunicationKDP.cpp @@ -107,11 +107,11 @@ if (command == KDP_RESUMECPUS) m_is_running.SetValue(true, eBroadcastAlways); return true; - } else { - // Failed to get the correct response, bail - reply_packet.Clear(); - return false; } + // Failed to get the correct response, bail + reply_packet.Clear(); + return false; + } else if (reply_sequence_id > request_sequence_id) { // Sequence ID was greater than the sequence ID of the packet we // sent, something is really wrong... @@ -465,8 +465,8 @@ return false; if (strncmp(m_kernel_version.c_str(), "EFI", 3) == 0) return true; - else - return false; + + return false; } bool CommunicationKDP::RemoteIsDarwinKernel() { @@ -474,8 +474,8 @@ return false; if (m_kernel_version.find("Darwin Kernel") != std::string::npos) return true; - else - return false; + + return false; } lldb::addr_t CommunicationKDP::GetLoadAddress() { Index: source/Plugins/Process/MacOSX-Kernel/ProcessKDP.cpp =================================================================== --- source/Plugins/Process/MacOSX-Kernel/ProcessKDP.cpp +++ source/Plugins/Process/MacOSX-Kernel/ProcessKDP.cpp @@ -964,16 +964,16 @@ result.AppendMessage(packet.GetString()); result.SetStatus(eReturnStatusSuccessFinishResult); return true; - } else { - const char *error_cstr = error.AsCString(); - if (error_cstr && error_cstr[0]) - result.AppendError(error_cstr); - else - result.AppendErrorWithFormat("unknown error 0x%8.8x", - error.GetError()); - result.SetStatus(eReturnStatusFailed); - return false; } + const char *error_cstr = error.AsCString(); + if (error_cstr && error_cstr[0]) + result.AppendError(error_cstr); + else + result.AppendErrorWithFormat("unknown error 0x%8.8x", + error.GetError()); + result.SetStatus(eReturnStatusFailed); + return false; + } else { result.AppendErrorWithFormat("process must be stopped in order " "to send KDP packets, state is %s", Index: source/Plugins/Process/Utility/ARMUtils.h =================================================================== --- source/Plugins/Process/Utility/ARMUtils.h +++ source/Plugins/Process/Utility/ARMUtils.h @@ -107,8 +107,8 @@ uint32_t result = LSL_C(value, amount, dont_care, success); if (*success) return result; - else - return 0; + + return 0; } static inline uint32_t LSR_C(const uint32_t value, const uint32_t amount, @@ -131,8 +131,8 @@ uint32_t result = LSR_C(value, amount, dont_care, success); if (*success) return result; - else - return 0; + + return 0; } static inline uint32_t ASR_C(const uint32_t value, const uint32_t amount, @@ -147,10 +147,9 @@ carry_out = Bit32(value, amount - 1); int64_t extended = llvm::SignExtend64<32>(value); return UnsignedBits(extended, amount + 31, amount); - } else { - carry_out = (negative ? 1 : 0); - return (negative ? 0xffffffff : 0); } + carry_out = (negative ? 1 : 0); + return (negative ? 0xffffffff : 0); } static inline uint32_t ASR(const uint32_t value, const uint32_t amount, @@ -162,8 +161,8 @@ uint32_t result = ASR_C(value, amount, dont_care, success); if (*success) return result; - else - return 0; + + return 0; } static inline uint32_t ROR_C(const uint32_t value, const uint32_t amount, @@ -188,8 +187,8 @@ uint32_t result = ROR_C(value, amount, dont_care, success); if (*success) return result; - else - return 0; + + return 0; } static inline uint32_t RRX_C(const uint32_t value, const uint32_t carry_in, @@ -206,8 +205,8 @@ uint32_t result = RRX_C(value, carry_in, dont_care, success); if (*success) return result; - else - return 0; + + return 0; } static inline uint32_t Shift_C(const uint32_t value, ARM_ShifterType type, @@ -246,8 +245,8 @@ } if (*success) return result; - else - return 0; + + return 0; } static inline uint32_t Shift(const uint32_t value, ARM_ShifterType type, @@ -258,8 +257,8 @@ uint32_t result = Shift_C(value, type, amount, carry_in, dont_care, success); if (*success) return result; - else - return 0; + + return 0; } static inline uint32_t bits(const uint32_t val, const uint32_t msbit, Index: source/Plugins/Process/Utility/NativeRegisterContextRegisterInfo.cpp =================================================================== --- source/Plugins/Process/Utility/NativeRegisterContextRegisterInfo.cpp +++ source/Plugins/Process/Utility/NativeRegisterContextRegisterInfo.cpp @@ -33,8 +33,8 @@ uint32_t reg_index) const { if (reg_index <= GetRegisterCount()) return m_register_info_interface_up->GetRegisterInfo() + reg_index; - else - return nullptr; + + return nullptr; } const RegisterInfoInterface & Index: source/Plugins/Process/Utility/RegisterContextDarwin_arm.cpp =================================================================== --- source/Plugins/Process/Utility/RegisterContextDarwin_arm.cpp +++ source/Plugins/Process/Utility/RegisterContextDarwin_arm.cpp @@ -989,7 +989,7 @@ int RegisterContextDarwin_arm::GetSetForNativeRegNum(int reg) { if (reg < fpu_s0) return GPRRegSet; - else if (reg < exc_exception) + if (reg < exc_exception) return FPURegSet; else if (reg < k_num_registers) return EXCRegSet; Index: source/Plugins/Process/Utility/RegisterContextDarwin_arm64.cpp =================================================================== --- source/Plugins/Process/Utility/RegisterContextDarwin_arm64.cpp +++ source/Plugins/Process/Utility/RegisterContextDarwin_arm64.cpp @@ -169,7 +169,7 @@ int RegisterContextDarwin_arm64::GetSetForNativeRegNum(int reg) { if (reg < fpu_v0) return GPRRegSet; - else if (reg < exc_far) + if (reg < exc_far) return FPURegSet; else if (reg < k_num_registers) return EXCRegSet; Index: source/Plugins/Process/Utility/RegisterContextDarwin_i386.cpp =================================================================== --- source/Plugins/Process/Utility/RegisterContextDarwin_i386.cpp +++ source/Plugins/Process/Utility/RegisterContextDarwin_i386.cpp @@ -489,7 +489,7 @@ int RegisterContextDarwin_i386::GetSetForNativeRegNum(int reg_num) { if (reg_num < fpu_fcw) return GPRRegSet; - else if (reg_num < exc_trapno) + if (reg_num < exc_trapno) return FPURegSet; else if (reg_num < k_num_registers) return EXCRegSet; @@ -959,8 +959,8 @@ // If the trace bit is already set, there is nothing to do if (gpr.eflags & trace_bit) return true; - else - gpr.eflags |= trace_bit; + + gpr.eflags |= trace_bit; } else { // If the trace bit is already cleared, there is nothing to do if (gpr.eflags & trace_bit) Index: source/Plugins/Process/Utility/RegisterContextDarwin_x86_64.cpp =================================================================== --- source/Plugins/Process/Utility/RegisterContextDarwin_x86_64.cpp +++ source/Plugins/Process/Utility/RegisterContextDarwin_x86_64.cpp @@ -548,7 +548,7 @@ int RegisterContextDarwin_x86_64::GetSetForNativeRegNum(int reg_num) { if (reg_num < fpu_fcw) return GPRRegSet; - else if (reg_num < exc_trapno) + if (reg_num < exc_trapno) return FPURegSet; else if (reg_num < k_num_registers) return EXCRegSet; @@ -1067,8 +1067,8 @@ if (gpr.rflags & trace_bit) return true; // trace bit is already set, there is nothing to do - else - gpr.rflags |= trace_bit; + + gpr.rflags |= trace_bit; } else { if (gpr.rflags & trace_bit) gpr.rflags &= ~trace_bit; Index: source/Plugins/Process/Utility/RegisterContextLLDB.cpp =================================================================== --- source/Plugins/Process/Utility/RegisterContextLLDB.cpp +++ source/Plugins/Process/Utility/RegisterContextLLDB.cpp @@ -41,7 +41,7 @@ static ConstString GetSymbolOrFunctionName(const SymbolContext &sym_ctx) { if (sym_ctx.symbol) return sym_ctx.symbol->GetName(); - else if (sym_ctx.function) + if (sym_ctx.function) return sym_ctx.function->GetName(); return ConstString(); } @@ -694,9 +694,8 @@ } m_frame_type = eNormalFrame; return unwind_plan_sp; - } else { - unwind_plan_sp.reset(); } + unwind_plan_sp.reset(); } return unwind_plan_sp; } @@ -797,8 +796,8 @@ unwind_plan_sp.reset(new UnwindPlan(lldb::eRegisterKindGeneric)); if (eh_frame->GetUnwindPlan(m_current_pc, *unwind_plan_sp)) return unwind_plan_sp; - else - unwind_plan_sp.reset(); + + unwind_plan_sp.reset(); } ArmUnwindInfo *arm_exidx = @@ -808,8 +807,8 @@ if (arm_exidx->GetUnwindPlan(exe_ctx.GetTargetRef(), m_current_pc, *unwind_plan_sp)) return unwind_plan_sp; - else - unwind_plan_sp.reset(); + + unwind_plan_sp.reset(); } return arch_default_unwind_plan_sp; @@ -1377,18 +1376,18 @@ "RegisterContext at frame 0", regnum.GetName(), regnum.GetAsKind(eRegisterKindLLDB)); return UnwindLLDB::RegisterSearchResult::eRegisterFound; - } else { - std::string unwindplan_name(""); - if (m_full_unwind_plan_sp) { - unwindplan_name += "via '"; - unwindplan_name += m_full_unwind_plan_sp->GetSourceName().AsCString(); - unwindplan_name += "'"; + } + std::string unwindplan_name(""); + if (m_full_unwind_plan_sp) { + unwindplan_name += "via '"; + unwindplan_name += m_full_unwind_plan_sp->GetSourceName().AsCString(); + unwindplan_name += "'"; } UnwindLogMsg("no save location for %s (%d) %s", regnum.GetName(), regnum.GetAsKind(eRegisterKindLLDB), unwindplan_name.c_str()); - } - return UnwindLLDB::RegisterSearchResult::eRegisterNotFound; + + return UnwindLLDB::RegisterSearchResult::eRegisterNotFound; } // unwindplan_regloc has valid contents about where to retrieve the register @@ -1417,16 +1416,15 @@ "have no information", regnum.GetName(), regnum.GetAsKind(eRegisterKindLLDB)); return UnwindLLDB::RegisterSearchResult::eRegisterNotFound; - } else { - regloc.type = UnwindLLDB::RegisterLocation::eRegisterInRegister; - regloc.location.register_number = regnum.GetAsKind(eRegisterKindLLDB); - m_registers[regnum.GetAsKind(eRegisterKindLLDB)] = regloc; - UnwindLogMsg( - "supplying caller's register %s (%d), saved in register %s (%d)", - regnum.GetName(), regnum.GetAsKind(eRegisterKindLLDB), - regnum.GetName(), regnum.GetAsKind(eRegisterKindLLDB)); - return UnwindLLDB::RegisterSearchResult::eRegisterFound; } + regloc.type = UnwindLLDB::RegisterLocation::eRegisterInRegister; + regloc.location.register_number = regnum.GetAsKind(eRegisterKindLLDB); + m_registers[regnum.GetAsKind(eRegisterKindLLDB)] = regloc; + UnwindLogMsg( + "supplying caller's register %s (%d), saved in register %s (%d)", + regnum.GetName(), regnum.GetAsKind(eRegisterKindLLDB), regnum.GetName(), + regnum.GetAsKind(eRegisterKindLLDB)); + return UnwindLLDB::RegisterSearchResult::eRegisterFound; } if (unwindplan_regloc.IsCFAPlusOffset()) { @@ -1527,16 +1525,15 @@ "(IsDWARFExpression)", regnum.GetName(), regnum.GetAsKind(eRegisterKindLLDB)); return UnwindLLDB::RegisterSearchResult::eRegisterFound; - } else { - regloc.type = - UnwindLLDB::RegisterLocation::eRegisterSavedAtMemoryLocation; - regloc.location.target_memory_location = val; - m_registers[regnum.GetAsKind(eRegisterKindLLDB)] = regloc; - UnwindLogMsg("supplying caller's register %s (%d) via DWARF expression " - "(IsAtDWARFExpression)", - regnum.GetName(), regnum.GetAsKind(eRegisterKindLLDB)); - return UnwindLLDB::RegisterSearchResult::eRegisterFound; } + regloc.type = + UnwindLLDB::RegisterLocation::eRegisterSavedAtMemoryLocation; + regloc.location.target_memory_location = val; + m_registers[regnum.GetAsKind(eRegisterKindLLDB)] = regloc; + UnwindLogMsg("supplying caller's register %s (%d) via DWARF expression " + "(IsAtDWARFExpression)", + regnum.GetName(), regnum.GetAsKind(eRegisterKindLLDB)); + return UnwindLLDB::RegisterSearchResult::eRegisterFound; } UnwindLogMsg("tried to use IsDWARFExpression or IsAtDWARFExpression for %s " "(%d) but failed", @@ -1771,12 +1768,11 @@ cfa_reg.GetName(), cfa_reg.GetAsKind(eRegisterKindLLDB), cfa_reg_contents, address); return true; - } else { - UnwindLogMsg("Tried to deref reg %s (%d) [0x%" PRIx64 - "] but memory read failed.", - cfa_reg.GetName(), cfa_reg.GetAsKind(eRegisterKindLLDB), - cfa_reg_contents); } + UnwindLogMsg("Tried to deref reg %s (%d) [0x%" PRIx64 + "] but memory read failed.", + cfa_reg.GetName(), cfa_reg.GetAsKind(eRegisterKindLLDB), + cfa_reg_contents); } } break; @@ -2057,9 +2053,8 @@ } return true; - } else { - return false; } + return false; } void RegisterContextLLDB::UnwindLogMsg(const char *fmt, ...) { Index: source/Plugins/Process/Utility/RegisterContextPOSIX_arm.cpp =================================================================== --- source/Plugins/Process/Utility/RegisterContextPOSIX_arm.cpp +++ source/Plugins/Process/Utility/RegisterContextPOSIX_arm.cpp @@ -146,8 +146,8 @@ RegisterContextPOSIX_arm::GetRegisterInfoAtIndex(size_t reg) { if (reg < m_reg_info.num_registers) return &GetRegisterInfo()[reg]; - else - return NULL; + + return NULL; } size_t RegisterContextPOSIX_arm::GetRegisterSetCount() { Index: source/Plugins/Process/Utility/RegisterContextPOSIX_arm64.cpp =================================================================== --- source/Plugins/Process/Utility/RegisterContextPOSIX_arm64.cpp +++ source/Plugins/Process/Utility/RegisterContextPOSIX_arm64.cpp @@ -166,8 +166,8 @@ RegisterContextPOSIX_arm64::GetRegisterInfoAtIndex(size_t reg) { if (reg < m_reg_info.num_registers) return &GetRegisterInfo()[reg]; - else - return NULL; + + return NULL; } size_t RegisterContextPOSIX_arm64::GetRegisterSetCount() { Index: source/Plugins/Process/Utility/RegisterContextPOSIX_mips64.cpp =================================================================== --- source/Plugins/Process/Utility/RegisterContextPOSIX_mips64.cpp +++ source/Plugins/Process/Utility/RegisterContextPOSIX_mips64.cpp @@ -96,8 +96,8 @@ RegisterContextPOSIX_mips64::GetRegisterInfoAtIndex(size_t reg) { if (reg < m_num_registers) return &GetRegisterInfo()[reg]; - else - return NULL; + + return NULL; } size_t RegisterContextPOSIX_mips64::GetRegisterSetCount() { Index: source/Plugins/Process/Utility/RegisterContextPOSIX_powerpc.cpp =================================================================== --- source/Plugins/Process/Utility/RegisterContextPOSIX_powerpc.cpp +++ source/Plugins/Process/Utility/RegisterContextPOSIX_powerpc.cpp @@ -133,8 +133,8 @@ RegisterContextPOSIX_powerpc::GetRegisterInfoAtIndex(size_t reg) { if (reg < k_num_registers_powerpc) return &GetRegisterInfo()[reg]; - else - return NULL; + + return NULL; } size_t RegisterContextPOSIX_powerpc::GetRegisterSetCount() { @@ -150,8 +150,8 @@ const RegisterSet *RegisterContextPOSIX_powerpc::GetRegisterSet(size_t set) { if (IsRegisterSetAvailable(set)) return &g_reg_sets_powerpc[set]; - else - return NULL; + + return NULL; } const char *RegisterContextPOSIX_powerpc::GetRegisterName(unsigned reg) { Index: source/Plugins/Process/Utility/RegisterContextPOSIX_ppc64le.cpp =================================================================== --- source/Plugins/Process/Utility/RegisterContextPOSIX_ppc64le.cpp +++ source/Plugins/Process/Utility/RegisterContextPOSIX_ppc64le.cpp @@ -151,8 +151,8 @@ RegisterContextPOSIX_ppc64le::GetRegisterInfoAtIndex(size_t reg) { if (reg < k_num_registers_ppc64le) return &GetRegisterInfo()[reg]; - else - return NULL; + + return NULL; } size_t RegisterContextPOSIX_ppc64le::GetRegisterSetCount() { @@ -168,8 +168,8 @@ const RegisterSet *RegisterContextPOSIX_ppc64le::GetRegisterSet(size_t set) { if (IsRegisterSetAvailable(set)) return &g_reg_sets_ppc64le[set]; - else - return NULL; + + return NULL; } const char *RegisterContextPOSIX_ppc64le::GetRegisterName(unsigned reg) { Index: source/Plugins/Process/Utility/RegisterContextPOSIX_s390x.cpp =================================================================== --- source/Plugins/Process/Utility/RegisterContextPOSIX_s390x.cpp +++ source/Plugins/Process/Utility/RegisterContextPOSIX_s390x.cpp @@ -113,8 +113,8 @@ RegisterContextPOSIX_s390x::GetRegisterInfoAtIndex(size_t reg) { if (reg < m_reg_info.num_registers) return &GetRegisterInfo()[reg]; - else - return NULL; + + return NULL; } size_t RegisterContextPOSIX_s390x::GetRegisterCount() { Index: source/Plugins/Process/Utility/RegisterContextPOSIX_x86.cpp =================================================================== --- source/Plugins/Process/Utility/RegisterContextPOSIX_x86.cpp +++ source/Plugins/Process/Utility/RegisterContextPOSIX_x86.cpp @@ -423,8 +423,8 @@ RegisterContextPOSIX_x86::GetRegisterInfoAtIndex(size_t reg) { if (reg < m_reg_info.num_registers) return &GetRegisterInfo()[reg]; - else - return NULL; + + return NULL; } size_t RegisterContextPOSIX_x86::GetRegisterSetCount() { Index: source/Plugins/Process/Utility/StopInfoMachException.cpp =================================================================== --- source/Plugins/Process/Utility/StopInfoMachException.cpp +++ source/Plugins/Process/Utility/StopInfoMachException.cpp @@ -510,10 +510,10 @@ wp_sp->SetHardwareIndex((uint32_t)exc_sub_sub_code); return StopInfo::CreateStopReasonWithWatchpointID(thread, wp_sp->GetID()); - } else { - is_actual_breakpoint = true; - is_trace_if_actual_breakpoint_missing = true; } + is_actual_breakpoint = true; + is_trace_if_actual_breakpoint_missing = true; + } else if (exc_code == 1) // EXC_ARM_BREAKPOINT { is_actual_breakpoint = true; @@ -597,7 +597,7 @@ thread.GetProcess()->GetOperatingSystem() != NULL) return StopInfo::CreateStopReasonWithBreakpointSiteID( thread, bp_site_sp->GetID()); - else if (is_trace_if_actual_breakpoint_missing) + if (is_trace_if_actual_breakpoint_missing) return StopInfo::CreateStopReasonToTrace(thread); else return StopInfoSP(); Index: source/Plugins/Process/Utility/UnwindLLDB.cpp =================================================================== --- source/Plugins/Process/Utility/UnwindLLDB.cpp +++ source/Plugins/Process/Utility/UnwindLLDB.cpp @@ -236,13 +236,12 @@ "stopping stack walk", cur_idx < 100 ? cur_idx : 100, "", cur_idx); return nullptr; - } else { - if (log) - log->Printf("%*sFrame %d had a bad CFA value but we switched the " - "UnwindPlan being used and got one that looks more " - "realistic.", - cur_idx < 100 ? cur_idx : 100, "", cur_idx); } + if (log) + log->Printf("%*sFrame %d had a bad CFA value but we switched the " + "UnwindPlan being used and got one that looks more " + "realistic.", + cur_idx < 100 ? cur_idx : 100, "", cur_idx); } } if (!reg_ctx_sp->ReadPC(cursor_sp->start_pc)) { @@ -472,8 +471,8 @@ lldb_regnum, regloc); if (result == UnwindLLDB::RegisterSearchResult::eRegisterFound) return true; - else - return false; + + return false; } while (frame_num >= 0) { UnwindLLDB::RegisterSearchResult result; Index: source/Plugins/Process/elf-core/RegisterContextPOSIXCore_mips64.cpp =================================================================== --- source/Plugins/Process/elf-core/RegisterContextPOSIXCore_mips64.cpp +++ source/Plugins/Process/elf-core/RegisterContextPOSIXCore_mips64.cpp @@ -61,12 +61,13 @@ v = m_gpr.GetMaxU64(&offset, reg_info->byte_size); value = v; return true; - } else if (IsFPR(reg_info->kinds[lldb::eRegisterKindLLDB])) { + } + if (IsFPR(reg_info->kinds[lldb::eRegisterKindLLDB])) { offset = offset - sizeof(GPR_linux_mips); v =m_fpr.GetMaxU64(&offset, reg_info->byte_size); value = v; return true; - } + } return false; } Index: source/Plugins/Process/elf-core/RegisterContextPOSIXCore_ppc64le.cpp =================================================================== --- source/Plugins/Process/elf-core/RegisterContextPOSIXCore_ppc64le.cpp +++ source/Plugins/Process/elf-core/RegisterContextPOSIXCore_ppc64le.cpp @@ -103,14 +103,13 @@ value.SetBytes(&v, reg_info->byte_size, m_vsx.GetByteOrder()); return true; - } else { - offset = - m_vmx.CopyData(offset - GetVSXSize() / 2, reg_info->byte_size, &v); - if (offset == reg_info->byte_size) { - value.SetBytes(v, reg_info->byte_size, m_vmx.GetByteOrder()); - return true; - } } + offset = m_vmx.CopyData(offset - GetVSXSize() / 2, reg_info->byte_size, &v); + if (offset == reg_info->byte_size) { + value.SetBytes(v, reg_info->byte_size, m_vmx.GetByteOrder()); + return true; + } + } else { uint64_t v = m_gpr.GetMaxU64(&offset, reg_info->byte_size); Index: source/Plugins/Process/elf-core/ThreadElfCore.cpp =================================================================== --- source/Plugins/Process/elf-core/ThreadElfCore.cpp +++ source/Plugins/Process/elf-core/ThreadElfCore.cpp @@ -259,7 +259,7 @@ assert(!abi.empty() && "ABI is not set"); if (!abi.compare("n64")) return sizeof(ELFLinuxPrStatus); - else if (!abi.compare("o32")) + if (!abi.compare("o32")) return mips_linux_pr_status_size_o32; // N32 ABI return mips_linux_pr_status_size_n32; Index: source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp =================================================================== --- source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp +++ source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp @@ -182,8 +182,8 @@ if (bytes_written == packet_length) { if (!skip_ack && GetSendAcks()) return GetAck(); - else - return PacketResult::Success; + + return PacketResult::Success; } else { if (log) log->Printf("error: failed to send packet: %.*s", (int)packet_length, @@ -200,8 +200,8 @@ if (packet.GetResponseType() == StringExtractorGDBRemote::ResponseType::eAck) return PacketResult::Success; - else - return PacketResult::ErrorSendAck; + + return PacketResult::ErrorSendAck; } return result; } @@ -229,8 +229,8 @@ bool sync_on_timeout) { if (m_read_thread_enabled) return PopPacketFromQueue(response, timeout); - else - return WaitForPacketNoLock(response, timeout, sync_on_timeout); + + return WaitForPacketNoLock(response, timeout, sync_on_timeout); } // This function is called when a packet is requested. @@ -354,7 +354,8 @@ if (response_regex.Execute(echo_response.GetStringRef())) { sync_success = true; break; - } else if (successful_responses == 1) { + } + if (successful_responses == 1) { // We got something else back as the first successful // response, it probably is the response to the packet we // actually wanted, so copy it over if this is the first @@ -407,8 +408,8 @@ return PacketResult::ErrorDisconnected; if (timed_out) return PacketResult::ErrorReplyTimeout; - else - return PacketResult::ErrorReplyFailed; + + return PacketResult::ErrorReplyFailed; } bool GDBRemoteCommunication::DecompressPacket() { @@ -501,9 +502,8 @@ SendNack(); m_bytes.erase(0, size_of_first_packet); return false; - } else { - SendAck(); } + SendAck(); } if (m_bytes[1] == 'N') { @@ -728,7 +728,8 @@ if (content_length == std::string::npos) { packet.Clear(); return GDBRemoteCommunication::PacketType::Invalid; - } else if (total_length > 0) { + } + if (total_length > 0) { // We have a valid packet... assert(content_length <= m_bytes.size()); @@ -863,8 +864,8 @@ if (isNotifyPacket) return GDBRemoteCommunication::PacketType::Notify; - else - return GDBRemoteCommunication::PacketType::Standard; + + return GDBRemoteCommunication::PacketType::Standard; } } packet.Clear(); Index: source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp =================================================================== --- source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp +++ source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp @@ -130,10 +130,10 @@ // live connection to a remote GDB server... if (QueryNoAckModeSupported()) { return true; - } else { - if (error_ptr) - error_ptr->SetErrorString("failed to get reply to handshake packet"); } + if (error_ptr) + error_ptr->SetErrorString("failed to get reply to handshake packet"); + } else { if (error_ptr) error_ptr->SetErrorString("failed to send the handshake ack"); @@ -254,8 +254,8 @@ } if (m_attach_or_wait_reply == eLazyBoolYes) return true; - else - return false; + + return false; } bool GDBRemoteCommunicationClient::GetSyncThreadStateSupported() { @@ -271,8 +271,8 @@ } if (m_prepare_for_reg_writing_reply == eLazyBoolYes) return true; - else - return false; + + return false; } void GDBRemoteCommunicationClient::ResetDiscoverableSettings(bool did_exec) { @@ -718,25 +718,25 @@ if (m_curr_pid_is_valid == eLazyBoolYes) { // We really got it. return m_curr_pid; - } else { - // If we don't get a response for qProcessInfo, check if $qC gives us a - // result. $qC only returns a real process id on older debugserver and - // lldb-platform stubs. The gdb remote protocol documents $qC as returning - // the thread id, which newer debugserver and lldb-gdbserver stubs return - // correctly. - StringExtractorGDBRemote response; - if (SendPacketAndWaitForResponse("qC", response, false) == - PacketResult::Success) { - if (response.GetChar() == 'Q') { - if (response.GetChar() == 'C') { - m_curr_pid = response.GetHexMaxU32(false, LLDB_INVALID_PROCESS_ID); - if (m_curr_pid != LLDB_INVALID_PROCESS_ID) { - m_curr_pid_is_valid = eLazyBoolYes; - return m_curr_pid; - } + } + // If we don't get a response for qProcessInfo, check if $qC gives us a + // result. $qC only returns a real process id on older debugserver and + // lldb-platform stubs. The gdb remote protocol documents $qC as returning + // the thread id, which newer debugserver and lldb-gdbserver stubs return + // correctly. + StringExtractorGDBRemote response; + if (SendPacketAndWaitForResponse("qC", response, false) == + PacketResult::Success) { + if (response.GetChar() == 'Q') { + if (response.GetChar() == 'C') { + m_curr_pid = response.GetHexMaxU32(false, LLDB_INVALID_PROCESS_ID); + if (m_curr_pid != LLDB_INVALID_PROCESS_ID) { + m_curr_pid_is_valid = eLazyBoolYes; + return m_curr_pid; } } } + } // If we don't get a response for $qC, check if $qfThreadID gives us a // result. @@ -751,7 +751,6 @@ return m_curr_pid; } } - } return LLDB_INVALID_PROCESS_ID; } @@ -921,7 +920,8 @@ if (was_supported) *was_supported = true; return 0; - } else if (response.IsUnsupportedResponse()) { + } + if (response.IsUnsupportedResponse()) { if (was_supported) *was_supported = false; return -1; @@ -1424,13 +1424,13 @@ if (m_supports_detach_stay_stopped == eLazyBoolNo) { error.SetErrorString("Stays stopped not supported by this target."); return error; - } else { - StringExtractorGDBRemote response; - PacketResult packet_result = - SendPacketAndWaitForResponse("D1", response, false); - if (packet_result != PacketResult::Success) - error.SetErrorString("Sending extended disconnect packet failed."); } + StringExtractorGDBRemote response; + PacketResult packet_result = + SendPacketAndWaitForResponse("D1", response, false); + if (packet_result != PacketResult::Success) + error.SetErrorString("Sending extended disconnect packet failed."); + } else { StringExtractorGDBRemote response; PacketResult packet_result = @@ -1972,10 +1972,9 @@ if (SendPacketAndWaitForResponse(packet, response, false) == PacketResult::Success) { return DecodeProcessInfoResponse(response, process_info); - } else { - m_supports_qProcessInfoPID = false; - return false; } + m_supports_qProcessInfoPID = false; + return false; } return false; } @@ -2812,7 +2811,7 @@ uint32_t exitcode = response.GetHexMaxU32(false, UINT32_MAX); if (exitcode == UINT32_MAX) return Status("unable to run remote process"); - else if (status_ptr) + if (status_ptr) *status_ptr = exitcode; if (response.GetChar() != ',') return Status("malformed reply"); @@ -3038,9 +3037,9 @@ return 0; } return bytes_written; - } else { - error.SetErrorString("failed to send vFile:pwrite packet"); } + error.SetErrorString("failed to send vFile:pwrite packet"); + return 0; } @@ -3449,10 +3448,9 @@ lldb::eStructuredDataTypeDictionary) { error.SetErrorString("Invalid Configuration obtained"); return error; - } else - options.setTraceParams( - static_pointer_cast( - custom_params_sp)); + } + options.setTraceParams( + static_pointer_cast(custom_params_sp)); } } else { error = response.GetStatus(); @@ -3799,94 +3797,92 @@ // connected to m_supports_qSymbol = false; return; - } else { - llvm::StringRef response_str(response.GetStringRef()); - if (response_str.startswith("qSymbol:")) { - response.SetFilePos(strlen("qSymbol:")); - std::string symbol_name; - if (response.GetHexByteString(symbol_name)) { - if (symbol_name.empty()) - return; - - addr_t symbol_load_addr = LLDB_INVALID_ADDRESS; - lldb_private::SymbolContextList sc_list; - if (process->GetTarget().GetImages().FindSymbolsWithNameAndType( - ConstString(symbol_name), eSymbolTypeAny, sc_list)) { - const size_t num_scs = sc_list.GetSize(); - for (size_t sc_idx = 0; - sc_idx < num_scs && - symbol_load_addr == LLDB_INVALID_ADDRESS; - ++sc_idx) { - SymbolContext sc; - if (sc_list.GetContextAtIndex(sc_idx, sc)) { - if (sc.symbol) { - switch (sc.symbol->GetType()) { - case eSymbolTypeInvalid: - case eSymbolTypeAbsolute: - case eSymbolTypeUndefined: - case eSymbolTypeSourceFile: - case eSymbolTypeHeaderFile: - case eSymbolTypeObjectFile: - case eSymbolTypeCommonBlock: - case eSymbolTypeBlock: - case eSymbolTypeLocal: - case eSymbolTypeParam: - case eSymbolTypeVariable: - case eSymbolTypeVariableType: - case eSymbolTypeLineEntry: - case eSymbolTypeLineHeader: - case eSymbolTypeScopeBegin: - case eSymbolTypeScopeEnd: - case eSymbolTypeAdditional: - case eSymbolTypeCompiler: - case eSymbolTypeInstrumentation: - case eSymbolTypeTrampoline: - break; - - case eSymbolTypeCode: - case eSymbolTypeResolver: - case eSymbolTypeData: - case eSymbolTypeRuntime: - case eSymbolTypeException: - case eSymbolTypeObjCClass: - case eSymbolTypeObjCMetaClass: - case eSymbolTypeObjCIVar: - case eSymbolTypeReExported: - symbol_load_addr = - sc.symbol->GetLoadAddress(&process->GetTarget()); - break; - } + } + llvm::StringRef response_str(response.GetStringRef()); + if (response_str.startswith("qSymbol:")) { + response.SetFilePos(strlen("qSymbol:")); + std::string symbol_name; + if (response.GetHexByteString(symbol_name)) { + if (symbol_name.empty()) + return; + + addr_t symbol_load_addr = LLDB_INVALID_ADDRESS; + lldb_private::SymbolContextList sc_list; + if (process->GetTarget().GetImages().FindSymbolsWithNameAndType( + ConstString(symbol_name), eSymbolTypeAny, sc_list)) { + const size_t num_scs = sc_list.GetSize(); + for (size_t sc_idx = 0; + sc_idx < num_scs && symbol_load_addr == LLDB_INVALID_ADDRESS; + ++sc_idx) { + SymbolContext sc; + if (sc_list.GetContextAtIndex(sc_idx, sc)) { + if (sc.symbol) { + switch (sc.symbol->GetType()) { + case eSymbolTypeInvalid: + case eSymbolTypeAbsolute: + case eSymbolTypeUndefined: + case eSymbolTypeSourceFile: + case eSymbolTypeHeaderFile: + case eSymbolTypeObjectFile: + case eSymbolTypeCommonBlock: + case eSymbolTypeBlock: + case eSymbolTypeLocal: + case eSymbolTypeParam: + case eSymbolTypeVariable: + case eSymbolTypeVariableType: + case eSymbolTypeLineEntry: + case eSymbolTypeLineHeader: + case eSymbolTypeScopeBegin: + case eSymbolTypeScopeEnd: + case eSymbolTypeAdditional: + case eSymbolTypeCompiler: + case eSymbolTypeInstrumentation: + case eSymbolTypeTrampoline: + break; + + case eSymbolTypeCode: + case eSymbolTypeResolver: + case eSymbolTypeData: + case eSymbolTypeRuntime: + case eSymbolTypeException: + case eSymbolTypeObjCClass: + case eSymbolTypeObjCMetaClass: + case eSymbolTypeObjCIVar: + case eSymbolTypeReExported: + symbol_load_addr = + sc.symbol->GetLoadAddress(&process->GetTarget()); + break; } } } } - // This is the normal path where our symbol lookup was successful - // and we want to send a packet with the new symbol value and see - // if another lookup needs to be done. - - // Change "packet" to contain the requested symbol value and name - packet.Clear(); - packet.PutCString("qSymbol:"); - if (symbol_load_addr != LLDB_INVALID_ADDRESS) { - packet.Printf("%" PRIx64, symbol_load_addr); - symbol_response_provided = true; - } else { - symbol_response_provided = false; - } - packet.PutCString(":"); - packet.PutBytesAsRawHex8(symbol_name.data(), symbol_name.size()); - continue; // go back to the while loop and send "packet" and wait - // for another response } + // This is the normal path where our symbol lookup was successful + // and we want to send a packet with the new symbol value and see + // if another lookup needs to be done. + + // Change "packet" to contain the requested symbol value and name + packet.Clear(); + packet.PutCString("qSymbol:"); + if (symbol_load_addr != LLDB_INVALID_ADDRESS) { + packet.Printf("%" PRIx64, symbol_load_addr); + symbol_response_provided = true; + } else { + symbol_response_provided = false; + } + packet.PutCString(":"); + packet.PutBytesAsRawHex8(symbol_name.data(), symbol_name.size()); + continue; // go back to the while loop and send "packet" and wait + // for another response + } } - } } // If we make it here, the symbol request packet response wasn't valid or // our symbol lookup failed so we must abort return; - - } else if (Log *log = ProcessGDBRemoteLog::GetLogIfAnyCategoryIsSet( - GDBR_LOG_PROCESS | GDBR_LOG_PACKETS)) { + } + if (Log *log = ProcessGDBRemoteLog::GetLogIfAnyCategoryIsSet( + GDBR_LOG_PROCESS | GDBR_LOG_PACKETS)) { log->Printf( "GDBRemoteCommunicationClient::%s: Didn't get sequence mutex.", __FUNCTION__); @@ -3956,9 +3952,8 @@ if (response.IsOKResponse()) { return Status(); - } else { - return Status("Unknown error happened during sending QPassSignals packet."); } + return Status("Unknown error happened during sending QPassSignals packet."); } Status GDBRemoteCommunicationClient::ConfigureRemoteStructuredData( Index: source/Plugins/Process/gdb-remote/GDBRemoteCommunicationHistory.h =================================================================== --- source/Plugins/Process/gdb-remote/GDBRemoteCommunicationHistory.h +++ source/Plugins/Process/gdb-remote/GDBRemoteCommunicationHistory.h @@ -76,15 +76,15 @@ uint32_t GetFirstSavedPacketIndex() const { if (m_total_packet_count < m_packets.size()) return 0; - else - return m_curr_idx + 1; + + return m_curr_idx + 1; } uint32_t GetNumPacketsInHistory() const { if (m_total_packet_count < m_packets.size()) return m_total_packet_count; - else - return (uint32_t)m_packets.size(); + + return (uint32_t)m_packets.size(); } uint32_t GetNextIndex() { Index: source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServer.cpp =================================================================== --- source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServer.cpp +++ source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServer.cpp @@ -109,8 +109,8 @@ packet.Printf("E%2.2x;", static_cast(error.GetError())); packet.PutCStringAsRawHex8(error.AsCString()); return SendPacketNoLock(packet.GetString()); - } else - return SendErrorResponse(error.GetError()); + } + return SendErrorResponse(error.GetError()); } GDBRemoteCommunication::PacketResult Index: source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp =================================================================== --- source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp +++ source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp @@ -1377,9 +1377,9 @@ // FIXME add continue at address support for $C{signo}[;{continue-address}]. if (*packet.Peek() == ';') return SendUnimplementedResponse(packet.GetStringRef().c_str()); - else - return SendIllFormedResponse( - packet, "unexpected content after $C{signal-number}"); + + return SendIllFormedResponse(packet, + "unexpected content after $C{signal-number}"); } ResumeActionList resume_actions(StateType::eStateRunning, 0); @@ -1499,7 +1499,8 @@ // Move past the ';', then do a simple 'c'. packet.SetFilePos(packet.GetFilePos() + 1); return Handle_c(packet); - } else if (::strcmp(packet.Peek(), ";s") == 0) { + } + if (::strcmp(packet.Peek(), ";s") == 0) { // Move past the ';', then do a simple 's'. packet.SetFilePos(packet.GetFilePos() + 1); return Handle_s(packet); @@ -2541,17 +2542,16 @@ LLDB_LOG(log, "pid {0} failed to set breakpoint: {1}", m_debugged_process_up->GetID(), error); return SendErrorResponse(0x09); - } else { - // Try to set the watchpoint. - const Status error = m_debugged_process_up->SetWatchpoint( - addr, size, watch_flags, want_hardware); - if (error.Success()) - return SendOKResponse(); - Log *log(GetLogIfAnyCategoriesSet(LIBLLDB_LOG_WATCHPOINTS)); - LLDB_LOG(log, "pid {0} failed to set watchpoint: {1}", - m_debugged_process_up->GetID(), error); - return SendErrorResponse(0x09); } + // Try to set the watchpoint. + const Status error = m_debugged_process_up->SetWatchpoint( + addr, size, watch_flags, want_hardware); + if (error.Success()) + return SendOKResponse(); + Log *log(GetLogIfAnyCategoriesSet(LIBLLDB_LOG_WATCHPOINTS)); + LLDB_LOG(log, "pid {0} failed to set watchpoint: {1}", + m_debugged_process_up->GetID(), error); + return SendErrorResponse(0x09); } GDBRemoteCommunication::PacketResult @@ -2629,16 +2629,15 @@ LLDB_LOG(log, "pid {0} failed to remove breakpoint: {1}", m_debugged_process_up->GetID(), error); return SendErrorResponse(0x09); - } else { - // Try to clear the watchpoint. - const Status error = m_debugged_process_up->RemoveWatchpoint(addr); - if (error.Success()) - return SendOKResponse(); - Log *log(GetLogIfAnyCategoriesSet(LIBLLDB_LOG_WATCHPOINTS)); - LLDB_LOG(log, "pid {0} failed to remove watchpoint: {1}", - m_debugged_process_up->GetID(), error); - return SendErrorResponse(0x09); } + // Try to clear the watchpoint. + const Status error = m_debugged_process_up->RemoveWatchpoint(addr); + if (error.Success()) + return SendOKResponse(); + Log *log(GetLogIfAnyCategoriesSet(LIBLLDB_LOG_WATCHPOINTS)); + LLDB_LOG(log, "pid {0} failed to remove watchpoint: {1}", + m_debugged_process_up->GetID(), error); + return SendErrorResponse(0x09); } GDBRemoteCommunication::PacketResult @@ -2796,9 +2795,9 @@ if (m_thread_suffix_supported) return SendIllFormedResponse( packet, "No thread specified in QSaveRegisterState packet"); - else - return SendIllFormedResponse(packet, - "No thread was is set with the Hg packet"); + + return SendIllFormedResponse(packet, + "No thread was is set with the Hg packet"); } // Grab the register context for the thread. @@ -2854,9 +2853,9 @@ if (m_thread_suffix_supported) return SendIllFormedResponse( packet, "No thread specified in QRestoreRegisterState packet"); - else - return SendIllFormedResponse(packet, - "No thread was is set with the Hg packet"); + + return SendIllFormedResponse(packet, + "No thread was is set with the Hg packet"); } // Grab the register context for the thread. @@ -3144,7 +3143,7 @@ const lldb::tid_t current_tid = GetCurrentThreadID(); if (current_tid == LLDB_INVALID_THREAD_ID) return nullptr; - else if (current_tid == 0) { + if (current_tid == 0) { // Pick a thread. return m_debugged_process_up->GetThreadAtIndex(0); } else Index: source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerPlatform.cpp =================================================================== --- source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerPlatform.cpp +++ source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerPlatform.cpp @@ -268,8 +268,8 @@ // go ahead and attempt to kill the spawned process if (KillSpawnedProcess(pid)) return SendOKResponse(); - else - return SendErrorResponse(11); + + return SendErrorResponse(11); } bool GDBRemoteCommunicationServerPlatform::KillSpawnedProcess(lldb::pid_t pid) { Index: source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.cpp =================================================================== --- source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.cpp +++ source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.cpp @@ -419,10 +419,9 @@ reg_checkpoint.SetID(save_id); reg_checkpoint.GetData().reset(); return true; - } else { - reg_checkpoint.SetID(0); // Invalid save ID is zero - return ReadAllRegisterValues(reg_checkpoint.GetData()); } + reg_checkpoint.SetID(0); // Invalid save ID is zero + return ReadAllRegisterValues(reg_checkpoint.GetData()); } bool GDBRemoteRegisterContext::WriteAllRegisterValues( @@ -440,9 +439,8 @@ ((ProcessGDBRemote *)process)->GetGDBRemote()); return gdb_comm.RestoreRegisterState(m_thread.GetProtocolID(), save_id); - } else { - return WriteAllRegisterValues(reg_checkpoint.GetData()); } + return WriteAllRegisterValues(reg_checkpoint.GetData()); } bool GDBRemoteRegisterContext::ReadAllRegisterValues( @@ -484,7 +482,7 @@ data_sp.reset(new DataBufferHeap(m_reg_data.GetDataStart(), m_reg_info.GetRegisterDataByteSize())); return true; - } else { + } Log *log(ProcessGDBRemoteLog::GetLogIfAnyCategoryIsSet(GDBR_LOG_THREAD | GDBR_LOG_PACKETS)); @@ -499,7 +497,6 @@ log->Printf("error: failed to get packet sequence mutex, not sending " "read all registers"); } - } data_sp.reset(); return false; @@ -619,20 +616,20 @@ } } return num_restored > 0; - } else { - // For the use_g_packet == false case, we're going to write each register - // individually. The data buffer is binary data in this case, instead of - // ascii characters. - - bool arm64_debugserver = false; - if (m_thread.GetProcess().get()) { - const ArchSpec &arch = - m_thread.GetProcess()->GetTarget().GetArchitecture(); - if (arch.IsValid() && arch.GetMachine() == llvm::Triple::aarch64 && - arch.GetTriple().getVendor() == llvm::Triple::Apple && - arch.GetTriple().getOS() == llvm::Triple::IOS) { - arm64_debugserver = true; - } + } + // For the use_g_packet == false case, we're going to write each register + // individually. The data buffer is binary data in this case, instead of + // ascii characters. + + bool arm64_debugserver = false; + if (m_thread.GetProcess().get()) { + const ArchSpec &arch = + m_thread.GetProcess()->GetTarget().GetArchitecture(); + if (arch.IsValid() && arch.GetMachine() == llvm::Triple::aarch64 && + arch.GetTriple().getVendor() == llvm::Triple::Apple && + arch.GetTriple().getOS() == llvm::Triple::IOS) { + arm64_debugserver = true; + } } uint32_t num_restored = 0; const RegisterInfo *reg_info; @@ -657,7 +654,7 @@ ++num_restored; } return num_restored > 0; - } + } else { Log *log(ProcessGDBRemoteLog::GetLogIfAnyCategoryIsSet(GDBR_LOG_THREAD | GDBR_LOG_PACKETS)); Index: source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp =================================================================== --- source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp +++ source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp @@ -492,11 +492,10 @@ // See if we can get register definitions from a python file if (ParsePythonTargetDefinition(target_definition_fspec)) { return; - } else { - StreamSP stream_sp = GetTarget().GetDebugger().GetAsyncOutputStream(); - stream_sp->Printf("ERROR: target description file %s failed to parse.\n", - target_definition_fspec.GetPath().c_str()); } + StreamSP stream_sp = GetTarget().GetDebugger().GetAsyncOutputStream(); + stream_sp->Printf("ERROR: target description file %s failed to parse.\n", + target_definition_fspec.GetPath().c_str()); } const ArchSpec &target_arch = GetTarget().GetArchitecture(); @@ -1022,7 +1021,8 @@ if (conn_ap->Connect(connect_url, &error) == eConnectionStatusSuccess) { m_gdb_comm.SetConnection(conn_ap.release()); break; - } else if (error.WasInterrupted()) { + } + if (error.WasInterrupted()) { // If we were interrupted, don't keep retrying. break; } @@ -2799,10 +2799,10 @@ } memcpy(buf, response.GetStringRef().data(), data_received_size); return data_received_size; - } else { - return response.GetHexBytes( - llvm::MutableArrayRef((uint8_t *)buf, size), '\xdd'); } + return response.GetHexBytes( + llvm::MutableArrayRef((uint8_t *)buf, size), '\xdd'); + } else if (response.IsErrorResponse()) error.SetErrorStringWithFormat("memory read failed for 0x%" PRIx64, addr); else if (response.IsUnsupportedResponse()) @@ -3003,7 +3003,8 @@ if (response.IsOKResponse()) { error.Clear(); return size; - } else if (response.IsErrorResponse()) + } + if (response.IsErrorResponse()) error.SetErrorStringWithFormat("memory write failed for 0x%" PRIx64, addr); else if (response.IsUnsupportedResponse()) @@ -3323,7 +3324,7 @@ assert(watch_read || watch_write); if (watch_read && watch_write) return eWatchpointReadWrite; - else if (watch_read) + if (watch_read) return eWatchpointRead; else // Must be watch_write, then. return eWatchpointWrite; @@ -3354,8 +3355,8 @@ wp->GetByteSize()) == 0) { wp->SetEnabled(true, notify); return error; - } else - error.SetErrorString("sending gdb watchpoint packet failed"); + } + error.SetErrorString("sending gdb watchpoint packet failed"); } else error.SetErrorString("watchpoints not supported"); } else { @@ -3400,8 +3401,8 @@ wp->GetByteSize()) == 0) { wp->SetEnabled(false, notify); return error; - } else - error.SetErrorString("sending gdb watchpoint packet failed"); + } + error.SetErrorString("sending gdb watchpoint packet failed"); } // TODO: clear software watchpoints if we implement them } else { Index: source/Plugins/Process/gdb-remote/ThreadGDBRemote.cpp =================================================================== --- source/Plugins/Process/gdb-remote/ThreadGDBRemote.cpp +++ source/Plugins/Process/gdb-remote/ThreadGDBRemote.cpp @@ -86,8 +86,8 @@ if (CachedQueueInfoIsValid()) { if (m_dispatch_queue_name.empty()) return nullptr; - else - return m_dispatch_queue_name.c_str(); + + return m_dispatch_queue_name.c_str(); } // Always re-fetch the dispatch queue name since it can change Index: source/Plugins/Process/mach-core/ProcessMachCore.cpp =================================================================== --- source/Plugins/Process/mach-core/ProcessMachCore.cpp +++ source/Plugins/Process/mach-core/ProcessMachCore.cpp @@ -621,12 +621,11 @@ return m_mach_kernel_addr; } return m_dyld_addr; - } else { - if (m_dyld_addr != LLDB_INVALID_ADDRESS) { - return m_dyld_addr; - } - return m_mach_kernel_addr; } + if (m_dyld_addr != LLDB_INVALID_ADDRESS) { + return m_dyld_addr; + } + return m_mach_kernel_addr; } lldb_private::ObjectFile *ProcessMachCore::GetCoreObjectFile() { Index: source/Plugins/Process/minidump/MinidumpParser.cpp =================================================================== --- source/Plugins/Process/minidump/MinidumpParser.cpp +++ source/Plugins/Process/minidump/MinidumpParser.cpp @@ -87,8 +87,8 @@ // to match. if (arch.GetTriple().getVendor() == llvm::Triple::Apple) return UUID::fromData(pdb70_uuid->Uuid, sizeof(pdb70_uuid->Uuid)); - else - return UUID::fromData(pdb70_uuid, sizeof(*pdb70_uuid)); + + return UUID::fromData(pdb70_uuid, sizeof(*pdb70_uuid)); } } else if (cv_signature == CvSignature::ElfBuildId) return UUID::fromData(cv_record); @@ -445,8 +445,9 @@ info.SetMapped((entry->state != MemFree) ? yes : no); return info; - } else if (head > load_addr && - (next_entry == nullptr || head < next_entry->base_address)) { + } + if (head > load_addr && + (next_entry == nullptr || head < next_entry->base_address)) { // In case there is no region containing load_addr keep track of the // nearest region after load_addr so we can return the distance to it. next_entry = entry; Index: source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp =================================================================== --- source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp +++ source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp @@ -587,8 +587,8 @@ PythonFile new_file(file, mode); sys_module_dict.SetItemForKey(PythonString(py_name), new_file); return true; - } else - save_file.Reset(); + } + save_file.Reset(); return false; } @@ -1315,8 +1315,8 @@ bp_options->SetCallback(ScriptInterpreterPython::BreakpointCallbackFunction, baton_sp); return error; - } else - return error; + } + return error; } // Set a Python one-liner as the callback for the watchpoint. @@ -1936,8 +1936,8 @@ } if (should_step) return lldb::eStateStepping; - else - return lldb::eStateRunning; + + return lldb::eStateRunning; } StructuredData::GenericSP @@ -2014,8 +2014,8 @@ if (depth_as_int <= lldb::kLastSearchDepthKind) return (lldb::SearchDepth) depth_as_int; - else - return lldb::eSearchDepthModule; + + return lldb::eSearchDepthModule; } StructuredData::ObjectSP @@ -3046,13 +3046,12 @@ if (result_ptr) dest.assign(result_ptr); return true; - } else { - StreamString str_stream; - str_stream.Printf( - "Function %s was not found. Containing module might be missing.", item); - dest = str_stream.GetString(); - return false; } + StreamString str_stream; + str_stream.Printf( + "Function %s was not found. Containing module might be missing.", item); + dest = str_stream.GetString(); + return false; } bool ScriptInterpreterPython::GetShortHelpForCommandObject( Index: source/Plugins/StructuredData/DarwinLog/StructuredDataDarwinLog.cpp =================================================================== --- source/Plugins/StructuredData/DarwinLog/StructuredDataDarwinLog.cpp +++ source/Plugins/StructuredData/DarwinLog/StructuredDataDarwinLog.cpp @@ -89,8 +89,8 @@ auto find_it = options_map.find(debugger_wp); if (find_it != options_map.end()) return find_it->second; - else - return EnableOptionsSP(); + + return EnableOptionsSP(); } void SetGlobalEnableOptions(const DebuggerSP &debugger_sp, @@ -1272,8 +1272,8 @@ bool StructuredDataDarwinLog::GetEnabled(const ConstString &type_name) const { if (type_name == GetStaticPluginName()) return m_is_enabled; - else - return false; + + return false; } void StructuredDataDarwinLog::SetEnabled(bool enabled) { @@ -1410,9 +1410,8 @@ llvm::Triple::VendorType::Apple) { auto process_wp = ProcessWP(process.shared_from_this()); return StructuredDataPluginSP(new StructuredDataDarwinLog(process_wp)); - } else { - return StructuredDataPluginSP(); } + return StructuredDataPluginSP(); } void StructuredDataDarwinLog::DebuggerInitialize(Debugger &debugger) { Index: source/Plugins/SymbolFile/DWARF/DIERef.cpp =================================================================== --- source/Plugins/SymbolFile/DWARF/DIERef.cpp +++ source/Plugins/SymbolFile/DWARF/DIERef.cpp @@ -62,6 +62,6 @@ //---------------------------------------------------------------------- if (dwarf && die_offset != DW_INVALID_OFFSET) return dwarf->GetID() | die_offset; - else - return LLDB_INVALID_UID; + + return LLDB_INVALID_UID; } Index: source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp =================================================================== --- source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp +++ source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp @@ -110,10 +110,9 @@ // overlap and must be at a higher bit offset than any previous bitfield // + size. return (bit_size + bit_offset) <= next_bit_offset; - } else { - // If the this BitfieldInfo is not valid, then any offset isOK - return true; } + // If the this BitfieldInfo is not valid, then any offset isOK + return true; } }; @@ -3713,9 +3712,8 @@ if (IsSubroutine(candidate)) { if (candidate.GetReferencedDIE(DW_AT_abstract_origin)) { return candidate; - } else { - return DWARFDIE(); } + return DWARFDIE(); } } assert(0 && "Shouldn't call GetContainingFunctionWithAbstractOrigin on " @@ -3790,39 +3788,39 @@ static_cast(m_die_to_decl_ctx[die.GetDIE()]); if (namespace_decl) return namespace_decl; - else { - const char *namespace_name = die.GetName(); - clang::DeclContext *containing_decl_ctx = - GetClangDeclContextContainingDIE(die, nullptr); - namespace_decl = m_ast.GetUniqueNamespaceDeclaration(namespace_name, - containing_decl_ctx); - Log *log = - nullptr; // (LogChannelDWARF::GetLogIfAll(DWARF_LOG_DEBUG_INFO)); - if (log) { - SymbolFileDWARF *dwarf = die.GetDWARF(); - if (namespace_name) { - dwarf->GetObjectFile()->GetModule()->LogMessage( - log, "ASTContext => %p: 0x%8.8" PRIx64 - ": DW_TAG_namespace with DW_AT_name(\"%s\") => " - "clang::NamespaceDecl *%p (original = %p)", - static_cast(m_ast.getASTContext()), die.GetID(), - namespace_name, static_cast(namespace_decl), - static_cast(namespace_decl->getOriginalNamespace())); - } else { - dwarf->GetObjectFile()->GetModule()->LogMessage( - log, "ASTContext => %p: 0x%8.8" PRIx64 - ": DW_TAG_namespace (anonymous) => clang::NamespaceDecl *%p " - "(original = %p)", - static_cast(m_ast.getASTContext()), die.GetID(), - static_cast(namespace_decl), - static_cast(namespace_decl->getOriginalNamespace())); - } + + const char *namespace_name = die.GetName(); + clang::DeclContext *containing_decl_ctx = + GetClangDeclContextContainingDIE(die, nullptr); + namespace_decl = m_ast.GetUniqueNamespaceDeclaration(namespace_name, + containing_decl_ctx); + Log *log = nullptr; // (LogChannelDWARF::GetLogIfAll(DWARF_LOG_DEBUG_INFO)); + if (log) { + SymbolFileDWARF *dwarf = die.GetDWARF(); + if (namespace_name) { + dwarf->GetObjectFile()->GetModule()->LogMessage( + log, + "ASTContext => %p: 0x%8.8" PRIx64 + ": DW_TAG_namespace with DW_AT_name(\"%s\") => " + "clang::NamespaceDecl *%p (original = %p)", + static_cast(m_ast.getASTContext()), die.GetID(), + namespace_name, static_cast(namespace_decl), + static_cast(namespace_decl->getOriginalNamespace())); + } else { + dwarf->GetObjectFile()->GetModule()->LogMessage( + log, + "ASTContext => %p: 0x%8.8" PRIx64 + ": DW_TAG_namespace (anonymous) => clang::NamespaceDecl *%p " + "(original = %p)", + static_cast(m_ast.getASTContext()), die.GetID(), + static_cast(namespace_decl), + static_cast(namespace_decl->getOriginalNamespace())); + } } if (namespace_decl) LinkDeclContextToDIE((clang::DeclContext *)namespace_decl, die); return namespace_decl; - } } return nullptr; } Index: source/Plugins/SymbolFile/DWARF/DWARFAbbreviationDeclaration.cpp =================================================================== --- source/Plugins/SymbolFile/DWARF/DWARFAbbreviationDeclaration.cpp +++ source/Plugins/SymbolFile/DWARF/DWARFAbbreviationDeclaration.cpp @@ -53,10 +53,9 @@ } return m_tag != 0; - } else { - m_tag = 0; - m_has_children = 0; } + m_tag = 0; + m_has_children = 0; return false; } Index: source/Plugins/SymbolFile/DWARF/DWARFBaseDIE.cpp =================================================================== --- source/Plugins/SymbolFile/DWARF/DWARFBaseDIE.cpp +++ source/Plugins/SymbolFile/DWARF/DWARFBaseDIE.cpp @@ -31,8 +31,8 @@ dw_tag_t DWARFBaseDIE::Tag() const { if (m_die) return m_die->Tag(); - else - return 0; + + return 0; } const char *DWARFBaseDIE::GetTagAsCString() const { @@ -44,8 +44,8 @@ if (IsValid()) return m_die->GetAttributeValueAsString(GetDWARF(), GetCU(), attr, fail_value); - else - return fail_value; + + return fail_value; } uint64_t DWARFBaseDIE::GetAttributeValueAsUnsigned(const dw_attr_t attr, @@ -53,8 +53,8 @@ if (IsValid()) return m_die->GetAttributeValueAsUnsigned(GetDWARF(), GetCU(), attr, fail_value); - else - return fail_value; + + return fail_value; } int64_t DWARFBaseDIE::GetAttributeValueAsSigned(const dw_attr_t attr, @@ -62,8 +62,8 @@ if (IsValid()) return m_die->GetAttributeValueAsSigned(GetDWARF(), GetCU(), attr, fail_value); - else - return fail_value; + + return fail_value; } uint64_t DWARFBaseDIE::GetAttributeValueAsReference(const dw_attr_t attr, @@ -71,8 +71,8 @@ if (IsValid()) return m_die->GetAttributeValueAsReference(GetDWARF(), GetCU(), attr, fail_value); - else - return fail_value; + + return fail_value; } uint64_t DWARFBaseDIE::GetAttributeValueAsAddress(const dw_attr_t attr, @@ -80,8 +80,8 @@ if (IsValid()) return m_die->GetAttributeValueAsAddress(GetDWARF(), GetCU(), attr, fail_value); - else - return fail_value; + + return fail_value; } lldb::user_id_t DWARFBaseDIE::GetID() const { @@ -91,66 +91,66 @@ const char *DWARFBaseDIE::GetName() const { if (IsValid()) return m_die->GetName(GetDWARF(), m_cu); - else - return nullptr; + + return nullptr; } lldb::LanguageType DWARFBaseDIE::GetLanguage() const { if (IsValid()) return m_cu->GetLanguageType(); - else - return lldb::eLanguageTypeUnknown; + + return lldb::eLanguageTypeUnknown; } lldb::ModuleSP DWARFBaseDIE::GetModule() const { SymbolFileDWARF *dwarf = GetDWARF(); if (dwarf) return dwarf->GetObjectFile()->GetModule(); - else - return lldb::ModuleSP(); + + return lldb::ModuleSP(); } lldb_private::CompileUnit *DWARFBaseDIE::GetLLDBCompileUnit() const { if (IsValid()) return GetDWARF()->GetCompUnitForDWARFCompUnit(GetCU()); - else - return nullptr; + + return nullptr; } dw_offset_t DWARFBaseDIE::GetOffset() const { if (IsValid()) return m_die->GetOffset(); - else - return DW_INVALID_OFFSET; + + return DW_INVALID_OFFSET; } dw_offset_t DWARFBaseDIE::GetCompileUnitRelativeOffset() const { if (IsValid()) return m_die->GetOffset() - m_cu->GetOffset(); - else - return DW_INVALID_OFFSET; + + return DW_INVALID_OFFSET; } SymbolFileDWARF *DWARFBaseDIE::GetDWARF() const { if (m_cu) return m_cu->GetSymbolFileDWARF(); - else - return nullptr; + + return nullptr; } lldb_private::TypeSystem *DWARFBaseDIE::GetTypeSystem() const { if (m_cu) return m_cu->GetTypeSystem(); - else - return nullptr; + + return nullptr; } DWARFASTParser *DWARFBaseDIE::GetDWARFParser() const { lldb_private::TypeSystem *type_system = GetTypeSystem(); if (type_system) return type_system->GetDWARFParser(); - else - return nullptr; + + return nullptr; } bool DWARFBaseDIE::HasChildren() const { Index: source/Plugins/SymbolFile/DWARF/DWARFDIE.cpp =================================================================== --- source/Plugins/SymbolFile/DWARF/DWARFDIE.cpp +++ source/Plugins/SymbolFile/DWARF/DWARFDIE.cpp @@ -37,24 +37,24 @@ DWARFDIE::GetParent() const { if (IsValid()) return DWARFDIE(m_cu, m_die->GetParent()); - else - return DWARFDIE(); + + return DWARFDIE(); } DWARFDIE DWARFDIE::GetFirstChild() const { if (IsValid()) return DWARFDIE(m_cu, m_die->GetFirstChild()); - else - return DWARFDIE(); + + return DWARFDIE(); } DWARFDIE DWARFDIE::GetSibling() const { if (IsValid()) return DWARFDIE(m_cu, m_die->GetSibling()); - else - return DWARFDIE(); + + return DWARFDIE(); } DWARFDIE @@ -63,16 +63,16 @@ GetAttributeValueAsReference(attr, DW_INVALID_OFFSET); if (die_offset != DW_INVALID_OFFSET) return GetDIE(die_offset); - else - return DWARFDIE(); + + return DWARFDIE(); } DWARFDIE DWARFDIE::GetDIE(dw_offset_t die_offset) const { if (IsValid()) return m_cu->GetDIE(die_offset); - else - return DWARFDIE(); + + return DWARFDIE(); } DWARFDIE @@ -100,10 +100,10 @@ if (block_die && block_die != function_die) { if (cu->ContainsDIEOffset(block_die->GetOffset())) return DWARFDIE(cu, block_die); - else - return DWARFDIE(dwarf->DebugInfo()->GetCompileUnit( - DIERef(cu->GetOffset(), block_die->GetOffset())), - block_die); + + return DWARFDIE(dwarf->DebugInfo()->GetCompileUnit( + DIERef(cu->GetOffset(), block_die->GetOffset())), + block_die); } } } @@ -113,37 +113,37 @@ const char *DWARFDIE::GetMangledName() const { if (IsValid()) return m_die->GetMangledName(GetDWARF(), m_cu); - else - return nullptr; + + return nullptr; } const char *DWARFDIE::GetPubname() const { if (IsValid()) return m_die->GetPubname(GetDWARF(), m_cu); - else - return nullptr; + + return nullptr; } const char *DWARFDIE::GetQualifiedName(std::string &storage) const { if (IsValid()) return m_die->GetQualifiedName(GetDWARF(), m_cu, storage); - else - return nullptr; + + return nullptr; } lldb_private::Type *DWARFDIE::ResolveType() const { if (IsValid()) return GetDWARF()->ResolveType(*this, true); - else - return nullptr; + + return nullptr; } lldb_private::Type *DWARFDIE::ResolveTypeUID(const DIERef &die_ref) const { SymbolFileDWARF *dwarf = GetDWARF(); if (dwarf) return dwarf->ResolveTypeUID(dwarf->GetDIE(die_ref), true); - else - return nullptr; + + return nullptr; } void DWARFDIE::GetDeclContextDIEs(DWARFDIECollection &decl_context_dies) const { @@ -219,8 +219,8 @@ DWARFDIE::GetParentDeclContextDIE() const { if (IsValid()) return m_die->GetParentDeclContextDIE(GetDWARF(), m_cu); - else - return DWARFDIE(); + + return DWARFDIE(); } bool DWARFDIE::IsStructUnionOrClass() const { @@ -278,30 +278,30 @@ return m_die->GetDIENamesAndRanges( GetDWARF(), GetCU(), name, mangled, ranges, decl_file, decl_line, decl_column, call_file, call_line, call_column, frame_base); - } else - return false; + } + return false; } CompilerDecl DWARFDIE::GetDecl() const { DWARFASTParser *dwarf_ast = GetDWARFParser(); if (dwarf_ast) return dwarf_ast->GetDeclForUIDFromDWARF(*this); - else - return CompilerDecl(); + + return CompilerDecl(); } CompilerDeclContext DWARFDIE::GetDeclContext() const { DWARFASTParser *dwarf_ast = GetDWARFParser(); if (dwarf_ast) return dwarf_ast->GetDeclContextForUIDFromDWARF(*this); - else - return CompilerDeclContext(); + + return CompilerDeclContext(); } CompilerDeclContext DWARFDIE::GetContainingDeclContext() const { DWARFASTParser *dwarf_ast = GetDWARFParser(); if (dwarf_ast) return dwarf_ast->GetDeclContextContainingUIDFromDWARF(*this); - else - return CompilerDeclContext(); + + return CompilerDeclContext(); } Index: source/Plugins/SymbolFile/DWARF/DWARFDebugAbbrev.cpp =================================================================== --- source/Plugins/SymbolFile/DWARF/DWARFDebugAbbrev.cpp +++ source/Plugins/SymbolFile/DWARF/DWARFDebugAbbrev.cpp @@ -181,10 +181,9 @@ if (m_prev_abbr_offset_pos != end && m_prev_abbr_offset_pos->first == cu_abbr_offset) return &(m_prev_abbr_offset_pos->second); - else { - pos = m_abbrevCollMap.find(cu_abbr_offset); - m_prev_abbr_offset_pos = pos; - } + + pos = m_abbrevCollMap.find(cu_abbr_offset); + m_prev_abbr_offset_pos = pos; if (pos != m_abbrevCollMap.end()) return &(pos->second); Index: source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.cpp =================================================================== --- source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.cpp +++ source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.cpp @@ -175,8 +175,8 @@ DWARFUnit *DWARFDebugInfo::GetCompileUnit(const DIERef &die_ref) { if (die_ref.cu_offset == DW_INVALID_OFFSET) return GetCompileUnitContainingDIEOffset(die_ref.die_offset); - else - return GetCompileUnit(die_ref.cu_offset); + + return GetCompileUnit(die_ref.cu_offset); } DWARFUnit * Index: source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp =================================================================== --- source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp +++ source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp @@ -195,11 +195,10 @@ } *offset_ptr = offset; return true; - } else { - m_tag = 0; - m_has_children = false; - return true; // NULL debug tag entry } + m_tag = 0; + m_has_children = false; + return true; // NULL debug tag entry return false; } @@ -1178,14 +1177,13 @@ if (die.IsNULL()) { s.PutCString("NULL"); return true; - } else { - const char *name = die.GetAttributeValueAsString( - dwarf2Data, cu, DW_AT_name, nullptr, true); - if (name) { - s.PutCString(name); - return true; - } } + const char *name = die.GetAttributeValueAsString(dwarf2Data, cu, DW_AT_name, + nullptr, true); + if (name) { + s.PutCString(name); + return true; + } } return false; } @@ -1212,112 +1210,111 @@ if (die.IsNULL()) { s.PutCString("NULL"); return true; - } else { - const char *name = die.GetPubname(dwarf2Data, cu); - if (name) - s.PutCString(name); - else { - bool result = true; - const DWARFAbbreviationDeclaration *abbrevDecl = - die.GetAbbreviationDeclarationPtr(dwarf2Data, cu, offset); - - if (abbrevDecl == NULL) - return false; - - switch (abbrevDecl->Tag()) { - case DW_TAG_array_type: - break; // print out a "[]" after printing the full type of the element - // below - case DW_TAG_base_type: - s.PutCString("base "); - break; - case DW_TAG_class_type: - s.PutCString("class "); - break; - case DW_TAG_const_type: - s.PutCString("const "); - break; - case DW_TAG_enumeration_type: - s.PutCString("enum "); - break; - case DW_TAG_file_type: - s.PutCString("file "); - break; - case DW_TAG_interface_type: - s.PutCString("interface "); - break; - case DW_TAG_packed_type: - s.PutCString("packed "); - break; - case DW_TAG_pointer_type: - break; // print out a '*' after printing the full type below - case DW_TAG_ptr_to_member_type: - break; // print out a '*' after printing the full type below - case DW_TAG_reference_type: - break; // print out a '&' after printing the full type below - case DW_TAG_restrict_type: - s.PutCString("restrict "); - break; - case DW_TAG_set_type: - s.PutCString("set "); - break; - case DW_TAG_shared_type: - s.PutCString("shared "); - break; - case DW_TAG_string_type: - s.PutCString("string "); - break; - case DW_TAG_structure_type: - s.PutCString("struct "); - break; - case DW_TAG_subrange_type: - s.PutCString("subrange "); - break; - case DW_TAG_subroutine_type: - s.PutCString("function "); - break; - case DW_TAG_thrown_type: - s.PutCString("thrown "); - break; - case DW_TAG_union_type: - s.PutCString("union "); - break; - case DW_TAG_unspecified_type: - s.PutCString("unspecified "); - break; - case DW_TAG_volatile_type: - s.PutCString("volatile "); - break; - default: - return false; - } + } + const char *name = die.GetPubname(dwarf2Data, cu); + if (name) + s.PutCString(name); + else { + bool result = true; + const DWARFAbbreviationDeclaration *abbrevDecl = + die.GetAbbreviationDeclarationPtr(dwarf2Data, cu, offset); - // Follow the DW_AT_type if possible - DWARFFormValue form_value; - if (die.GetAttributeValue(dwarf2Data, cu, DW_AT_type, form_value)) { - uint64_t next_die_offset = form_value.Reference(); - result = AppendTypeName(dwarf2Data, cu, next_die_offset, s); - } + if (abbrevDecl == NULL) + return false; - switch (abbrevDecl->Tag()) { - case DW_TAG_array_type: - s.PutCString("[]"); - break; - case DW_TAG_pointer_type: - s.PutChar('*'); - break; - case DW_TAG_ptr_to_member_type: - s.PutChar('*'); - break; - case DW_TAG_reference_type: - s.PutChar('&'); - break; - default: - break; - } - return result; + switch (abbrevDecl->Tag()) { + case DW_TAG_array_type: + break; // print out a "[]" after printing the full type of the element + // below + case DW_TAG_base_type: + s.PutCString("base "); + break; + case DW_TAG_class_type: + s.PutCString("class "); + break; + case DW_TAG_const_type: + s.PutCString("const "); + break; + case DW_TAG_enumeration_type: + s.PutCString("enum "); + break; + case DW_TAG_file_type: + s.PutCString("file "); + break; + case DW_TAG_interface_type: + s.PutCString("interface "); + break; + case DW_TAG_packed_type: + s.PutCString("packed "); + break; + case DW_TAG_pointer_type: + break; // print out a '*' after printing the full type below + case DW_TAG_ptr_to_member_type: + break; // print out a '*' after printing the full type below + case DW_TAG_reference_type: + break; // print out a '&' after printing the full type below + case DW_TAG_restrict_type: + s.PutCString("restrict "); + break; + case DW_TAG_set_type: + s.PutCString("set "); + break; + case DW_TAG_shared_type: + s.PutCString("shared "); + break; + case DW_TAG_string_type: + s.PutCString("string "); + break; + case DW_TAG_structure_type: + s.PutCString("struct "); + break; + case DW_TAG_subrange_type: + s.PutCString("subrange "); + break; + case DW_TAG_subroutine_type: + s.PutCString("function "); + break; + case DW_TAG_thrown_type: + s.PutCString("thrown "); + break; + case DW_TAG_union_type: + s.PutCString("union "); + break; + case DW_TAG_unspecified_type: + s.PutCString("unspecified "); + break; + case DW_TAG_volatile_type: + s.PutCString("volatile "); + break; + default: + return false; + } + + // Follow the DW_AT_type if possible + DWARFFormValue form_value; + if (die.GetAttributeValue(dwarf2Data, cu, DW_AT_type, form_value)) { + uint64_t next_die_offset = form_value.Reference(); + result = AppendTypeName(dwarf2Data, cu, next_die_offset, s); + } + + switch (abbrevDecl->Tag()) { + case DW_TAG_array_type: + s.PutCString("[]"); + break; + case DW_TAG_pointer_type: + s.PutChar('*'); + break; + case DW_TAG_ptr_to_member_type: + s.PutChar('*'); + break; + case DW_TAG_reference_type: + s.PutChar('&'); + break; + default: + break; + } + return result; } - } } return false; } Index: source/Plugins/SymbolFile/DWARF/DWARFDebugLine.cpp =================================================================== --- source/Plugins/SymbolFile/DWARF/DWARFDebugLine.cpp +++ source/Plugins/SymbolFile/DWARF/DWARFDebugLine.cpp @@ -129,8 +129,8 @@ if (ParseStatementTable(debug_line_data, &offset, DumpStateToFile, log, nullptr)) return offset; - else - return debug_line_offset + 1; // Skip to next byte in .debug_line section + + return debug_line_offset + 1; // Skip to next byte in .debug_line section } return DW_INVALID_OFFSET; Index: source/Plugins/SymbolFile/DWARF/DWARFDebugMacinfoEntry.cpp =================================================================== --- source/Plugins/SymbolFile/DWARF/DWARFDebugMacinfoEntry.cpp +++ source/Plugins/SymbolFile/DWARF/DWARFDebugMacinfoEntry.cpp @@ -104,8 +104,8 @@ break; } return true; - } else - m_type_code = 0; + } + m_type_code = 0; return false; } Index: source/Plugins/SymbolFile/DWARF/DWARFDebugRanges.cpp =================================================================== --- source/Plugins/SymbolFile/DWARF/DWARFDebugRanges.cpp +++ source/Plugins/SymbolFile/DWARF/DWARFDebugRanges.cpp @@ -97,7 +97,8 @@ if (begin == 0 && end == 0) { s.PutCString(" End"); break; - } else if (begin == LLDB_INVALID_ADDRESS) { + } + if (begin == LLDB_INVALID_ADDRESS) { // A base address selection entry base_addr = end; s.Address(base_addr, sizeof(dw_addr_t), " Base address = "); Index: source/Plugins/SymbolFile/DWARF/DWARFDeclContext.h =================================================================== --- source/Plugins/SymbolFile/DWARF/DWARFDeclContext.h +++ source/Plugins/SymbolFile/DWARF/DWARFDeclContext.h @@ -32,7 +32,7 @@ bool NameMatches(const Entry &rhs) const { if (name == rhs.name) return true; - else if (name && rhs.name) + if (name && rhs.name) return strcmp(name, rhs.name) == 0; return false; } Index: source/Plugins/SymbolFile/DWARF/DWARFFormValue.cpp =================================================================== --- source/Plugins/SymbolFile/DWARF/DWARFFormValue.cpp +++ source/Plugins/SymbolFile/DWARF/DWARFFormValue.cpp @@ -544,7 +544,8 @@ if (m_form == DW_FORM_string) { return m_value.value.cstr; - } else if (m_form == DW_FORM_strp) { + } + if (m_form == DW_FORM_strp) { if (!symbol_file) return nullptr; @@ -715,7 +716,7 @@ const char *b_string = b_value.AsCString(); if (a_string == b_string) return 0; - else if (a_string && b_string) + if (a_string && b_string) return strcmp(a_string, b_string); else if (a_string == NULL) return -1; // A string is NULL, and B is valid Index: source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp =================================================================== --- source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp +++ source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp @@ -431,8 +431,8 @@ m_base_obj_offset != DW_INVALID_OFFSET ? m_base_obj_offset : m_offset; if (m_dwarf) return DIERef(local_id, local_id).GetUID(m_dwarf); - else - return local_id; + + return local_id; } dw_offset_t DWARFUnit::GetNextCompileUnitOffset() const { @@ -574,8 +574,8 @@ TypeSystem *DWARFUnit::GetTypeSystem() { if (m_dwarf) return m_dwarf->GetTypeSystemForLanguage(GetLanguageType()); - else - return nullptr; + + return nullptr; } DWARFFormValue::FixedFormSizes DWARFUnit::GetFixedFormSizes() { @@ -665,8 +665,8 @@ if (major_version > 425 || (major_version == 425 && GetProducerVersionUpdate() >= 13)) return true; - else - return false; + + return false; } return true; // Assume all other compilers didn't have incorrect ObjC bitfield // info Index: source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.cpp =================================================================== --- source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.cpp +++ source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.cpp @@ -180,9 +180,8 @@ // If we find the complete version we're done. offsets.push_back(ref); return; - } else { - incomplete_types.push_back(ref); } + incomplete_types.push_back(ref); } offsets.insert(offsets.end(), incomplete_types.begin(), Index: source/Plugins/SymbolFile/DWARF/HashedNameToDIE.cpp =================================================================== --- source/Plugins/SymbolFile/DWARF/HashedNameToDIE.cpp +++ source/Plugins/SymbolFile/DWARF/HashedNameToDIE.cpp @@ -81,11 +81,11 @@ die_offsets.emplace_back(die_info_array[i].cu_offset, die_info_array[i].offset); return; - } else { - // Put the one true definition as the first entry so it matches first - die_offsets.emplace(die_offsets.begin(), die_info_array[i].cu_offset, - die_info_array[i].offset); } + // Put the one true definition as the first entry so it matches first + die_offsets.emplace(die_offsets.begin(), die_info_array[i].cu_offset, + die_info_array[i].offset); + } else { die_offsets.emplace_back(die_info_array[i].cu_offset, die_info_array[i].offset); @@ -432,9 +432,9 @@ if (match) return eResultKeyMatch; // The key (cstring) matches and we have lookup // results! - else - return eResultKeyMismatch; // The key doesn't match, this function will - // get called + + return eResultKeyMismatch; // The key doesn't match, this function will + // get called // again for the next key/value or the key terminator which in our case is // a zero .debug_str offset. } else { @@ -493,9 +493,9 @@ if (match) return eResultKeyMatch; // The key (cstring) matches and we have lookup // results! - else - return eResultKeyMismatch; // The key doesn't match, this function will - // get called + + return eResultKeyMismatch; // The key doesn't match, this function will + // get called // again for the next key/value or the key terminator which in our case is // a zero .debug_str offset. } else { Index: source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp =================================================================== --- source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp +++ source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp @@ -265,8 +265,8 @@ SymbolFileDWARFDebugMap *debug_map_symfile = GetDebugMapSymfile(); if (debug_map_symfile) return debug_map_symfile->GetTypeList(); - else - return m_obj_file->GetModule()->GetTypeList(); + + return m_obj_file->GetModule()->GetTypeList(); } void SymbolFileDWARF::GetTypes(const DWARFDIE &die, dw_offset_t min_die_offset, dw_offset_t max_die_offset, uint32_t type_mask, @@ -430,8 +430,8 @@ SymbolFileDWARFDebugMap *debug_map_symfile = GetDebugMapSymfile(); if (debug_map_symfile) return debug_map_symfile->GetUniqueDWARFASTTypeMap(); - else - return m_unique_ast_type_map; + + return m_unique_ast_type_map; } TypeSystem *SymbolFileDWARF::GetTypeSystemForLanguage(LanguageType language) { @@ -801,7 +801,8 @@ if (dwarf_cu->GetSymbolFileDWARF() != this) { return dwarf_cu->GetSymbolFileDWARF()->ParseCompileUnit(dwarf_cu, cu_idx); - } else if (dwarf_cu->GetOffset() == 0 && GetDebugMapSymfile()) { + } + if (dwarf_cu->GetOffset() == 0 && GetDebugMapSymfile()) { // Let the debug map create the compile unit cu_sp = m_debug_map_symfile->GetCompileUnit(this); dwarf_cu->SetUserData(cu_sp.get()); @@ -916,8 +917,8 @@ DWARFUnit *dwarf_cu = GetDWARFCompileUnit(sc.comp_unit); if (dwarf_cu) return dwarf_cu->GetLanguageType(); - else - return eLanguageTypeUnknown; + + return eLanguageTypeUnknown; } size_t SymbolFileDWARF::ParseCompileUnitFunctions(const SymbolContext &sc) { @@ -1410,8 +1411,8 @@ DWARFDIE type_die = GetDIEFromUID(type_uid); if (type_die) return type_die.ResolveType(); - else - return nullptr; + + return nullptr; } llvm::Optional @@ -1421,8 +1422,8 @@ DWARFDIE type_die = GetDIEFromUID(type_uid); if (type_die) return DWARFASTParser::ParseChildArrayInfo(type_die, exe_ctx); - else - return llvm::None; + + return llvm::None; } Type *SymbolFileDWARF::ResolveTypeUID(const DIERef &die_ref) { @@ -1601,8 +1602,8 @@ const auto &pos = m_external_type_modules.find(name); if (pos != m_external_type_modules.end()) return pos->second; - else - return lldb::ModuleSP(); + + return lldb::ModuleSP(); } DWARFDIE @@ -1610,8 +1611,8 @@ DWARFDebugInfo *debug_info = DebugInfo(); if (debug_info) return debug_info->GetDIE(die_ref); - else - return DWARFDIE(); + + return DWARFDIE(); } std::unique_ptr @@ -2459,8 +2460,8 @@ // Make sure we haven't already searched this SymbolFile before... if (searched_symbol_files.count(this)) return 0; - else - searched_symbol_files.insert(this); + + searched_symbol_files.insert(this); DWARFDebugInfo *info = DebugInfo(); if (info == NULL) @@ -2529,23 +2530,22 @@ } } return num_matches; - } else { - UpdateExternalModuleListIfNeeded(); - - for (const auto &pair : m_external_type_modules) { - ModuleSP external_module_sp = pair.second; - if (external_module_sp) { - SymbolVendor *sym_vendor = external_module_sp->GetSymbolVendor(); - if (sym_vendor) { - const uint32_t num_external_matches = - sym_vendor->FindTypes(sc, name, parent_decl_ctx, append, - max_matches, searched_symbol_files, types); - if (num_external_matches) - return num_external_matches; - } + } + UpdateExternalModuleListIfNeeded(); + + for (const auto &pair : m_external_type_modules) { + ModuleSP external_module_sp = pair.second; + if (external_module_sp) { + SymbolVendor *sym_vendor = external_module_sp->GetSymbolVendor(); + if (sym_vendor) { + const uint32_t num_external_matches = + sym_vendor->FindTypes(sc, name, parent_decl_ctx, append, + max_matches, searched_symbol_files, types); + if (num_external_matches) + return num_external_matches; } } - } + } return 0; } Index: source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp =================================================================== --- source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp +++ source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp @@ -1192,8 +1192,8 @@ searched_symbol_files, types); if (types.GetSize() >= max_matches) return true; - else - return false; + + return false; }); } Index: source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.cpp =================================================================== --- source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.cpp +++ source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.cpp @@ -64,8 +64,8 @@ // Only dwo files with 1 compile unit is supported if (GetNumCompileUnits() == 1) return DebugInfo()->GetCompileUnitAtIndex(0); - else - return nullptr; + + return nullptr; } DWARFUnit * Index: source/Symbol/ArmUnwindInfo.cpp =================================================================== --- source/Symbol/ArmUnwindInfo.cpp +++ source/Symbol/ArmUnwindInfo.cpp @@ -152,18 +152,18 @@ // 10000000 00000000 // Refuse to unwind (for example, out of a cleanup) (see remark a) return false; - } else { - // 1000iiii iiiiiiii (i not all 0) - // Pop up to 12 integer registers under masks {r15-r12}, {r11-r4} (see - // remark b) - uint16_t regs = ((byte1 & 0x0f) << 8) | byte2; - for (uint8_t i = 0; i < 12; ++i) { - if (regs & (1 << i)) { - register_offsets.emplace_back(dwarf_r4 + i, vsp); - vsp += 4; - } - } } + // 1000iiii iiiiiiii (i not all 0) + // Pop up to 12 integer registers under masks {r15-r12}, {r11-r4} (see + // remark b) + uint16_t regs = ((byte1 & 0x0f) << 8) | byte2; + for (uint8_t i = 0; i < 12; ++i) { + if (regs & (1 << i)) { + register_offsets.emplace_back(dwarf_r4 + i, vsp); + vsp += 4; + } + } + } else if ((byte1 & 0xff) == 0x9d) { // 10011101 // Reserved as prefix for ARM register to register moves @@ -208,7 +208,8 @@ // 10110001 00000000 // Spare (see remark f) return false; - } else if ((byte2 & 0xf0) == 0x00) { + } + if ((byte2 & 0xf0) == 0x00) { // 10110001 0000iiii (i not all 0) // Pop integer registers under mask {r3, r2, r1, r0} for (uint8_t i = 0; i < 4; ++i) { Index: source/Symbol/Block.cpp =================================================================== --- source/Symbol/Block.cpp +++ source/Symbol/Block.cpp @@ -205,8 +205,8 @@ if (parent_block) { if (parent_block->GetInlinedFunctionInfo()) return parent_block; - else - return parent_block->GetInlinedParent(); + + return parent_block->GetInlinedParent(); } return nullptr; } Index: source/Symbol/ClangASTContext.cpp =================================================================== --- source/Symbol/ClangASTContext.cpp +++ source/Symbol/ClangASTContext.cpp @@ -176,8 +176,8 @@ if (baseDtorDecl->isVirtual()) { path.Decls = baseDtorDecl; return true; - } else - return false; + } + return false; } // Otherwise, search for name in the base class. @@ -710,7 +710,8 @@ ast_sp->SetArchitecture(fixed_arch); } return ast_sp; - } else if (target && target->IsValid()) { + } + if (target && target->IsValid()) { std::shared_ptr ast_sp( new ClangASTContextForExpressions(*target)); if (ast_sp) { @@ -1361,7 +1362,8 @@ if (type_name) { if (streq(type_name, "char16_t")) { return CompilerType(ast, ast->Char16Ty); - } else if (streq(type_name, "char32_t")) { + } + if (streq(type_name, "char32_t")) { return CompilerType(ast, ast->Char32Ty); } } @@ -1751,8 +1753,8 @@ return unary; if (num_params == 2) return binary; - else - return false; + + return false; } bool ClangASTContext::CheckOverloadedOperatorKindParameterCount( @@ -2252,20 +2254,18 @@ return CompilerType( ast, ast->getExtVectorType(ClangUtil::GetQualType(element_type), element_count)); - } else { + } llvm::APInt ap_element_count(64, element_count); if (element_count == 0) { return CompilerType(ast, ast->getIncompleteArrayType( ClangUtil::GetQualType(element_type), clang::ArrayType::Normal, 0)); - } else { - return CompilerType( - ast, ast->getConstantArrayType(ClangUtil::GetQualType(element_type), - ap_element_count, - clang::ArrayType::Normal, 0)); } - } + return CompilerType( + ast, ast->getConstantArrayType(ClangUtil::GetQualType(element_type), + ap_element_count, + clang::ArrayType::Normal, 0)); } return CompilerType(); } @@ -2542,8 +2542,9 @@ ast_source->CompleteType(tag_decl); return !tag_decl->getTypeForDecl()->isIncompleteType(); - } else if (clang::ObjCInterfaceDecl *objc_interface_decl = - llvm::dyn_cast(decl)) { + } + if (clang::ObjCInterfaceDecl *objc_interface_decl = + llvm::dyn_cast(decl)) { if (objc_interface_decl->getDefinition()) return true; @@ -2581,8 +2582,8 @@ if (external_source && external_source->HasMetadata(object)) return external_source->GetMetadata(object); - else - return nullptr; + + return nullptr; } clang::DeclContext * @@ -3182,18 +3183,17 @@ if (field_qual_type->isFloatingType()) { if (field_qual_type->isComplexType()) return 0; + + if (num_fields == 0) + base_qual_type = field_qual_type; else { - if (num_fields == 0) - base_qual_type = field_qual_type; - else { - if (is_hva) - return 0; - is_hfa = true; - if (field_qual_type.getTypePtr() != - base_qual_type.getTypePtr()) - return 0; + if (is_hva) + return 0; + is_hfa = true; + if (field_qual_type.getTypePtr() != base_qual_type.getTypePtr()) + return 0; } - } + } else if (field_qual_type->isVectorType() || field_qual_type->isExtVectorType()) { if (num_fields == 0) { @@ -3657,18 +3657,18 @@ if (tag_decl) return tag_decl->isCompleteDefinition(); return false; - } else { - const clang::ObjCObjectType *objc_class_type = - llvm::dyn_cast(qual_type); - if (objc_class_type) { - clang::ObjCInterfaceDecl *class_interface_decl = - objc_class_type->getInterface(); - if (class_interface_decl) - return class_interface_decl->getDefinition() != nullptr; - return false; - } } - return true; + const clang::ObjCObjectType *objc_class_type = + llvm::dyn_cast(qual_type); + if (objc_class_type) { + clang::ObjCInterfaceDecl *class_interface_decl = + objc_class_type->getInterface(); + if (class_interface_decl) + return class_interface_decl->getDefinition() != nullptr; + return false; + } + + return true; } bool ClangASTContext::IsObjCClassType(const CompilerType &type) { @@ -4397,7 +4397,7 @@ const clang::RecordDecl *record_decl = record_type->getDecl(); if (record_decl->isUnion()) return lldb::eTypeClassUnion; - else if (record_decl->isStruct()) + if (record_decl->isStruct()) return lldb::eTypeClassStruct; else return lldb::eTypeClassClass; @@ -4524,11 +4524,11 @@ ast_ctx, ast_ctx->getConstantArrayType( qual_type, llvm::APInt(64, size), clang::ArrayType::ArraySizeModifier::Normal, 0)); - else - return CompilerType( - ast_ctx, - ast_ctx->getIncompleteArrayType( - qual_type, clang::ArrayType::ArraySizeModifier::Normal, 0)); + + return CompilerType( + ast_ctx, + ast_ctx->getIncompleteArrayType( + qual_type, clang::ArrayType::ArraySizeModifier::Normal, 0)); } } @@ -4824,8 +4824,8 @@ if (kind == eMemberFunctionKindUnknown) return TypeMemberFunctionImpl(); - else - return TypeMemberFunctionImpl(clang_type, clang_decl, name, kind); + + return TypeMemberFunctionImpl(clang_type, clang_decl, name, kind); } CompilerType @@ -4903,8 +4903,8 @@ return CompilerType(this, getASTContext() ->getLValueReferenceType(GetQualType(type)) .getAsOpaquePtr()); - else - return CompilerType(); + + return CompilerType(); } CompilerType @@ -4913,8 +4913,8 @@ return CompilerType(this, getASTContext() ->getRValueReferenceType(GetQualType(type)) .getAsOpaquePtr()); - else - return CompilerType(); + + return CompilerType(); } CompilerType @@ -5438,8 +5438,8 @@ case clang::Type::Complex: { if (qual_type->isComplexType()) return lldb::eFormatComplex; - else - return lldb::eFormatComplexInteger; + + return lldb::eFormatComplexInteger; } case clang::Type::ObjCInterface: break; @@ -6876,13 +6876,12 @@ child_bitfield_bit_size, child_bitfield_bit_offset, child_is_base_class, tmp_child_is_deref_of_parent, valobj, language_flags); - } else { - child_is_deref_of_parent = true; - const char *parent_name = - valobj ? valobj->GetName().GetCString() : NULL; - if (parent_name) { - child_name.assign(1, '*'); - child_name += parent_name; + } + child_is_deref_of_parent = true; + const char *parent_name = valobj ? valobj->GetName().GetCString() : NULL; + if (parent_name) { + child_name.assign(1, '*'); + child_name += parent_name; } // We have a pointer to an simple type @@ -6892,7 +6891,6 @@ child_byte_offset = 0; return pointee_clang_type; } - } } break; @@ -6950,14 +6948,13 @@ child_bitfield_bit_size, child_bitfield_bit_offset, child_is_base_class, tmp_child_is_deref_of_parent, valobj, language_flags); - } else { - child_is_deref_of_parent = true; + } + child_is_deref_of_parent = true; - const char *parent_name = - valobj ? valobj->GetName().GetCString() : NULL; - if (parent_name) { - child_name.assign(1, '*'); - child_name += parent_name; + const char *parent_name = valobj ? valobj->GetName().GetCString() : NULL; + if (parent_name) { + child_name.assign(1, '*'); + child_name += parent_name; } // We have a pointer to an simple type @@ -6967,8 +6964,8 @@ child_byte_offset = 0; return pointee_clang_type; } - } - break; + + break; } case clang::Type::LValueReference: @@ -6987,12 +6984,11 @@ child_bitfield_bit_size, child_bitfield_bit_offset, child_is_base_class, tmp_child_is_deref_of_parent, valobj, language_flags); - } else { - const char *parent_name = - valobj ? valobj->GetName().GetCString() : NULL; - if (parent_name) { - child_name.assign(1, '&'); - child_name += parent_name; + } + const char *parent_name = valobj ? valobj->GetName().GetCString() : NULL; + if (parent_name) { + child_name.assign(1, '&'); + child_name += parent_name; } // We have a pointer to an simple type @@ -7002,7 +6998,6 @@ child_byte_offset = 0; return pointee_clang_type; } - } } break; @@ -7219,13 +7214,12 @@ if (child_idx == UINT32_MAX) { child_indexes.clear(); return 0; - } else { - child_indexes.push_back(child_idx); - parent_record_decl = llvm::cast( - elem.Base->getType() - ->getAs() - ->getDecl()); } + child_indexes.push_back(child_idx); + parent_record_decl = llvm::cast( + elem.Base->getType() + ->getAs() + ->getDecl()); } for (clang::NamedDecl *path_decl : path->Decls) { child_idx = GetIndexForRecordChild( @@ -7233,9 +7227,8 @@ if (child_idx == UINT32_MAX) { child_indexes.clear(); return 0; - } else { - child_indexes.push_back(child_idx); } + child_indexes.push_back(child_idx); } } return child_indexes.size(); @@ -7584,24 +7577,24 @@ if (pointee_type.IsAggregateType()) { return pointee_type.GetIndexOfChildWithName(name, omit_empty_base_classes); - } else { - // if (parent_name) - // { - // child_name.assign(1, '*'); - // child_name += parent_name; - // } - // - // // We have a pointer to an simple type - // if (idx == 0) - // { - // std::pair clang_type_info - // = ast->getTypeInfo(pointee_type); - // assert(clang_type_info.first % 8 == 0); - // child_byte_size = clang_type_info.first / 8; - // child_byte_offset = 0; - // return pointee_type.getAsOpaquePtr(); - // } } + // if (parent_name) + // { + // child_name.assign(1, '*'); + // child_name += parent_name; + // } + // + // // We have a pointer to an simple type + // if (idx == 0) + // { + // std::pair clang_type_info + // = ast->getTypeInfo(pointee_type); + // assert(clang_type_info.first % 8 == 0); + // child_byte_size = clang_type_info.first / 8; + // child_byte_offset = 0; + // return pointee_type.getAsOpaquePtr(); + // } + } break; case clang::Type::Auto: @@ -7832,8 +7825,8 @@ clang::QualType qual_type = ClangUtil::GetCanonicalQualType(type); if (qual_type.isNull()) return nullptr; - else - return qual_type->getAsTagDecl(); + + return qual_type->getAsTagDecl(); } clang::TypedefNameDecl * @@ -9279,49 +9272,48 @@ LLDB_INVALID_ADDRESS, 0, 0); s->PutChar('"'); return; - } else { - CompilerType element_clang_type(getASTContext(), element_qual_type); - lldb::Format element_format = element_clang_type.GetFormat(); - - for (element_idx = 0; element_idx < element_count; ++element_idx) { - // Print the starting squiggly bracket (if this is the first member) or - // comman (for member 2 and beyong) for the struct/union/class member. - if (element_idx == 0) - s->PutChar('{'); - else - s->PutChar(','); - - // Indent and print the index - s->Printf("\n%*s[%u] ", depth + DEPTH_INCREMENT, "", element_idx); - - // Figure out the field offset within the current struct/union/class - // type - element_offset = element_idx * element_stride; + } + CompilerType element_clang_type(getASTContext(), element_qual_type); + lldb::Format element_format = element_clang_type.GetFormat(); - // Dump the value of the member - element_clang_type.DumpValue( - exe_ctx, - s, // Stream to dump to - element_format, // The format with which to display the element - data, // Data buffer containing all bytes for this type - data_byte_offset + - element_offset, // Offset into "data" where to grab value from - element_byte_size, // Size of this type in bytes - 0, // Bitfield bit size - 0, // Bitfield bit offset - show_types, // Boolean indicating if we should show the variable - // types - show_summary, // Boolean indicating if we should show a summary for - // the current type - verbose, // Verbose output? - depth + DEPTH_INCREMENT); // Scope depth for any types that have - // children + for (element_idx = 0; element_idx < element_count; ++element_idx) { + // Print the starting squiggly bracket (if this is the first member) or + // comman (for member 2 and beyong) for the struct/union/class member. + if (element_idx == 0) + s->PutChar('{'); + else + s->PutChar(','); + + // Indent and print the index + s->Printf("\n%*s[%u] ", depth + DEPTH_INCREMENT, "", element_idx); + + // Figure out the field offset within the current struct/union/class + // type + element_offset = element_idx * element_stride; + + // Dump the value of the member + element_clang_type.DumpValue( + exe_ctx, + s, // Stream to dump to + element_format, // The format with which to display the element + data, // Data buffer containing all bytes for this type + data_byte_offset + + element_offset, // Offset into "data" where to grab value from + element_byte_size, // Size of this type in bytes + 0, // Bitfield bit size + 0, // Bitfield bit offset + show_types, // Boolean indicating if we should show the variable + // types + show_summary, // Boolean indicating if we should show a summary for + // the current type + verbose, // Verbose output? + depth + DEPTH_INCREMENT); // Scope depth for any types that have + // children } // Indent the trailing squiggly bracket if (element_idx > 0) s->Printf("\n%*s}", depth, ""); - } } return; @@ -9450,34 +9442,34 @@ return false; if (IsAggregateType(type)) { return false; - } else { - clang::QualType qual_type(GetQualType(type)); + } + clang::QualType qual_type(GetQualType(type)); - const clang::Type::TypeClass type_class = qual_type->getTypeClass(); - switch (type_class) { - case clang::Type::Typedef: { - clang::QualType typedef_qual_type = - llvm::cast(qual_type) - ->getDecl() - ->getUnderlyingType(); - CompilerType typedef_clang_type(getASTContext(), typedef_qual_type); - if (format == eFormatDefault) - format = typedef_clang_type.GetFormat(); - clang::TypeInfo typedef_type_info = - getASTContext()->getTypeInfo(typedef_qual_type); - uint64_t typedef_byte_size = typedef_type_info.Width / 8; - - return typedef_clang_type.DumpTypeValue( - s, - format, // The format with which to display the element - data, // Data buffer containing all bytes for this type - byte_offset, // Offset into "data" where to grab value from - typedef_byte_size, // Size of this type in bytes - bitfield_bit_size, // Size in bits of a bitfield value, if zero don't + const clang::Type::TypeClass type_class = qual_type->getTypeClass(); + switch (type_class) { + case clang::Type::Typedef: { + clang::QualType typedef_qual_type = + llvm::cast(qual_type) + ->getDecl() + ->getUnderlyingType(); + CompilerType typedef_clang_type(getASTContext(), typedef_qual_type); + if (format == eFormatDefault) + format = typedef_clang_type.GetFormat(); + clang::TypeInfo typedef_type_info = + getASTContext()->getTypeInfo(typedef_qual_type); + uint64_t typedef_byte_size = typedef_type_info.Width / 8; + + return typedef_clang_type.DumpTypeValue( + s, + format, // The format with which to display the element + data, // Data buffer containing all bytes for this type + byte_offset, // Offset into "data" where to grab value from + typedef_byte_size, // Size of this type in bytes + bitfield_bit_size, // Size in bits of a bitfield value, if zero don't // treat as a bitfield - bitfield_bit_offset, // Offset in bits of a bitfield value if - // bitfield_bit_size != 0 - exe_scope); + bitfield_bit_offset, // Offset in bits of a bitfield value if + // bitfield_bit_size != 0 + exe_scope); } break; case clang::Type::Enum: @@ -9589,8 +9581,8 @@ } break; } - } - return 0; + + return 0; } void ClangASTContext::DumpSummary(lldb::opaque_compiler_type_t type, @@ -9930,8 +9922,8 @@ if (opaque_decl) return CompilerDeclContext(this, ((clang::Decl *)opaque_decl)->getDeclContext()); - else - return CompilerDeclContext(); + + return CompilerDeclContext(); } CompilerType ClangASTContext::DeclGetFunctionReturnType(void *opaque_decl) { @@ -9941,8 +9933,8 @@ if (clang::ObjCMethodDecl *objc_method = llvm::dyn_cast((clang::Decl *)opaque_decl)) return CompilerType(this, objc_method->getReturnType().getAsOpaquePtr()); - else - return CompilerType(); + + return CompilerType(); } size_t ClangASTContext::DeclGetFunctionNumArguments(void *opaque_decl) { @@ -9952,8 +9944,8 @@ if (clang::ObjCMethodDecl *objc_method = llvm::dyn_cast((clang::Decl *)opaque_decl)) return objc_method->param_size(); - else - return 0; + + return 0; } CompilerType ClangASTContext::DeclGetFunctionArgumentType(void *opaque_decl, @@ -10162,8 +10154,8 @@ bool ClangASTContext::DeclContextIsStructUnionOrClass(void *opaque_decl_ctx) { if (opaque_decl_ctx) return ((clang::DeclContext *)opaque_decl_ctx)->isRecord(); - else - return false; + + return false; } ConstString ClangASTContext::DeclContextGetName(void *opaque_decl_ctx) { @@ -10202,8 +10194,9 @@ if (language_object_name_ptr) language_object_name_ptr->SetCString("self"); return true; - } else if (CXXMethodDecl *cxx_method = - llvm::dyn_cast(decl_ctx)) { + } + if (CXXMethodDecl *cxx_method = + llvm::dyn_cast(decl_ctx)) { if (is_instance_method_ptr) *is_instance_method_ptr = cxx_method->isInstance(); if (language_ptr) Index: source/Symbol/ClangASTImporter.cpp =================================================================== --- source/Symbol/ClangASTImporter.cpp +++ source/Symbol/ClangASTImporter.cpp @@ -655,9 +655,8 @@ } return true; - } else { - return false; } + return false; } return true; @@ -679,8 +678,8 @@ if (ObjCInterfaceDecl *objc_interface_decl = objc_object_type->getInterface()) return CompleteObjCInterfaceDecl(objc_interface_decl); - else - return false; + + return false; } if (const ArrayType *array_type = type->getAsArrayTypeUnsafe()) { return RequireCompleteType(array_type->getElementType()); @@ -697,8 +696,8 @@ if (decl_origin.Valid()) return ClangASTContext::GetMetadata(decl_origin.ctx, decl_origin.decl); - else - return ClangASTContext::GetMetadata(&decl->getASTContext(), decl); + + return ClangASTContext::GetMetadata(&decl->getASTContext(), decl); } ClangASTImporter::DeclOrigin @@ -711,8 +710,8 @@ if (iter != origins.end()) return iter->second; - else - return DeclOrigin(); + + return DeclOrigin(); } void ClangASTImporter::SetDeclOrigin(const clang::Decl *decl, @@ -748,8 +747,8 @@ if (iter != namespace_maps.end()) return iter->second; - else - return NamespaceMapSP(); + + return NamespaceMapSP(); } void ClangASTImporter::BuildNamespaceMap(const clang::NamespaceDecl *decl) { Index: source/Symbol/ClangExternalASTSourceCommon.cpp =================================================================== --- source/Symbol/ClangExternalASTSourceCommon.cpp +++ source/Symbol/ClangExternalASTSourceCommon.cpp @@ -38,9 +38,8 @@ if (iter != source_map.end()) { return iter->second; - } else { - return nullptr; } + return nullptr; } ClangExternalASTSourceCommon::ClangExternalASTSourceCommon() @@ -60,8 +59,8 @@ ClangExternalASTSourceCommon::GetMetadata(const void *object) { if (HasMetadata(object)) return &m_metadata[object]; - else - return nullptr; + + return nullptr; } void ClangExternalASTSourceCommon::SetMetadata(const void *object, Index: source/Symbol/CompactUnwindInfo.cpp =================================================================== --- source/Symbol/CompactUnwindInfo.cpp +++ source/Symbol/CompactUnwindInfo.cpp @@ -442,9 +442,9 @@ if (mid != last && entry_func_end_offset) *entry_func_end_offset = next_func_offset; return first_entry + (mid * 8); - } else { - low = mid + 1; } + low = mid + 1; + } else { high = mid; } @@ -481,9 +481,9 @@ if (mid != last && entry_func_end_offset) *entry_func_end_offset = next_func_offset; return UNWIND_INFO_COMPRESSED_ENTRY_ENCODING_INDEX(entry); - } else { - low = mid + 1; } + low = mid + 1; + } else { high = mid; } @@ -605,7 +605,8 @@ } } return true; - } else if (kind == UNWIND_SECOND_LEVEL_COMPRESSED) { + } + if (kind == UNWIND_SECOND_LEVEL_COMPRESSED) { // struct unwind_info_compressed_second_level_page_header { // uint32_t kind; // UNWIND_SECOND_LEVEL_COMPRESSED // uint16_t entryPageOffset; // offset from this 2nd lvl page Index: source/Symbol/CompilerDeclContext.cpp =================================================================== --- source/Symbol/CompilerDeclContext.cpp +++ source/Symbol/CompilerDeclContext.cpp @@ -20,8 +20,8 @@ if (IsValid()) return m_type_system->DeclContextFindDeclByName(m_opaque_decl_ctx, name, ignore_using_decls); - else - return std::vector(); + + return std::vector(); } bool CompilerDeclContext::IsClang() const { @@ -31,22 +31,22 @@ ConstString CompilerDeclContext::GetName() const { if (IsValid()) return m_type_system->DeclContextGetName(m_opaque_decl_ctx); - else - return ConstString(); + + return ConstString(); } ConstString CompilerDeclContext::GetScopeQualifiedName() const { if (IsValid()) return m_type_system->DeclContextGetScopeQualifiedName(m_opaque_decl_ctx); - else - return ConstString(); + + return ConstString(); } bool CompilerDeclContext::IsStructUnionOrClass() const { if (IsValid()) return m_type_system->DeclContextIsStructUnionOrClass(m_opaque_decl_ctx); - else - return false; + + return false; } bool CompilerDeclContext::IsClassMethod(lldb::LanguageType *language_ptr, @@ -56,8 +56,8 @@ return m_type_system->DeclContextIsClassMethod( m_opaque_decl_ctx, language_ptr, is_instance_method_ptr, language_object_name_ptr); - else - return false; + + return false; } bool lldb_private::operator==(const lldb_private::CompilerDeclContext &lhs, Index: source/Symbol/CompilerType.cpp =================================================================== --- source/Symbol/CompilerType.cpp +++ source/Symbol/CompilerType.cpp @@ -442,36 +442,36 @@ CompilerType CompilerType::GetLValueReferenceType() const { if (IsValid()) return m_type_system->GetLValueReferenceType(m_type); - else - return CompilerType(); + + return CompilerType(); } CompilerType CompilerType::GetRValueReferenceType() const { if (IsValid()) return m_type_system->GetRValueReferenceType(m_type); - else - return CompilerType(); + + return CompilerType(); } CompilerType CompilerType::AddConstModifier() const { if (IsValid()) return m_type_system->AddConstModifier(m_type); - else - return CompilerType(); + + return CompilerType(); } CompilerType CompilerType::AddVolatileModifier() const { if (IsValid()) return m_type_system->AddVolatileModifier(m_type); - else - return CompilerType(); + + return CompilerType(); } CompilerType CompilerType::AddRestrictModifier() const { if (IsValid()) return m_type_system->AddRestrictModifier(m_type); - else - return CompilerType(); + + return CompilerType(); } CompilerType @@ -479,15 +479,15 @@ const CompilerDeclContext &decl_ctx) const { if (IsValid()) return m_type_system->CreateTypedef(m_type, name, decl_ctx); - else - return CompilerType(); + + return CompilerType(); } CompilerType CompilerType::GetTypedefedType() const { if (IsValid()) return m_type_system->GetTypedefedType(m_type); - else - return CompilerType(); + + return CompilerType(); } //---------------------------------------------------------------------- @@ -809,94 +809,99 @@ if (IsAggregateType()) { return false; // Aggregate types don't have scalar values - } else { - uint64_t count = 0; - lldb::Encoding encoding = GetEncoding(count); + } + uint64_t count = 0; + lldb::Encoding encoding = GetEncoding(count); - if (encoding == lldb::eEncodingInvalid || count != 1) - return false; + if (encoding == lldb::eEncodingInvalid || count != 1) + return false; - const uint64_t byte_size = GetByteSize(nullptr); - lldb::offset_t offset = data_byte_offset; - switch (encoding) { - case lldb::eEncodingInvalid: - break; - case lldb::eEncodingVector: - break; - case lldb::eEncodingUint: - if (byte_size <= sizeof(unsigned long long)) { - uint64_t uval64 = data.GetMaxU64(&offset, byte_size); - if (byte_size <= sizeof(unsigned int)) { - value = (unsigned int)uval64; + const uint64_t byte_size = GetByteSize(nullptr); + lldb::offset_t offset = data_byte_offset; + switch (encoding) { + case lldb::eEncodingInvalid: + break; + case lldb::eEncodingVector: + break; + case lldb::eEncodingUint: + if (byte_size <= sizeof(unsigned long long)) { + uint64_t uval64 = data.GetMaxU64(&offset, byte_size); + if (byte_size <= sizeof(unsigned int)) { + value = (unsigned int)uval64; + return true; + } + if (byte_size <= sizeof(unsigned long)) { + value = (unsigned long)uval64; + return true; + } else if (byte_size <= sizeof(unsigned long long)) { + value = (unsigned long long)uval64; + return true; + } else + value.Clear(); + } + break; + + case lldb::eEncodingSint: + if (byte_size <= sizeof(long long)) { + int64_t sval64 = data.GetMaxS64(&offset, byte_size); + if (byte_size <= sizeof(int)) { + value = (int)sval64; + return true; + } + if (byte_size <= sizeof(long)) { + value = (long)sval64; + return true; + } else if (byte_size <= sizeof(long long)) { + value = (long long)sval64; + return true; + } else + value.Clear(); + } + break; + + case lldb::eEncodingIEEE754: + if (byte_size <= sizeof(long double)) { + uint32_t u32; + uint64_t u64; + if (byte_size == sizeof(float)) { + if (sizeof(float) == sizeof(uint32_t)) { + u32 = data.GetU32(&offset); + value = *((float *)&u32); return true; - } else if (byte_size <= sizeof(unsigned long)) { - value = (unsigned long)uval64; + } + if (sizeof(float) == sizeof(uint64_t)) { + u64 = data.GetU64(&offset); + value = *((float *)&u64); return true; - } else if (byte_size <= sizeof(unsigned long long)) { - value = (unsigned long long)uval64; + } + } else if (byte_size == sizeof(double)) { + if (sizeof(double) == sizeof(uint32_t)) { + u32 = data.GetU32(&offset); + value = *((double *)&u32); return true; - } else - value.Clear(); - } - break; - - case lldb::eEncodingSint: - if (byte_size <= sizeof(long long)) { - int64_t sval64 = data.GetMaxS64(&offset, byte_size); - if (byte_size <= sizeof(int)) { - value = (int)sval64; + } + if (sizeof(double) == sizeof(uint64_t)) { + u64 = data.GetU64(&offset); + value = *((double *)&u64); return true; - } else if (byte_size <= sizeof(long)) { - value = (long)sval64; + } + } else if (byte_size == sizeof(long double)) { + if (sizeof(long double) == sizeof(uint32_t)) { + u32 = data.GetU32(&offset); + value = *((long double *)&u32); return true; - } else if (byte_size <= sizeof(long long)) { - value = (long long)sval64; + } + if (sizeof(long double) == sizeof(uint64_t)) { + u64 = data.GetU64(&offset); + value = *((long double *)&u64); return true; - } else - value.Clear(); - } - break; - - case lldb::eEncodingIEEE754: - if (byte_size <= sizeof(long double)) { - uint32_t u32; - uint64_t u64; - if (byte_size == sizeof(float)) { - if (sizeof(float) == sizeof(uint32_t)) { - u32 = data.GetU32(&offset); - value = *((float *)&u32); - return true; - } else if (sizeof(float) == sizeof(uint64_t)) { - u64 = data.GetU64(&offset); - value = *((float *)&u64); - return true; - } - } else if (byte_size == sizeof(double)) { - if (sizeof(double) == sizeof(uint32_t)) { - u32 = data.GetU32(&offset); - value = *((double *)&u32); - return true; - } else if (sizeof(double) == sizeof(uint64_t)) { - u64 = data.GetU64(&offset); - value = *((double *)&u64); - return true; - } - } else if (byte_size == sizeof(long double)) { - if (sizeof(long double) == sizeof(uint32_t)) { - u32 = data.GetU32(&offset); - value = *((long double *)&u32); - return true; - } else if (sizeof(long double) == sizeof(uint64_t)) { - u64 = data.GetU64(&offset); - value = *((long double *)&u64); - return true; - } } } - break; } - } - return false; + break; + } + + return false; } bool CompilerType::SetValueFromScalar(const Scalar &value, Stream &strm) { @@ -966,7 +971,8 @@ if (byte_size == sizeof(float)) { strm.PutFloat(value.Float()); return true; - } else if (byte_size == sizeof(double)) { + } + if (byte_size == sizeof(double)) { strm.PutDouble(value.Double()); return true; } else if (byte_size == sizeof(long double)) { @@ -1009,15 +1015,14 @@ // The address is an address in this process, so just copy it memcpy(dst, reinterpret_cast(addr), byte_size); return true; - } else { - Process *process = nullptr; - if (exe_ctx) - process = exe_ctx->GetProcessPtr(); - if (process) { - Status error; - return process->ReadMemory(addr, dst, byte_size, error) == byte_size; - } } + Process *process = nullptr; + if (exe_ctx) + process = exe_ctx->GetProcessPtr(); + if (process) { + Status error; + return process->ReadMemory(addr, dst, byte_size, error) == byte_size; + } } return false; } @@ -1044,16 +1049,15 @@ // The address is an address in this process, so just copy it memcpy((void *)addr, new_value.GetData(), byte_size); return true; - } else { - Process *process = nullptr; - if (exe_ctx) - process = exe_ctx->GetProcessPtr(); - if (process) { - Status error; - return process->WriteMemory(addr, new_value.GetData(), byte_size, - error) == byte_size; - } } + Process *process = nullptr; + if (exe_ctx) + process = exe_ctx->GetProcessPtr(); + if (process) { + Status error; + return process->WriteMemory(addr, new_value.GetData(), byte_size, + error) == byte_size; + } } return false; } Index: source/Symbol/Declaration.cpp =================================================================== --- source/Symbol/Declaration.cpp +++ source/Symbol/Declaration.cpp @@ -54,7 +54,8 @@ s->Printf(":%u", m_column); #endif return true; - } else if (m_line > 0) { + } + if (m_line > 0) { s->Printf(" line %u", m_line); #ifdef LLDB_ENABLE_DECLARATION_COLUMNS if (m_column > 0) @@ -73,7 +74,7 @@ return result; if (a.m_line < b.m_line) return -1; - else if (a.m_line > b.m_line) + if (a.m_line > b.m_line) return 1; #ifdef LLDB_ENABLE_DECLARATION_COLUMNS if (a.m_column < b.m_column) Index: source/Symbol/Function.cpp =================================================================== --- source/Symbol/Function.cpp +++ source/Symbol/Function.cpp @@ -598,8 +598,8 @@ lldb::LanguageType Function::GetLanguage() const { if (m_comp_unit) return m_comp_unit->GetLanguage(); - else - return lldb::eLanguageTypeUnknown; + + return lldb::eLanguageTypeUnknown; } ConstString Function::GetName() const { Index: source/Symbol/LineTable.cpp =================================================================== --- source/Symbol/LineTable.cpp +++ source/Symbol/LineTable.cpp @@ -302,7 +302,8 @@ if (m_entries[idx].line < line) { continue; - } else if (m_entries[idx].line == line) { + } + if (m_entries[idx].line == line) { if (line_entry_ptr) ConvertEntryAtIndexToLineEntry(idx, *line_entry_ptr); return idx; @@ -346,7 +347,8 @@ if (m_entries[idx].line < line) { continue; - } else if (m_entries[idx].line == line) { + } + if (m_entries[idx].line == line) { if (line_entry_ptr) ConvertEntryAtIndexToLineEntry(idx, *line_entry_ptr); return idx; Index: source/Symbol/ObjectFile.cpp =================================================================== --- source/Symbol/ObjectFile.cpp +++ source/Symbol/ObjectFile.cpp @@ -521,16 +521,15 @@ section_dst_len = section_bytes_left; return CopyData(section->GetFileOffset() + section_offset, section_dst_len, dst); - } else { - if (section->GetType() == eSectionTypeZeroFill) { - const uint64_t section_size = section->GetByteSize(); - const uint64_t section_bytes_left = section_size - section_offset; - uint64_t section_dst_len = dst_len; - if (section_dst_len > section_bytes_left) - section_dst_len = section_bytes_left; - memset(dst, 0, section_dst_len); - return section_dst_len; - } + } + if (section->GetType() == eSectionTypeZeroFill) { + const uint64_t section_size = section->GetByteSize(); + const uint64_t section_bytes_left = section_size - section_offset; + uint64_t section_dst_len = dst_len; + if (section_dst_len > section_bytes_left) + section_dst_len = section_bytes_left; + memset(dst, 0, section_dst_len); + return section_dst_len; } } return 0; @@ -563,15 +562,14 @@ } return GetData(section->GetFileOffset(), section->GetFileSize(), section_data); - } else { - // The object file now contains a full mmap'ed copy of the object file - // data, so just use this - if (!section->IsRelocated()) - RelocateSection(section); - - return GetData(section->GetFileOffset(), section->GetFileSize(), - section_data); } + // The object file now contains a full mmap'ed copy of the object file + // data, so just use this + if (!section->IsRelocated()) + RelocateSection(section); + + return GetData(section->GetFileOffset(), section->GetFileSize(), + section_data); } bool ObjectFile::SplitArchivePathWithObject(const char *path_with_object, Index: source/Symbol/Symbol.cpp =================================================================== --- source/Symbol/Symbol.cpp +++ source/Symbol/Symbol.cpp @@ -128,8 +128,8 @@ intptr_t str_ptr = m_addr_range.GetBaseAddress().GetOffset(); if (str_ptr != 0) return ConstString((const char *)str_ptr); - else - return GetName(); + + return GetName(); } return ConstString(); } @@ -481,15 +481,15 @@ lldb::addr_t Symbol::GetFileAddress() const { if (ValueIsAddress()) return GetAddressRef().GetFileAddress(); - else - return LLDB_INVALID_ADDRESS; + + return LLDB_INVALID_ADDRESS; } lldb::addr_t Symbol::GetLoadAddress(Target *target) const { if (ValueIsAddress()) return GetAddressRef().GetLoadAddress(target); - else - return LLDB_INVALID_ADDRESS; + + return LLDB_INVALID_ADDRESS; } ConstString Symbol::GetName() const { return m_mangled.GetName(GetLanguage()); } Index: source/Symbol/SymbolContext.cpp =================================================================== --- source/Symbol/SymbolContext.cpp +++ source/Symbol/SymbolContext.cpp @@ -443,8 +443,8 @@ LanguageType lang; if (function && (lang = function->GetLanguage()) != eLanguageTypeUnknown) { return lang; - } else if (variable && - (lang = variable->GetLanguage()) != eLanguageTypeUnknown) { + } + if (variable && (lang = variable->GetLanguage()) != eLanguageTypeUnknown) { return lang; } else if (symbol && (lang = symbol->GetLanguage()) != eLanguageTypeUnknown) { return lang; @@ -501,14 +501,14 @@ next_frame_sc.line_entry.column = curr_inlined_block_inlined_info->GetCallSite().GetColumn(); return true; - } else { - Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_SYMBOLS)); + } + Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_SYMBOLS)); - if (log) { - log->Printf( - "warning: inlined block 0x%8.8" PRIx64 - " doesn't have a range that contains file address 0x%" PRIx64, - curr_inlined_block->GetID(), curr_frame_pc.GetFileAddress()); + if (log) { + log->Printf( + "warning: inlined block 0x%8.8" PRIx64 + " doesn't have a range that contains file address 0x%" PRIx64, + curr_inlined_block->GetID(), curr_frame_pc.GetFileAddress()); } #ifdef LLDB_CONFIGURATION_DEBUG else { @@ -539,7 +539,6 @@ } } #endif - } } } @@ -701,7 +700,8 @@ } } return function->GetMangled().GetName(function->GetLanguage(), preference); - } else if (symbol && symbol->ValueIsAddress()) { + } + if (symbol && symbol->ValueIsAddress()) { return symbol->GetMangled().GetName(symbol->GetLanguage(), preference); } else { // No function, return an empty string. @@ -908,7 +908,8 @@ ss.PutChar('\n'); error.SetErrorString(ss.GetData()); return nullptr; - } else if (external_symbols.size()) { + } + if (external_symbols.size()) { return external_symbols[0]; } else if (internal_symbols.size() > 1) { StreamString ss; @@ -933,7 +934,8 @@ if (!error.Success()) { return nullptr; - } else if (module_symbol) { + } + if (module_symbol) { return module_symbol; } } @@ -946,7 +948,8 @@ if (!error.Success()) { return nullptr; - } else if (target_symbol) { + } + if (target_symbol) { return target_symbol; } } Index: source/Symbol/SymbolVendor.cpp =================================================================== --- source/Symbol/SymbolVendor.cpp +++ source/Symbol/SymbolVendor.cpp @@ -92,11 +92,10 @@ assert(m_compile_units[idx].get() == nullptr); m_compile_units[idx] = cu_sp; return true; - } else { - // This should NOT happen, and if it does, we want to crash and know - // about it - assert(idx < num_compile_units); } + // This should NOT happen, and if it does, we want to crash and know + // about it + assert(idx < num_compile_units); } return false; } Index: source/Symbol/Symtab.cpp =================================================================== --- source/Symbol/Symtab.cpp +++ source/Symbol/Symtab.cpp @@ -591,7 +591,8 @@ if (uid_a > uid_b) return false; return false; - } else if (value_a < value_b) + } + if (value_a < value_b) return true; return false; Index: source/Symbol/Type.cpp =================================================================== --- source/Symbol/Type.cpp +++ source/Symbol/Type.cpp @@ -402,14 +402,13 @@ return false; memcpy(dst, reinterpret_cast(addr), byte_size); return true; - } else { - if (exe_ctx) { - Process *process = exe_ctx->GetProcessPtr(); - if (process) { - Status error; - return exe_ctx->GetProcessPtr()->ReadMemory(addr, dst, byte_size, - error) == byte_size; - } + } + if (exe_ctx) { + Process *process = exe_ctx->GetProcessPtr(); + if (process) { + Status error; + return exe_ctx->GetProcessPtr()->ReadMemory(addr, dst, byte_size, + error) == byte_size; } } } @@ -748,8 +747,8 @@ bool TypeAndOrName::IsEmpty() const { if ((bool)m_type_name || (bool)m_type_pair) return false; - else - return true; + + return true; } void TypeAndOrName::Clear() { @@ -1087,15 +1086,15 @@ size_t TypeMemberFunctionImpl::GetNumArguments() const { if (m_type) return m_type.GetNumberOfFunctionArguments(); - else - return m_decl.GetNumFunctionArguments(); + + return m_decl.GetNumFunctionArguments(); } CompilerType TypeMemberFunctionImpl::GetArgumentAtIndex(size_t idx) const { if (m_type) return m_type.GetFunctionArgumentAtIndex(idx); - else - return m_decl.GetFunctionArgumentType(idx); + + return m_decl.GetFunctionArgumentType(idx); } TypeEnumMemberImpl::TypeEnumMemberImpl(const lldb::TypeImplSP &integer_type_sp, Index: source/Symbol/UnwindPlan.cpp =================================================================== --- source/Symbol/UnwindPlan.cpp +++ source/Symbol/UnwindPlan.cpp @@ -370,14 +370,13 @@ const UnwindPlan::RowSP UnwindPlan::GetRowAtIndex(uint32_t idx) const { if (idx < m_row_list.size()) return m_row_list[idx]; - else { - Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_UNWIND)); - if (log) - log->Printf("error: UnwindPlan::GetRowAtIndex(idx = %u) invalid index " - "(number rows is %u)", - idx, (uint32_t)m_row_list.size()); - return UnwindPlan::RowSP(); - } + + Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_UNWIND)); + if (log) + log->Printf("error: UnwindPlan::GetRowAtIndex(idx = %u) invalid index " + "(number rows is %u)", + idx, (uint32_t)m_row_list.size()); + return UnwindPlan::RowSP(); } const UnwindPlan::RowSP UnwindPlan::GetLastRow() const { Index: source/Target/CPPLanguageRuntime.cpp =================================================================== --- source/Target/CPPLanguageRuntime.cpp +++ source/Target/CPPLanguageRuntime.cpp @@ -331,15 +331,14 @@ ret_plan_sp.reset(new ThreadPlanRunToAddress( thread, callable_info.callable_address, stop_others)); return ret_plan_sp; - } else { - // We are in std::function but we could not obtain the callable. - // We create a ThreadPlan to keep stepping through using the address range - // of the current function. - ret_plan_sp.reset(new ThreadPlanStepInRange(thread, range_of_curr_func, - sc, eOnlyThisThread, - eLazyBoolYes, eLazyBoolYes)); - return ret_plan_sp; } + // We are in std::function but we could not obtain the callable. + // We create a ThreadPlan to keep stepping through using the address range + // of the current function. + ret_plan_sp.reset(new ThreadPlanStepInRange(thread, range_of_curr_func, sc, + eOnlyThisThread, eLazyBoolYes, + eLazyBoolYes)); + return ret_plan_sp; } return ret_plan_sp; Index: source/Target/ExecutionContext.cpp =================================================================== --- source/Target/ExecutionContext.cpp +++ source/Target/ExecutionContext.cpp @@ -193,7 +193,7 @@ RegisterContext *ExecutionContext::GetRegisterContext() const { if (m_frame_sp) return m_frame_sp->GetRegisterContext().get(); - else if (m_thread_sp) + if (m_thread_sp) return m_thread_sp->GetRegisterContext().get(); return nullptr; } Index: source/Target/FileAction.cpp =================================================================== --- source/Target/FileAction.cpp +++ source/Target/FileAction.cpp @@ -46,9 +46,9 @@ m_arg = O_NOCTTY | O_CREAT | O_WRONLY; m_file_spec = file_spec; return true; - } else { - Clear(); } + Clear(); + return false; } Index: source/Target/Language.cpp =================================================================== --- source/Target/Language.cpp +++ source/Target/Language.cpp @@ -220,8 +220,8 @@ const char *Language::GetNameForLanguageType(LanguageType language) { if (language < num_languages) return language_names[language].name; - else - return language_names[eLanguageTypeUnknown].name; + + return language_names[eLanguageTypeUnknown].name; } void Language::PrintAllLanguages(Stream &s, const char *prefix, Index: source/Target/LanguageRuntime.cpp =================================================================== --- source/Target/LanguageRuntime.cpp +++ source/Target/LanguageRuntime.cpp @@ -117,15 +117,15 @@ if (SetActualResolver()) return m_actual_resolver_sp->SearchCallback(filter, context, addr, containing); - else - return eCallbackReturnStop; + + return eCallbackReturnStop; } lldb::SearchDepth GetDepth() override { if (SetActualResolver()) return m_actual_resolver_sp->GetDepth(); - else - return lldb::eSearchDepthTarget; + + return lldb::eSearchDepthTarget; } void GetDescription(Stream *s) override { Index: source/Target/ObjCLanguageRuntime.cpp =================================================================== --- source/Target/ObjCLanguageRuntime.cpp +++ source/Target/ObjCLanguageRuntime.cpp @@ -85,8 +85,8 @@ if (complete_type_sp) return complete_type_sp; - else - m_complete_class_cache.erase(name); + + m_complete_class_cache.erase(name); } if (m_negative_complete_class_cache.count(name) > 0) @@ -150,8 +150,8 @@ return true; if ((value % ptr_size) == 0) return (check_version_specific ? CheckPointer(value, ptr_size) : true); - else - return false; + + return false; } ObjCLanguageRuntime::ObjCISA Index: source/Target/Platform.cpp =================================================================== --- source/Target/Platform.cpp +++ source/Target/Platform.cpp @@ -504,8 +504,8 @@ #else return false; #endif - else - return GetRemoteOSBuildString(s); + + return GetRemoteOSBuildString(s); } bool Platform::GetOSKernelDescription(std::string &s) { @@ -515,8 +515,8 @@ #else return false; #endif - else - return GetRemoteOSKernelDescription(s); + + return GetRemoteOSKernelDescription(s); } void Platform::AddClangModuleCompilationOptions( @@ -533,11 +533,11 @@ llvm::SmallString<64> cwd; if (llvm::sys::fs::current_path(cwd)) return {}; - else { - FileSpec file_spec(cwd); - FileSystem::Instance().Resolve(file_spec); - return file_spec; - } + + FileSpec file_spec(cwd); + FileSystem::Instance().Resolve(file_spec); + return file_spec; + } else { if (!m_working_dir) m_working_dir = GetRemoteWorkingDirectory(); @@ -761,23 +761,21 @@ return false; } return true; - } else { - m_working_dir.Clear(); - return SetRemoteWorkingDirectory(file_spec); } + m_working_dir.Clear(); + return SetRemoteWorkingDirectory(file_spec); } Status Platform::MakeDirectory(const FileSpec &file_spec, uint32_t permissions) { if (IsHost()) return llvm::sys::fs::create_directory(file_spec.GetPath(), permissions); - else { - Status error; - error.SetErrorStringWithFormat("remote platform %s doesn't support %s", - GetPluginName().GetCString(), - LLVM_PRETTY_FUNCTION); - return error; - } + + Status error; + error.SetErrorStringWithFormat("remote platform %s doesn't support %s", + GetPluginName().GetCString(), + LLVM_PRETTY_FUNCTION); + return error; } Status Platform::GetFilePermissions(const FileSpec &file_spec, @@ -787,13 +785,12 @@ if (Value) file_permissions = Value.get(); return Status(Value.getError()); - } else { - Status error; - error.SetErrorStringWithFormat("remote platform %s doesn't support %s", - GetPluginName().GetCString(), - LLVM_PRETTY_FUNCTION); - return error; } + Status error; + error.SetErrorStringWithFormat("remote platform %s doesn't support %s", + GetPluginName().GetCString(), + LLVM_PRETTY_FUNCTION); + return error; } Status Platform::SetFilePermissions(const FileSpec &file_spec, @@ -801,13 +798,12 @@ if (IsHost()) { auto Perms = static_cast(file_permissions); return llvm::sys::fs::setPermissions(file_spec.GetPath(), Perms); - } else { - Status error; - error.SetErrorStringWithFormat("remote platform %s doesn't support %s", - GetPluginName().GetCString(), - LLVM_PRETTY_FUNCTION); - return error; } + Status error; + error.SetErrorStringWithFormat("remote platform %s doesn't support %s", + GetPluginName().GetCString(), + LLVM_PRETTY_FUNCTION); + return error; } ConstString Platform::GetName() { return GetPluginName(); } @@ -867,20 +863,19 @@ // We don't need anyone setting the OS version for the host platform, we // should be able to figure it out by calling HostInfo::GetOSVersion(...). return false; - } else { - // We have a remote platform, allow setting the target OS version if we - // aren't connected, since if we are connected, we should be able to - // request the remote OS version from the connected platform. - if (IsConnected()) - return false; - else { - // We aren't connected and we might want to set the OS version ahead of - // time before we connect so we can peruse files and use a local SDK or - // PDK cache of support files to disassemble or do other things. - m_os_version = version; - return true; - } } + // We have a remote platform, allow setting the target OS version if we + // aren't connected, since if we are connected, we should be able to + // request the remote OS version from the connected platform. + if (IsConnected()) + return false; + + // We aren't connected and we might want to set the OS version ahead of + // time before we connect so we can peruse files and use a local SDK or + // PDK cache of support files to disassemble or do other things. + m_os_version = version; + return true; + return false; } @@ -1375,8 +1370,8 @@ if (IsHost()) return Host::RunShellCommand(command, working_dir, status_ptr, signo_ptr, command_output, timeout); - else - return Status("unimplemented"); + + return Status("unimplemented"); } bool Platform::CalculateMD5(const FileSpec &file_spec, uint64_t &low, Index: source/Target/Process.cpp =================================================================== --- source/Target/Process.cpp +++ source/Target/Process.cpp @@ -695,8 +695,8 @@ if (process_sp->CanDebug(target_sp, false)) { process_sp->m_process_unique_id = ++g_process_unique_id; break; - } else - process_sp.reset(); + } + process_sp.reset(); } } } @@ -1242,8 +1242,8 @@ if (listener_sp) { return HijackBroadcaster(listener_sp, eBroadcastBitStateChanged | eBroadcastBitInterrupt); - } else - return false; + } + return false; } void Process::RestoreProcessEvents() { RestoreBroadcaster(); } @@ -1321,8 +1321,8 @@ if (control_only) return m_private_state_listener_sp->GetEventForBroadcaster( &m_private_state_control_broadcaster, event_sp, timeout); - else - return m_private_state_listener_sp->GetEvent(event_sp, timeout); + + return m_private_state_listener_sp->GetEvent(event_sp, timeout); } bool Process::IsRunning() const { @@ -1749,8 +1749,8 @@ m_language_runtimes[language] = runtime_sp; return runtime_sp.get(); - } else - return (*pos).second.get(); + } + return (*pos).second.get(); } CPPLanguageRuntime *Process::GetCPPLanguageRuntime(bool retry_if_null) { @@ -1911,26 +1911,24 @@ bp_site_sp->AddOwner(owner); owner->SetBreakpointSite(bp_site_sp); return bp_site_sp->GetID(); - } else { - bp_site_sp.reset(new BreakpointSite(&m_breakpoint_site_list, owner, - load_addr, use_hardware)); - if (bp_site_sp) { - Status error = EnableBreakpointSite(bp_site_sp.get()); - if (error.Success()) { - owner->SetBreakpointSite(bp_site_sp); - return m_breakpoint_site_list.Add(bp_site_sp); - } else { - if (show_error || use_hardware) { - // Report error for setting breakpoint... - GetTarget().GetDebugger().GetErrorFile()->Printf( - "warning: failed to set breakpoint site at 0x%" PRIx64 - " for breakpoint %i.%i: %s\n", - load_addr, owner->GetBreakpoint().GetID(), owner->GetID(), - error.AsCString() ? error.AsCString() : "unknown error"); - } - } - } } + bp_site_sp.reset(new BreakpointSite(&m_breakpoint_site_list, owner, + load_addr, use_hardware)); + if (bp_site_sp) { + Status error = EnableBreakpointSite(bp_site_sp.get()); + if (error.Success()) { + owner->SetBreakpointSite(bp_site_sp); + return m_breakpoint_site_list.Add(bp_site_sp); + } + if (show_error || use_hardware) { + // Report error for setting breakpoint... + GetTarget().GetDebugger().GetErrorFile()->Printf( + "warning: failed to set breakpoint site at 0x%" PRIx64 + " for breakpoint %i.%i: %s\n", + load_addr, owner->GetBreakpoint().GetID(), owner->GetID(), + error.AsCString() ? error.AsCString() : "unknown error"); + } + } } // We failed to enable the breakpoint return LLDB_INVALID_BREAK_ID; @@ -2122,10 +2120,10 @@ "addr = 0x%" PRIx64 " -- SUCCESS", bp_site->GetID(), (uint64_t)bp_addr); return error; - } else { - if (break_op_found) - error.SetErrorString("Failed to restore original opcode."); } + if (break_op_found) + error.SetErrorString("Failed to restore original opcode."); + } else error.SetErrorString("Failed to read memory to verify that " "breakpoint trap was restored."); @@ -2189,11 +2187,10 @@ return m_memory_cache.Read(addr, buf, size, error); #endif // defined (VERIFY_MEMORY_READS) - } else { - // Memory caching is disabled - - return ReadMemoryFromInferior(addr, buf, size, error); } + // Memory caching is disabled + + return ReadMemoryFromInferior(addr, buf, size, error); } size_t Process::ReadCStringFromMemory(addr_t addr, std::string &out_str, @@ -2419,55 +2416,54 @@ // No breakpoint sites overlap if (bp_sites_in_range.IsEmpty()) return WriteMemoryPrivate(addr, buf, size, error); - else { - const uint8_t *ubuf = (const uint8_t *)buf; - uint64_t bytes_written = 0; - bp_sites_in_range.ForEach([this, addr, size, &bytes_written, &ubuf, - &error](BreakpointSite *bp) -> void { + const uint8_t *ubuf = (const uint8_t *)buf; + uint64_t bytes_written = 0; - if (error.Success()) { - addr_t intersect_addr; - size_t intersect_size; - size_t opcode_offset; - const bool intersects = bp->IntersectsRange( - addr, size, &intersect_addr, &intersect_size, &opcode_offset); - UNUSED_IF_ASSERT_DISABLED(intersects); - assert(intersects); - assert(addr <= intersect_addr && intersect_addr < addr + size); - assert(addr < intersect_addr + intersect_size && - intersect_addr + intersect_size <= addr + size); - assert(opcode_offset + intersect_size <= bp->GetByteSize()); - - // Check for bytes before this breakpoint - const addr_t curr_addr = addr + bytes_written; - if (intersect_addr > curr_addr) { - // There are some bytes before this breakpoint that we need to just - // write to memory - size_t curr_size = intersect_addr - curr_addr; - size_t curr_bytes_written = WriteMemoryPrivate( - curr_addr, ubuf + bytes_written, curr_size, error); - bytes_written += curr_bytes_written; - if (curr_bytes_written != curr_size) { - // We weren't able to write all of the requested bytes, we are - // done looping and will return the number of bytes that we have - // written so far. - if (error.Success()) - error.SetErrorToGenericError(); - } + bp_sites_in_range.ForEach([this, addr, size, &bytes_written, &ubuf, + &error](BreakpointSite *bp) -> void { + if (error.Success()) { + addr_t intersect_addr; + size_t intersect_size; + size_t opcode_offset; + const bool intersects = bp->IntersectsRange( + addr, size, &intersect_addr, &intersect_size, &opcode_offset); + UNUSED_IF_ASSERT_DISABLED(intersects); + assert(intersects); + assert(addr <= intersect_addr && intersect_addr < addr + size); + assert(addr < intersect_addr + intersect_size && + intersect_addr + intersect_size <= addr + size); + assert(opcode_offset + intersect_size <= bp->GetByteSize()); + + // Check for bytes before this breakpoint + const addr_t curr_addr = addr + bytes_written; + if (intersect_addr > curr_addr) { + // There are some bytes before this breakpoint that we need to just + // write to memory + size_t curr_size = intersect_addr - curr_addr; + size_t curr_bytes_written = WriteMemoryPrivate( + curr_addr, ubuf + bytes_written, curr_size, error); + bytes_written += curr_bytes_written; + if (curr_bytes_written != curr_size) { + // We weren't able to write all of the requested bytes, we are + // done looping and will return the number of bytes that we have + // written so far. + if (error.Success()) + error.SetErrorToGenericError(); } - // Now write any bytes that would cover up any software breakpoints - // directly into the breakpoint opcode buffer - ::memcpy(bp->GetSavedOpcodeBytes() + opcode_offset, - ubuf + bytes_written, intersect_size); - bytes_written += intersect_size; } - }); + // Now write any bytes that would cover up any software breakpoints + // directly into the breakpoint opcode buffer + ::memcpy(bp->GetSavedOpcodeBytes() + opcode_offset, + ubuf + bytes_written, intersect_size); + bytes_written += intersect_size; + } + }); + + if (bytes_written < size) + WriteMemoryPrivate(addr + bytes_written, ubuf + bytes_written, + size - bytes_written, error); - if (bytes_written < size) - WriteMemoryPrivate(addr + bytes_written, ubuf + bytes_written, - size - bytes_written, error); - } } else { return WriteMemoryPrivate(addr, buf, size, error); } @@ -2486,8 +2482,8 @@ scalar.GetAsMemoryData(buf, byte_size, GetByteOrder(), error); if (mem_size > 0) return WriteMemory(addr, buf, mem_size, error); - else - error.SetErrorString("failed to get scalar as memory data"); + + error.SetErrorString("failed to get scalar as memory data"); } else { error.SetErrorString("invalid scalar value"); } @@ -2944,15 +2940,15 @@ RequestResume(); return eEventActionRetry; - } else { - if (log) - log->Printf("Process::AttachCompletionHandler::%s state %s: no more " - "execs expected to start, continuing with attach", - __FUNCTION__, StateAsCString(state)); - - m_process->CompleteAttach(); - return eEventActionSuccess; } + if (log) + log->Printf("Process::AttachCompletionHandler::%s state %s: no more " + "execs expected to start, continuing with attach", + __FUNCTION__, StateAsCString(state)); + + m_process->CompleteAttach(); + return eEventActionSuccess; + break; default: @@ -2977,8 +2973,8 @@ ListenerSP ProcessAttachInfo::GetListenerForProcess(Debugger &debugger) { if (m_listener_sp) return m_listener_sp; - else - return debugger.GetListener(); + + return debugger.GetListener(); } Status Process::Attach(ProcessAttachInfo &attach_info) { @@ -3385,8 +3381,8 @@ log->Printf("Process::%s() Process exited while waiting to stop.", __FUNCTION__); return error; - } else - exit_event_sp.reset(); // It is ok to consume any non-exit stop events + } + exit_event_sp.reset(); // It is ok to consume any non-exit stop events if (state != eStateStopped) { if (log) @@ -3420,7 +3416,8 @@ if (!error.Success()) { m_destroy_in_process = false; return error; - } else if (exit_event_sp) { + } + if (exit_event_sp) { // We shouldn't need to do anything else here. There's no process left // to detach from... StopPrivateStateThread(); @@ -3755,8 +3752,8 @@ if (m_private_state_thread.IsJoinable()) { ResumePrivateStateThread(); return true; - } else - return false; + } + return false; } void Process::PausePrivateStateThread() { @@ -4006,7 +4003,8 @@ } continue; - } else if (event_sp->GetType() == eBroadcastBitInterrupt) { + } + if (event_sp->GetType() == eBroadcastBitInterrupt) { if (m_public_state.GetValue() == eStateAttaching) { if (log) log->Printf("Process::%s (arg = %p, pid = %" PRIu64 @@ -4301,16 +4299,16 @@ const ProcessEventData *data = GetEventDataFromEvent(event_ptr); if (data == nullptr) return eStateInvalid; - else - return data->GetState(); + + return data->GetState(); } bool Process::ProcessEventData::GetRestartedFromEvent(const Event *event_ptr) { const ProcessEventData *data = GetEventDataFromEvent(event_ptr); if (data == nullptr) return false; - else - return data->GetRestarted(); + + return data->GetRestarted(); } void Process::ProcessEventData::SetRestartedInEvent(Event *event_ptr, @@ -4327,8 +4325,8 @@ const_cast(GetEventDataFromEvent(event_ptr)); if (data != nullptr) return data->GetNumRestartedReasons(); - else - return 0; + + return 0; } const char * @@ -4338,8 +4336,8 @@ const_cast(GetEventDataFromEvent(event_ptr)); if (data != nullptr) return data->GetRestartedReasonAtIndex(idx); - else - return nullptr; + + return nullptr; } void Process::ProcessEventData::AddRestartedReason(Event *event_ptr, @@ -4355,8 +4353,8 @@ const ProcessEventData *data = GetEventDataFromEvent(event_ptr); if (data == nullptr) return false; - else - return data->GetInterrupted(); + + return data->GetInterrupted(); } void Process::ProcessEventData::SetInterruptedInEvent(Event *event_ptr, @@ -4438,8 +4436,8 @@ auto find_it = m_structured_data_plugin_map.find(type_name); if (find_it != m_structured_data_plugin_map.end()) return find_it->second; - else - return StructuredDataPluginSP(); + + return StructuredDataPluginSP(); } size_t Process::GetAsyncProfileData(char *buf, size_t buf_size, Status &error) { @@ -4621,22 +4619,22 @@ size_t bytes_written = 0; Status result = m_pipe.Write(&ch, 1, bytes_written); return result.Success(); - } else { - // This IOHandler might be pushed on the stack, but not being run - // currently so do the right thing if we aren't actively watching for - // STDIN by sending the interrupt to the process. Otherwise the write to - // the pipe above would do nothing. This can happen when the command - // interpreter is running and gets a "expression ...". It will be on the - // IOHandler thread and sending the input is complete to the delegate - // which will cause the expression to run, which will push the process IO - // handler, but not run it. - - if (StateIsRunningState(m_process->GetState())) { - m_process->SendAsyncInterrupt(); - return true; - } } - return false; + // This IOHandler might be pushed on the stack, but not being run + // currently so do the right thing if we aren't actively watching for + // STDIN by sending the interrupt to the process. Otherwise the write to + // the pipe above would do nothing. This can happen when the command + // interpreter is running and gets a "expression ...". It will be on the + // IOHandler thread and sending the input is complete to the delegate + // which will cause the expression to run, which will push the process IO + // handler, but not run it. + + if (StateIsRunningState(m_process->GetState())) { + m_process->SendAsyncInterrupt(); + return true; + } + + return false; } void GotEOF() override {} @@ -4778,8 +4776,8 @@ if (!options.GetTimeout()) return llvm::None; - else - return *options.GetTimeout() - GetOneThreadExpressionTimeout(options); + + return *options.GetTimeout() - GetOneThreadExpressionTimeout(options); } static llvm::Optional @@ -5197,44 +5195,44 @@ log->Printf("Process::RunThreadPlan(): Got interrupted by " "eBroadcastBitInterrupted, exiting."); break; - } else { - stop_state = - Process::ProcessEventData::GetStateFromEvent(event_sp.get()); - if (log) - log->Printf( - "Process::RunThreadPlan(): in while loop, got event: %s.", - StateAsCString(stop_state)); - - switch (stop_state) { - case lldb::eStateStopped: { - // We stopped, figure out what we are going to do now. - ThreadSP thread_sp = - GetThreadList().FindThreadByIndexID(thread_idx_id); - if (!thread_sp) { - // Ooh, our thread has vanished. Unlikely that this was - // successful execution... - if (log) - log->Printf("Process::RunThreadPlan(): execution completed " - "but our thread (index-id=%u) has vanished.", - thread_idx_id); - return_value = eExpressionInterrupted; - } else if (Process::ProcessEventData::GetRestartedFromEvent( - event_sp.get())) { - // If we were restarted, we just need to go back up to fetch - // another event. - if (log) { - log->Printf("Process::RunThreadPlan(): Got a stop and " - "restart, so we'll continue waiting."); - } - keep_going = true; - do_resume = false; - handle_running_event = true; - } else { - const bool handle_interrupts = true; - return_value = *HandleStoppedEvent( - *thread, thread_plan_sp, thread_plan_restorer, event_sp, - event_to_broadcast_sp, options, handle_interrupts); + } + stop_state = + Process::ProcessEventData::GetStateFromEvent(event_sp.get()); + if (log) + log->Printf( + "Process::RunThreadPlan(): in while loop, got event: %s.", + StateAsCString(stop_state)); + + switch (stop_state) { + case lldb::eStateStopped: { + // We stopped, figure out what we are going to do now. + ThreadSP thread_sp = + GetThreadList().FindThreadByIndexID(thread_idx_id); + if (!thread_sp) { + // Ooh, our thread has vanished. Unlikely that this was + // successful execution... + if (log) + log->Printf("Process::RunThreadPlan(): execution completed " + "but our thread (index-id=%u) has vanished.", + thread_idx_id); + return_value = eExpressionInterrupted; + } else if (Process::ProcessEventData::GetRestartedFromEvent( + event_sp.get())) { + // If we were restarted, we just need to go back up to fetch + // another event. + if (log) { + log->Printf("Process::RunThreadPlan(): Got a stop and " + "restart, so we'll continue waiting."); } + keep_going = true; + do_resume = false; + handle_running_event = true; + } else { + const bool handle_interrupts = true; + return_value = *HandleStoppedEvent( + *thread, thread_plan_sp, thread_plan_restorer, event_sp, + event_to_broadcast_sp, options, handle_interrupts); + } } break; case lldb::eStateRunning: @@ -5261,12 +5259,11 @@ return_value = eExpressionInterrupted; break; } - } if (keep_going) continue; - else - break; + + break; } else { if (log) log->PutCString("Process::RunThreadPlan(): got_event was true, but " @@ -5383,15 +5380,14 @@ back_to_top = true; break; - } else { - // Running all threads failed, so return Interrupted. - if (log) - log->PutCString("Process::RunThreadPlan(): running all " - "threads timed out."); - return_value = eExpressionInterrupted; - back_to_top = false; - break; } + // Running all threads failed, so return Interrupted. + if (log) + log->PutCString("Process::RunThreadPlan(): running all " + "threads timed out."); + return_value = eExpressionInterrupted; + back_to_top = false; + break; } } else { if (log) @@ -5410,8 +5406,8 @@ if (!back_to_top || try_halt_again > num_retries) break; - else - continue; + + continue; } } // END WAIT LOOP @@ -5468,7 +5464,8 @@ if (!event_sp) { event_explanation = ""; break; - } else if (event_sp->GetType() == eBroadcastBitInterrupt) { + } + if (event_sp->GetType() == eBroadcastBitInterrupt) { event_explanation = ""; break; } else { @@ -5757,8 +5754,8 @@ ProcessRunLock &Process::GetRunLock() { if (m_private_state_thread.EqualsThread(Host::GetCurrentThread())) return m_private_run_lock; - else - return m_public_run_lock; + + return m_public_run_lock; } void Process::Flush() { @@ -5951,8 +5948,8 @@ pos = m_instrumentation_runtimes.find(type); if (pos == m_instrumentation_runtimes.end()) { return InstrumentationRuntimeSP(); - } else - return (*pos).second; + } + return (*pos).second; } bool Process::GetModuleSpec(const FileSpec &module_file_spec, Index: source/Target/ProcessLaunchInfo.cpp =================================================================== --- source/Target/ProcessLaunchInfo.cpp +++ source/Target/ProcessLaunchInfo.cpp @@ -425,9 +425,9 @@ m_executable = m_shell; m_arguments = shell_arguments; return true; - } else { - error.SetErrorString("invalid shell path"); } + error.SetErrorString("invalid shell path"); + } else { error.SetErrorString("not launching in shell"); } @@ -437,6 +437,6 @@ ListenerSP ProcessLaunchInfo::GetListenerForProcess(Debugger &debugger) { if (m_listener_sp) return m_listener_sp; - else - return debugger.GetListener(); + + return debugger.GetListener(); } Index: source/Target/QueueList.cpp =================================================================== --- source/Target/QueueList.cpp +++ source/Target/QueueList.cpp @@ -28,9 +28,8 @@ std::lock_guard guard(m_mutex); if (idx < m_queues.size()) { return m_queues[idx]; - } else { - return QueueSP(); } + return QueueSP(); } void QueueList::Clear() { Index: source/Target/RegisterNumber.cpp =================================================================== --- source/Target/RegisterNumber.cpp +++ source/Target/RegisterNumber.cpp @@ -63,23 +63,23 @@ if (m_kind == rhs.m_kind) { if (m_regnum == rhs.m_regnum) return true; - else - return false; + + return false; } uint32_t rhs_regnum = rhs.GetAsKind(m_kind); if (rhs_regnum != LLDB_INVALID_REGNUM) { if (m_regnum == rhs_regnum) return true; - else - return false; + + return false; } uint32_t lhs_regnum = GetAsKind(rhs.m_kind); { if (lhs_regnum == rhs.m_regnum) return true; - else - return false; + + return false; } return false; } Index: source/Target/SectionLoadHistory.cpp =================================================================== --- source/Target/SectionLoadHistory.cpp +++ source/Target/SectionLoadHistory.cpp @@ -29,8 +29,8 @@ std::lock_guard guard(m_mutex); if (m_stop_id_to_section_load_list.empty()) return 0; - else - return m_stop_id_to_section_load_list.rbegin()->first; + + return m_stop_id_to_section_load_list.rbegin()->first; } SectionLoadList * @@ -48,17 +48,16 @@ StopIDToSectionLoadList::reverse_iterator rpos = m_stop_id_to_section_load_list.rbegin(); return rpos->second.get(); - } else { - StopIDToSectionLoadList::iterator pos = - m_stop_id_to_section_load_list.lower_bound(stop_id); - if (pos != m_stop_id_to_section_load_list.end() && - pos->first == stop_id) - return pos->second.get(); - else if (pos != m_stop_id_to_section_load_list.begin()) { - --pos; - return pos->second.get(); - } } + StopIDToSectionLoadList::iterator pos = + m_stop_id_to_section_load_list.lower_bound(stop_id); + if (pos != m_stop_id_to_section_load_list.end() && pos->first == stop_id) + return pos->second.get(); + if (pos != m_stop_id_to_section_load_list.begin()) { + --pos; + return pos->second.get(); + } + } else { // You can only use "eStopIDNow" when reading from the section load // history Index: source/Target/SectionLoadList.cpp =================================================================== --- source/Target/SectionLoadList.cpp +++ source/Target/SectionLoadList.cpp @@ -81,8 +81,8 @@ if (sta_pos != m_sect_to_addr.end()) { if (load_addr == sta_pos->second) return false; // No change... - else - sta_pos->second = load_addr; + + sta_pos->second = load_addr; } else m_sect_to_addr[section.get()] = load_addr; @@ -118,16 +118,15 @@ } else m_addr_to_sect[load_addr] = section; return true; // Changed - - } else { - if (log) { - log->Printf( - "SectionLoadList::%s (section = %p (%s), load_addr = 0x%16.16" PRIx64 - ") error: module has been deleted", - __FUNCTION__, static_cast(section.get()), - section->GetName().AsCString(), load_addr); - } } + if (log) { + log->Printf( + "SectionLoadList::%s (section = %p (%s), load_addr = 0x%16.16" PRIx64 + ") error: module has been deleted", + __FUNCTION__, static_cast(section.get()), + section->GetName().AsCString(), load_addr); + } + return false; } Index: source/Target/StackFrame.cpp =================================================================== --- source/Target/StackFrame.cpp +++ source/Target/StackFrame.cpp @@ -167,8 +167,8 @@ if (thread_sp) return thread_sp->GetStackFrameList()->GetVisibleStackFrameIndex( m_frame_index); - else - return m_frame_index; + + return m_frame_index; } void StackFrame::SetSymbolContextScope(SymbolContextScope *symbol_scope) { @@ -249,11 +249,10 @@ // want this frame to have only the variables for the inlined function // and its non-inlined block child blocks. return inline_block; - } else { - // This block is not contained within any inlined function blocks with so - // we want to use the top most function block. - return &m_sc.function->GetBlock(false); } + // This block is not contained within any inlined function blocks with so + // we want to use the top most function block. + return &m_sc.function->GetBlock(false); } return nullptr; } @@ -819,7 +818,8 @@ var_expr_path_strm.GetData()); return ValueObjectSP(); - } else if (is_objc_pointer) { + } + if (is_objc_pointer) { // dereferencing ObjC variables is not valid.. so let's try and // recur to synthetic children ValueObjectSP synthetic = valobj_sp->GetSyntheticValue(); @@ -1282,9 +1282,8 @@ } if (reg_value.GetAsUInt64() == value) { return std::make_pair(&operand, 0); - } else { - return std::make_pair(nullptr, 0); } + return std::make_pair(nullptr, 0); } } return std::make_pair(nullptr, 0); @@ -1357,13 +1356,12 @@ target_sp->GetScratchTypeSystemForLanguage(nullptr, eLanguageTypeC); if (!c_type_system) { return ValueObjectSP(); - } else { - CompilerType void_ptr_type = - c_type_system - ->GetBasicTypeFromAST(lldb::BasicType::eBasicTypeChar) - .GetPointerType(); - return ValueObjectMemory::Create(this, "", addr, void_ptr_type); } + CompilerType void_ptr_type = + c_type_system->GetBasicTypeFromAST(lldb::BasicType::eBasicTypeChar) + .GetPointerType(); + return ValueObjectMemory::Create(this, "", addr, void_ptr_type); + } else { return ValueObjectSP(); } @@ -1410,9 +1408,8 @@ if (offset == 0) { return parent; - } else { - return ValueObjectSP(); } + return ValueObjectSP(); } ValueObjectSP GetValueForDereferincingOffset(StackFrame &frame, Index: source/Target/StackFrameList.cpp =================================================================== --- source/Target/StackFrameList.cpp +++ source/Target/StackFrameList.cpp @@ -72,9 +72,8 @@ "GetCurrentInlinedDepth: invalidating current inlined depth.\n"); } return m_current_inlined_depth; - } else { - return UINT32_MAX; } + return UINT32_MAX; } void StackFrameList::ResetCurrentInlinedDepth() { @@ -793,8 +792,8 @@ if (frame_sp) { SetSelectedFrame(frame_sp.get()); return true; - } else - return false; + } + return false; } void StackFrameList::SetDefaultFileAndLineToSelectedFrame() { Index: source/Target/StopInfo.cpp =================================================================== --- source/Target/StopInfo.cpp +++ source/Target/StopInfo.cpp @@ -57,7 +57,8 @@ lldb::StateType ret_type = thread_sp->GetProcess()->GetPrivateState(); if (ret_type == eStateRunning) { return true; - } else if (ret_type == eStateStopped) { + } + if (ret_type == eStateStopped) { // This is a little tricky. We want to count "run and stopped again // before you could ask this question as a "TRUE" answer to // HasTargetRunSinceMe. But we don't want to include any running of the @@ -71,7 +72,8 @@ thread_sp->GetProcess()->GetLastUserExpressionResumeID(); if (curr_resume_id == m_resume_id) { return false; - } else if (curr_resume_id > last_user_expression_id) { + } + if (curr_resume_id > last_user_expression_id) { return true; } } @@ -1005,8 +1007,8 @@ const char *GetDescription() override { if (m_description.empty()) return "trace"; - else - return m_description.c_str(); + + return m_description.c_str(); } }; @@ -1029,8 +1031,8 @@ const char *GetDescription() override { if (m_description.empty()) return "exception"; - else - return m_description.c_str(); + + return m_description.c_str(); } }; @@ -1069,8 +1071,8 @@ bool ShouldStop(Event *event_ptr) override { if (m_plan_sp) return m_plan_sp->ShouldStop(event_ptr); - else - return StopInfo::ShouldStop(event_ptr); + + return StopInfo::ShouldStop(event_ptr); } private: @@ -1165,8 +1167,8 @@ StopInfoThreadPlan *plan_stop_info = static_cast(stop_info_sp.get()); return plan_stop_info->GetReturnValueObject(); - } else - return ValueObjectSP(); + } + return ValueObjectSP(); } ExpressionVariableSP StopInfo::GetExpressionVariable(StopInfoSP &stop_info_sp) { @@ -1175,8 +1177,8 @@ StopInfoThreadPlan *plan_stop_info = static_cast(stop_info_sp.get()); return plan_stop_info->GetExpressionVariable(); - } else - return ExpressionVariableSP(); + } + return ExpressionVariableSP(); } lldb::ValueObjectSP Index: source/Target/Target.cpp =================================================================== --- source/Target/Target.cpp +++ source/Target/Target.cpp @@ -280,15 +280,15 @@ BreakpointList &Target::GetBreakpointList(bool internal) { if (internal) return m_internal_breakpoint_list; - else - return m_breakpoint_list; + + return m_breakpoint_list; } const BreakpointList &Target::GetBreakpointList(bool internal) const { if (internal) return m_internal_breakpoint_list; - else - return m_breakpoint_list; + + return m_breakpoint_list; } BreakpointSP Target::GetBreakpointByID(break_id_t break_id) { @@ -1104,7 +1104,8 @@ StructuredData::ParseJSONFromFile(file, error); if (!error.Success()) { return error; - } else if (!input_data_sp || !input_data_sp->IsValid()) { + } + if (!input_data_sp || !input_data_sp->IsValid()) { error.SetErrorStringWithFormat("Invalid JSON from input file: %s.", file.GetPath().c_str()); return error; @@ -1592,10 +1593,9 @@ ArchSpec merged_arch(m_arch.GetSpec()); merged_arch.MergeFrom(arch_spec); return SetArchitecture(merged_arch); - } else { - // The new architecture is different, we just need to replace it - return SetArchitecture(arch_spec); } + // The new architecture is different, we just need to replace it + return SetArchitecture(arch_spec); } return false; } @@ -1726,9 +1726,9 @@ section_sp.get(), addr.GetOffset(), dst, dst_len); if (bytes_read > 0) return bytes_read; - else - error.SetErrorStringWithFormat("error reading data from section %s", - section_sp->GetName().GetCString()); + + error.SetErrorStringWithFormat("error reading data from section %s", + section_sp->GetName().GetCString()); } else error.SetErrorString("address isn't from a object file"); } else @@ -2173,9 +2173,8 @@ } else { if (languages_for_expressions.empty()) { return nullptr; - } else { - language = *languages_for_expressions.begin(); } + language = *languages_for_expressions.begin(); } } @@ -2190,9 +2189,8 @@ if (type_system) { return type_system->GetPersistentExpressionState(); - } else { - return nullptr; } + return nullptr; } UserExpression *Target::GetUserExpressionForLanguage( @@ -3596,8 +3594,8 @@ if (exp_values) return exp_values->GetPropertyAtIndexAsBoolean( exe_ctx, ePropertyInjectLocalVars, true); - else - return true; + + return true; } void TargetProperties::SetInjectLocalVariables(ExecutionContext *exe_ctx, @@ -3619,8 +3617,8 @@ if (exp_values) return exp_values->GetPropertyAtIndexAsBoolean( nullptr, ePropertyUseModernTypeLookup, true); - else - return true; + + return true; } ArchSpec TargetProperties::GetDefaultArchitecture() const { Index: source/Target/Thread.cpp =================================================================== --- source/Target/Thread.cpp +++ source/Target/Thread.cpp @@ -341,8 +341,8 @@ BroadcastSelectedFrameChange(frame_sp->GetStackID()); FunctionOptimizationWarning(frame_sp.get()); return true; - } else - return false; + } + return false; } bool Thread::SetSelectedFrameByIndexNoisily(uint32_t frame_idx, @@ -367,8 +367,8 @@ return frame_sp->GetStatus(output_stream, show_frame_info, show_source); } return false; - } else - return false; + } + return false; } void Thread::FunctionOptimizationWarning(StackFrame *frame) { @@ -404,7 +404,8 @@ if (have_valid_stop_info && !plan_overrides_trace && !plan_failed) { return m_stop_info_sp; - } else if (completed_plan_sp) { + } + if (completed_plan_sp) { return StopInfo::CreateStopReasonWithPlan( completed_plan_sp, GetReturnValueObject(), GetExpressionVariable()); } else { @@ -465,9 +466,9 @@ ProcessSP process_sp(GetProcess()); if (process_sp) return m_stop_info_stop_id == process_sp->GetStopID(); - else - return true; // Process is no longer around so stop info is always up to - // date... + + return true; // Process is no longer around so stop info is always up to + // date... } void Thread::ResetStopInfo() { @@ -502,12 +503,11 @@ void Thread::SetShouldReportStop(Vote vote) { if (vote == eVoteNoOpinion) return; - else { - m_override_should_notify = (vote == eVoteYes ? eLazyBoolYes : eLazyBoolNo); - if (m_stop_info_sp) - m_stop_info_sp->OverrideShouldNotify(m_override_should_notify == - eLazyBoolYes); - } + + m_override_should_notify = (vote == eVoteYes ? eLazyBoolYes : eLazyBoolNo); + if (m_stop_info_sp) + m_stop_info_sp->OverrideShouldNotify(m_override_should_notify == + eLazyBoolYes); } void Thread::SetStopInfoToNothing() { @@ -874,14 +874,14 @@ !current_plan->OkayToDiscard()) { PopPlan(); break; - } else { - PopPlan(); + } + PopPlan(); - current_plan = GetCurrentPlan(); - if (current_plan == nullptr) { - break; + current_plan = GetCurrentPlan(); + if (current_plan == nullptr) { + break; } - } + } else { break; } @@ -977,18 +977,18 @@ ": returning vote for complete stack's back plan", GetID()); return m_completed_plan_stack.back()->ShouldReportStop(event_ptr); - } else { - Vote thread_vote = eVoteNoOpinion; - ThreadPlan *plan_ptr = GetCurrentPlan(); - while (1) { - if (plan_ptr->PlanExplainsStop(event_ptr)) { - thread_vote = plan_ptr->ShouldReportStop(event_ptr); - break; - } - if (PlanIsBasePlan(plan_ptr)) - break; - else - plan_ptr = GetPreviousPlan(plan_ptr); + } + Vote thread_vote = eVoteNoOpinion; + ThreadPlan *plan_ptr = GetCurrentPlan(); + while (1) { + if (plan_ptr->PlanExplainsStop(event_ptr)) { + thread_vote = plan_ptr->ShouldReportStop(event_ptr); + break; + } + if (PlanIsBasePlan(plan_ptr)) + break; + + plan_ptr = GetPreviousPlan(plan_ptr); } if (log) log->Printf("Thread::ShouldReportStop() tid = 0x%4.4" PRIx64 @@ -996,7 +996,6 @@ GetID(), thread_vote); return thread_vote; - } } Vote Thread::ShouldReportRun(Event *event_ptr) { @@ -1017,16 +1016,15 @@ m_completed_plan_stack.back()->GetName()); return m_completed_plan_stack.back()->ShouldReportRun(event_ptr); - } else { - if (log) - log->Printf("Current Plan for thread %d(%p) (0x%4.4" PRIx64 - ", %s): %s being asked whether we should report run.", - GetIndexID(), static_cast(this), GetID(), - StateAsCString(GetTemporaryResumeState()), - GetCurrentPlan()->GetName()); - - return GetCurrentPlan()->ShouldReportRun(event_ptr); } + if (log) + log->Printf("Current Plan for thread %d(%p) (0x%4.4" PRIx64 + ", %s): %s being asked whether we should report run.", + GetIndexID(), static_cast(this), GetID(), + StateAsCString(GetTemporaryResumeState()), + GetCurrentPlan()->GetName()); + + return GetCurrentPlan()->ShouldReportRun(event_ptr); } bool Thread::MatchesSpec(const ThreadSpec *spec) { @@ -1060,16 +1058,15 @@ if (m_plan_stack.size() <= 1) return; - else { - ThreadPlanSP &plan = m_plan_stack.back(); - if (log) { - log->Printf("Popping plan: \"%s\", tid = 0x%4.4" PRIx64 ".", - plan->GetName(), plan->GetThread().GetID()); + + ThreadPlanSP &plan = m_plan_stack.back(); + if (log) { + log->Printf("Popping plan: \"%s\", tid = 0x%4.4" PRIx64 ".", + plan->GetName(), plan->GetThread().GetID()); } m_completed_plan_stack.push_back(plan); plan->WillPop(); m_plan_stack.pop_back(); - } } void Thread::DiscardPlan() { @@ -1235,8 +1232,8 @@ if (idx == thread_index) { up_to_plan_ptr = plan_sp.get(); break; - } else - idx++; + } + idx++; } if (up_to_plan_ptr == nullptr) @@ -1338,7 +1335,7 @@ bool Thread::PlanIsBasePlan(ThreadPlan *plan_ptr) { if (plan_ptr->IsBasePlan()) return true; - else if (m_plan_stack.size() == 0) + if (m_plan_stack.size() == 0) return false; else return m_plan_stack[0].get() == plan_ptr; @@ -1764,7 +1761,8 @@ if (outside_function.empty()) { return Status("Cannot locate an address for %s:%i.", file.GetFilename().AsCString(), line); - } else if (outside_function.size() == 1) { + } + if (outside_function.size() == 1) { return Status("%s:%i is outside the current function.", file.GetFilename().AsCString(), line); } else { @@ -1835,8 +1833,8 @@ if (loader) return loader->GetThreadLocalData(module, shared_from_this(), tls_file_addr); - else - return LLDB_INVALID_ADDRESS; + + return LLDB_INVALID_ADDRESS; } bool Thread::SafeToCallFunctions() { Index: source/Target/ThreadList.cpp =================================================================== --- source/Target/ThreadList.cpp +++ source/Target/ThreadList.cpp @@ -61,8 +61,8 @@ ThreadSP expr_thread_sp = FindThreadByID(m_expression_tid_stack.back()); if (expr_thread_sp) return expr_thread_sp; - else - return GetSelectedThread(); + + return GetSelectedThread(); } void ThreadList::PushExpressionExecutionThread(lldb::tid_t tid) { Index: source/Target/ThreadPlan.cpp =================================================================== --- source/Target/ThreadPlan.cpp +++ source/Target/ThreadPlan.cpp @@ -43,9 +43,8 @@ bool actual_value = DoPlanExplainsStop(event_ptr); m_cached_plan_explains_stop = actual_value ? eLazyBoolYes : eLazyBoolNo; return actual_value; - } else { - return m_cached_plan_explains_stop == eLazyBoolYes; } + return m_cached_plan_explains_stop == eLazyBoolYes; } bool ThreadPlan::IsPlanComplete() { @@ -143,8 +142,8 @@ if (m_tracer_sp && m_tracer_sp->TracingEnabled() && m_tracer_sp->SingleStepEnabled()) return eStateStepping; - else - return GetPlanRunState(); + + return GetPlanRunState(); } bool ThreadPlan::IsUsuallyUnexplainedStopReason(lldb::StopReason reason) { Index: source/Target/ThreadPlanBase.cpp =================================================================== --- source/Target/ThreadPlanBase.cpp +++ source/Target/ThreadPlanBase.cpp @@ -59,8 +59,8 @@ // handles the stop. if (TracerExplainsStop()) return false; - else - return true; + + return true; } Vote ThreadPlanBase::ShouldReportStop(Event *event_ptr) { @@ -69,8 +69,8 @@ bool should_notify = stop_info_sp->ShouldNotify(event_ptr); if (should_notify) return eVoteYes; - else - return eVoteNoOpinion; + + return eVoteNoOpinion; } else return eVoteNoOpinion; } Index: source/Target/ThreadPlanCallFunction.cpp =================================================================== --- source/Target/ThreadPlanCallFunction.cpp +++ source/Target/ThreadPlanCallFunction.cpp @@ -75,17 +75,17 @@ log->Printf("ThreadPlanCallFunction(%p): %s.", static_cast(this), m_constructor_errors.GetData()); return false; - } else { - ObjectFile *objectFile = exe_module->GetObjectFile(); - if (!objectFile) { - m_constructor_errors.Printf( - "Could not find object file for module \"%s\".", - exe_module->GetFileSpec().GetFilename().AsCString()); + } + ObjectFile *objectFile = exe_module->GetObjectFile(); + if (!objectFile) { + m_constructor_errors.Printf( + "Could not find object file for module \"%s\".", + exe_module->GetFileSpec().GetFilename().AsCString()); - if (log) - log->Printf("ThreadPlanCallFunction(%p): %s.", - static_cast(this), m_constructor_errors.GetData()); - return false; + if (log) + log->Printf("ThreadPlanCallFunction(%p): %s.", static_cast(this), + m_constructor_errors.GetData()); + return false; } m_start_addr = objectFile->GetEntryPointAddress(); @@ -98,7 +98,6 @@ static_cast(this), m_constructor_errors.GetData()); return false; } - } start_load_addr = m_start_addr.GetLoadAddress(&GetTarget()); @@ -266,8 +265,8 @@ Vote ThreadPlanCallFunction::ShouldReportStop(Event *event_ptr) { if (m_takedown_done || IsPlanComplete()) return eVoteYes; - else - return ThreadPlan::ShouldReportStop(event_ptr); + + return ThreadPlan::ShouldReportStop(event_ptr); } bool ThreadPlanCallFunction::DoPlanExplainsStop(Event *event_ptr) { @@ -347,14 +346,14 @@ "returning true"); m_real_stop_info_sp->OverrideShouldStop(false); return true; - } else { - if (log) - log->Printf("ThreadPlanCallFunction::PlanExplainsStop: we are not " - "ignoring breakpoints, overriding breakpoint stop info " - "ShouldStop, returning true"); - m_real_stop_info_sp->OverrideShouldStop(true); - return false; } + if (log) + log->Printf("ThreadPlanCallFunction::PlanExplainsStop: we are not " + "ignoring breakpoints, overriding breakpoint stop info " + "ShouldStop, returning true"); + m_real_stop_info_sp->OverrideShouldStop(true); + return false; + } else if (!m_unwind_on_error) { // If we don't want to discard this plan, than any stop we don't understand // should be propagated up the stack. @@ -372,8 +371,8 @@ m_real_stop_info_sp->ShouldStopSynchronous(event_ptr)) { SetPlanComplete(false); return m_subplan_sp ? m_unwind_on_error : false; - } else - return true; + } + return true; } } @@ -386,9 +385,8 @@ if (IsPlanComplete()) { ReportRegisterState("Function completed. Register state was:"); return true; - } else { - return false; } + return false; } bool ThreadPlanCallFunction::StopOthers() { return m_stop_other_threads; } @@ -425,9 +423,8 @@ ThreadPlan::MischiefManaged(); return true; - } else { - return false; } + return false; } void ThreadPlanCallFunction::SetBreakpoints() { Index: source/Target/ThreadPlanCallUserExpression.cpp =================================================================== --- source/Target/ThreadPlanCallUserExpression.cpp +++ source/Target/ThreadPlanCallUserExpression.cpp @@ -95,9 +95,8 @@ ThreadPlan::MischiefManaged(); return true; - } else { - return false; } + return false; } StopInfoSP ThreadPlanCallUserExpression::GetRealStopInfo() { Index: source/Target/ThreadPlanRunToAddress.cpp =================================================================== --- source/Target/ThreadPlanRunToAddress.cpp +++ source/Target/ThreadPlanRunToAddress.cpp @@ -94,7 +94,8 @@ if (num_addresses == 0) { s->Printf("run to address with no addresses given."); return; - } else if (num_addresses == 1) + } + if (num_addresses == 1) s->Printf("run to address: "); else s->Printf("run to addresses: "); @@ -107,7 +108,8 @@ if (num_addresses == 0) { s->Printf("run to address with no addresses given."); return; - } else if (num_addresses == 1) + } + if (num_addresses == 1) s->Printf("Run to address: "); else { s->Printf("Run to addresses: "); @@ -189,8 +191,8 @@ log->Printf("Completed run to address plan."); ThreadPlan::MischiefManaged(); return true; - } else - return false; + } + return false; } bool ThreadPlanRunToAddress::AtOurAddress() { Index: source/Target/ThreadPlanShouldStopHere.cpp =================================================================== --- source/Target/ThreadPlanShouldStopHere.cpp +++ source/Target/ThreadPlanShouldStopHere.cpp @@ -161,6 +161,6 @@ lldb::FrameComparison operation, Status &status) { if (!InvokeShouldStopHereCallback(operation, status)) return QueueStepOutFromHerePlan(m_flags, operation, status); - else - return ThreadPlanSP(); + + return ThreadPlanSP(); } Index: source/Target/ThreadPlanStepInRange.cpp =================================================================== --- source/Target/ThreadPlanStepInRange.cpp +++ source/Target/ThreadPlanStepInRange.cpp @@ -163,8 +163,8 @@ SetPlanComplete(); m_no_more_plans = true; return true; - } else - m_sub_plan_sp.reset(); + } + m_sub_plan_sp.reset(); } if (m_virtual_step) { @@ -306,11 +306,10 @@ m_no_more_plans = true; SetPlanComplete(); return true; - } else { - m_no_more_plans = false; - m_sub_plan_sp->SetPrivate(true); - return false; } + m_no_more_plans = false; + m_sub_plan_sp->SetPrivate(true); + return false; } void ThreadPlanStepInRange::SetAvoidRegexp(const char *name) { Index: source/Target/ThreadPlanStepInstruction.cpp =================================================================== --- source/Target/ThreadPlanStepInstruction.cpp +++ source/Target/ThreadPlanStepInstruction.cpp @@ -110,7 +110,8 @@ SetPlanComplete(); } return (m_thread.GetRegisterContext()->GetPC(0) != m_instruction_addr); - } else if (cur_frame_id < m_stack_id) { + } + if (cur_frame_id < m_stack_id) { // If the current frame is younger than the start frame and we are stepping // over, then we need to continue, but if we are doing just one step, we're // done. @@ -144,12 +145,12 @@ if (--m_iteration_count <= 0) { SetPlanComplete(); return true; - } else { - // We are still stepping, reset the start pc, and in case we've - // stepped out, reset the current stack id. - SetUpState(); - return false; } + // We are still stepping, reset the start pc, and in case we've + // stepped out, reset the current stack id. + SetUpState(); + return false; + } else return false; } else { @@ -201,16 +202,16 @@ false, nullptr, true, stop_others, eVoteNo, eVoteNoOpinion, 0, m_status); return false; - } else { - if (log) { - log->PutCString( - "The stack id we are stepping in changed, but our parent frame " - "did not when stepping from code with no symbols. " - "We are probably just confused about where we are, stopping."); - } + } + if (log) { + log->PutCString( + "The stack id we are stepping in changed, but our parent frame " + "did not when stepping from code with no symbols. " + "We are probably just confused about where we are, stopping."); + } SetPlanComplete(); return true; - } + } else { if (log) log->Printf("Could not find previous frame, stopping."); @@ -224,12 +225,12 @@ if (--m_iteration_count <= 0) { SetPlanComplete(); return true; - } else { - // We are still stepping, reset the start pc, and in case we've stepped - // in or out, reset the current stack id. - SetUpState(); - return false; } + // We are still stepping, reset the start pc, and in case we've stepped + // in or out, reset the current stack id. + SetUpState(); + return false; + } else return false; } @@ -250,7 +251,6 @@ log->Printf("Completed single instruction step plan."); ThreadPlan::MischiefManaged(); return true; - } else { - return false; } + return false; } Index: source/Target/ThreadPlanStepOut.cpp =================================================================== --- source/Target/ThreadPlanStepOut.cpp +++ source/Target/ThreadPlanStepOut.cpp @@ -251,13 +251,14 @@ // inlined frame. if (m_step_out_to_inline_plan_sp) { return m_step_out_to_inline_plan_sp->MischiefManaged(); - } else if (m_step_through_inline_plan_sp) { + } + if (m_step_through_inline_plan_sp) { if (m_step_through_inline_plan_sp->MischiefManaged()) { CalculateReturnValue(); SetPlanComplete(); return true; - } else - return false; + } + return false; } else if (m_step_out_further_plan_sp) { return m_step_out_further_plan_sp->MischiefManaged(); } @@ -306,7 +307,8 @@ return true; } return false; - } else if (IsUsuallyUnexplainedStopReason(reason)) + } + if (IsUsuallyUnexplainedStopReason(reason)) return false; else return true; @@ -327,8 +329,8 @@ m_step_out_to_inline_plan_sp.reset(); SetPlanComplete(false); return true; - } else - done = true; + } + done = true; } else return m_step_out_to_inline_plan_sp->ShouldStop(event_ptr); } else if (m_step_through_inline_plan_sp) { @@ -416,9 +418,8 @@ ThreadPlan::MischiefManaged(); return true; - } else { - return false; } + return false; } bool ThreadPlanStepOut::QueueInlinedStepPlan(bool queue_now) { Index: source/Target/ThreadPlanStepOverBreakpoint.cpp =================================================================== --- source/Target/ThreadPlanStepOverBreakpoint.cpp +++ source/Target/ThreadPlanStepOverBreakpoint.cpp @@ -150,16 +150,15 @@ // If we are still at the PC of our breakpoint, then for some reason we // didn't get a chance to run. return false; - } else { - Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_STEP)); - if (log) - log->Printf("Completed step over breakpoint plan."); - // Otherwise, re-enable the breakpoint we were stepping over, and we're - // done. - ReenableBreakpointSite(); - ThreadPlan::MischiefManaged(); - return true; } + Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_STEP)); + if (log) + log->Printf("Completed step over breakpoint plan."); + // Otherwise, re-enable the breakpoint we were stepping over, and we're + // done. + ReenableBreakpointSite(); + ThreadPlan::MischiefManaged(); + return true; } void ThreadPlanStepOverBreakpoint::ReenableBreakpointSite() { Index: source/Target/ThreadPlanStepOverRange.cpp =================================================================== --- source/Target/ThreadPlanStepOverRange.cpp +++ source/Target/ThreadPlanStepOverRange.cpp @@ -181,13 +181,12 @@ false, nullptr, true, stop_others, eVoteNo, eVoteNoOpinion, 0, m_status, true); break; - } else { - new_plan_sp = m_thread.QueueThreadPlanForStepThrough( - m_stack_id, false, stop_others, m_status); - // If we found a way through, then we should stop recursing. - if (new_plan_sp) - break; } + new_plan_sp = m_thread.QueueThreadPlanForStepThrough( + m_stack_id, false, stop_others, m_status); + // If we found a way through, then we should stop recursing. + if (new_plan_sp) + break; } } else { // If we're still in the range, keep going. @@ -331,8 +330,8 @@ // this calculation again in MischiefManaged. SetPlanComplete(m_status.Success()); return true; - } else - return false; + } + return false; } bool ThreadPlanStepOverRange::DoPlanExplainsStop(Event *event_ptr) { Index: source/Target/ThreadPlanStepRange.cpp =================================================================== --- source/Target/ThreadPlanStepRange.cpp +++ source/Target/ThreadPlanStepRange.cpp @@ -196,7 +196,8 @@ if (m_addr_context.function != nullptr) { return m_addr_context.function->GetAddressRange().ContainsLoadAddress( cur_pc, m_thread.CalculateTarget().get()); - } else if (m_addr_context.symbol && m_addr_context.symbol->ValueIsAddress()) { + } + if (m_addr_context.symbol && m_addr_context.symbol->ValueIsAddress()) { AddressRange range(m_addr_context.symbol->GetAddressRef(), m_addr_context.symbol->GetByteSize()); return range.ContainsLoadAddress(cur_pc, m_thread.CalculateTarget().get()); @@ -260,22 +261,19 @@ } if (!m_instruction_ranges[i]) return nullptr; - else { - // Find where we are in the instruction list as well. If we aren't at - // an instruction, return nullptr. In this case, we're probably lost, - // and shouldn't try to do anything fancy. - - insn_offset = - m_instruction_ranges[i] - ->GetInstructionList() - .GetIndexOfInstructionAtLoadAddress(addr, GetTarget()); - if (insn_offset == UINT32_MAX) - return nullptr; - else { - range_index = i; - return &m_instruction_ranges[i]->GetInstructionList(); - } - } + + // Find where we are in the instruction list as well. If we aren't at + // an instruction, return nullptr. In this case, we're probably lost, + // and shouldn't try to do anything fancy. + + insn_offset = m_instruction_ranges[i] + ->GetInstructionList() + .GetIndexOfInstructionAtLoadAddress(addr, GetTarget()); + if (insn_offset == UINT32_MAX) + return nullptr; + + range_index = i; + return &m_instruction_ranges[i]->GetInstructionList(); } } return nullptr; @@ -312,24 +310,23 @@ GetInstructionsForAddress(cur_addr, range_index, pc_index); if (instructions == nullptr) return false; - else { - Target &target = GetThread().GetProcess()->GetTarget(); - uint32_t branch_index; - branch_index = - instructions->GetIndexOfNextBranchInstruction(pc_index, target); - - Address run_to_address; - - // If we didn't find a branch, run to the end of the range. - if (branch_index == UINT32_MAX) { - uint32_t last_index = instructions->GetSize() - 1; - if (last_index - pc_index > 1) { - InstructionSP last_inst = - instructions->GetInstructionAtIndex(last_index); - size_t last_inst_size = last_inst->GetOpcode().GetByteSize(); - run_to_address = last_inst->GetAddress(); - run_to_address.Slide(last_inst_size); - } + + Target &target = GetThread().GetProcess()->GetTarget(); + uint32_t branch_index; + branch_index = + instructions->GetIndexOfNextBranchInstruction(pc_index, target); + + Address run_to_address; + + // If we didn't find a branch, run to the end of the range. + if (branch_index == UINT32_MAX) { + uint32_t last_index = instructions->GetSize() - 1; + if (last_index - pc_index > 1) { + InstructionSP last_inst = instructions->GetInstructionAtIndex(last_index); + size_t last_inst_size = last_inst->GetOpcode().GetByteSize(); + run_to_address = last_inst->GetAddress(); + run_to_address.Slide(last_inst_size); + } } else if (branch_index - pc_index > 1) { run_to_address = instructions->GetInstructionAtIndex(branch_index)->GetAddress(); @@ -366,11 +363,11 @@ m_next_branch_bp_sp->SetBreakpointKind("next-branch-location"); return true; - } else - return false; + } + return false; } - } - return false; + + return false; } bool ThreadPlanStepRange::NextRangeBreakpointExplainsStop( @@ -384,7 +381,7 @@ m_thread.GetProcess()->GetBreakpointSiteList().FindByID(bp_site_id); if (!bp_site_sp) return false; - else if (!bp_site_sp->IsBreakpointAtThisSite(m_next_branch_bp_sp->GetID())) + if (!bp_site_sp->IsBreakpointAtThisSite(m_next_branch_bp_sp->GetID())) return false; else { // If we've hit the next branch breakpoint, then clear it. @@ -415,8 +412,8 @@ StateType ThreadPlanStepRange::GetPlanRunState() { if (m_next_branch_bp_sp) return eStateRunning; - else - return eStateStepping; + + return eStateStepping; } bool ThreadPlanStepRange::MischiefManaged() { @@ -448,9 +445,8 @@ ClearNextBranchBreakpoint(); ThreadPlan::MischiefManaged(); return true; - } else { - return false; } + return false; } bool ThreadPlanStepRange::IsPlanStale() { @@ -463,7 +459,8 @@ "stepped out."); } return true; - } else if (frame_order == eFrameCompareEqual && InSymbol()) { + } + if (frame_order == eFrameCompareEqual && InSymbol()) { // If we are not in a place we should step through, we've gotten stale. One // tricky bit here is that some stubs don't push a frame, so we should. // check that we are in the same symbol. Index: source/Target/ThreadPlanStepThrough.cpp =================================================================== --- source/Target/ThreadPlanStepThrough.cpp +++ source/Target/ThreadPlanStepThrough.cpp @@ -199,10 +199,9 @@ if (m_backstop_bkpt_id != LLDB_INVALID_BREAK_ID) { m_sub_plan_sp.reset(); return false; - } else { - SetPlanComplete(false); - return true; } + SetPlanComplete(false); + return true; } // Next see if there is a specific step through plan at our current pc (these @@ -212,10 +211,9 @@ if (m_sub_plan_sp) { PushPlan(m_sub_plan_sp); return false; - } else { - SetPlanComplete(); - return true; } + SetPlanComplete(); + return true; } bool ThreadPlanStepThrough::StopOthers() { return m_stop_others; } @@ -242,14 +240,13 @@ if (!IsPlanComplete()) { return false; - } else { - if (log) - log->Printf("Completed step through step plan."); - - ClearBackstopBreakpoint(); - ThreadPlan::MischiefManaged(); - return true; } + if (log) + log->Printf("Completed step through step plan."); + + ClearBackstopBreakpoint(); + ThreadPlan::MischiefManaged(); + return true; } bool ThreadPlanStepThrough::HitOurBackstopBreakpoint() { Index: source/Target/ThreadPlanStepUntil.cpp =================================================================== --- source/Target/ThreadPlanStepUntil.cpp +++ source/Target/ThreadPlanStepUntil.cpp @@ -132,7 +132,8 @@ error->PutCString( "Could not create hardware breakpoint for thread plan."); return false; - } else if (m_return_bp_id == LLDB_INVALID_BREAK_ID) { + } + if (m_return_bp_id == LLDB_INVALID_BREAK_ID) { if (error) error->PutCString("Could not create return breakpoint."); return false; @@ -193,62 +194,63 @@ else m_explains_stop = false; return; - } else { - // Check if we've hit one of our "until" breakpoints. - until_collection::iterator pos, end = m_until_points.end(); - for (pos = m_until_points.begin(); pos != end; pos++) { - if (this_site->IsBreakpointAtThisSite((*pos).second)) { - // If we're at the right stack depth, then we're done. - - bool done; - StackID frame_zero_id = - m_thread.GetStackFrameAtIndex(0)->GetStackID(); - - if (frame_zero_id == m_stack_id) - done = true; - else if (frame_zero_id < m_stack_id) + } + // Check if we've hit one of our "until" breakpoints. + until_collection::iterator pos, end = m_until_points.end(); + for (pos = m_until_points.begin(); pos != end; pos++) { + if (this_site->IsBreakpointAtThisSite((*pos).second)) { + // If we're at the right stack depth, then we're done. + + bool done; + StackID frame_zero_id = + m_thread.GetStackFrameAtIndex(0)->GetStackID(); + + if (frame_zero_id == m_stack_id) + done = true; + else if (frame_zero_id < m_stack_id) + done = false; + else { + StackFrameSP older_frame_sp = m_thread.GetStackFrameAtIndex(1); + + // But if we can't even unwind one frame we should just get out + // of here & stop... + if (older_frame_sp) { + const SymbolContext &older_context = + older_frame_sp->GetSymbolContext(eSymbolContextEverything); + SymbolContext stack_context; + m_stack_id.GetSymbolContextScope()->CalculateSymbolContext( + &stack_context); + + done = (older_context == stack_context); + } else done = false; - else { - StackFrameSP older_frame_sp = m_thread.GetStackFrameAtIndex(1); - - // But if we can't even unwind one frame we should just get out - // of here & stop... - if (older_frame_sp) { - const SymbolContext &older_context = - older_frame_sp->GetSymbolContext(eSymbolContextEverything); - SymbolContext stack_context; - m_stack_id.GetSymbolContextScope()->CalculateSymbolContext( - &stack_context); - - done = (older_context == stack_context); - } else - done = false; - } - - if (done) - SetPlanComplete(); - else - m_should_stop = false; - - // Otherwise we've hit this breakpoint recursively. If we're the - // only breakpoint here, then we do explain the stop, and we'll - // continue. If not then we should let higher plans handle this - // stop. - if (this_site->GetNumberOfOwners() == 1) - m_explains_stop = true; - else { - m_should_stop = true; - m_explains_stop = false; - } - return; } + + if (done) + SetPlanComplete(); + else + m_should_stop = false; + + // Otherwise we've hit this breakpoint recursively. If we're the + // only breakpoint here, then we do explain the stop, and we'll + // continue. If not then we should let higher plans handle this + // stop. + if (this_site->GetNumberOfOwners() == 1) + m_explains_stop = true; + else { + m_should_stop = true; + m_explains_stop = false; + } + return; } - } - // If we get here we haven't hit any of our breakpoints, so let the - // higher plans take care of the stop. - m_explains_stop = false; - return; - } else if (IsUsuallyUnexplainedStopReason(reason)) { + } + + // If we get here we haven't hit any of our breakpoints, so let the + // higher plans take care of the stop. + m_explains_stop = false; + return; + } + if (IsUsuallyUnexplainedStopReason(reason)) { m_explains_stop = false; } else { m_explains_stop = true; Index: source/Target/ThreadPlanTracer.cpp =================================================================== --- source/Target/ThreadPlanTracer.cpp +++ source/Target/ThreadPlanTracer.cpp @@ -44,11 +44,11 @@ Stream *ThreadPlanTracer::GetLogStream() { if (m_stream_sp) return m_stream_sp.get(); - else { - TargetSP target_sp(m_thread.CalculateTarget()); - if (target_sp) - return target_sp->GetDebugger().GetOutputFile().get(); - } + + TargetSP target_sp(m_thread.CalculateTarget()); + if (target_sp) + return target_sp->GetDebugger().GetOutputFile().get(); + return nullptr; } @@ -70,8 +70,8 @@ if (m_enabled && m_single_step) { lldb::StopInfoSP stop_info = m_thread.GetStopInfo(); return (stop_info->GetStopReason() == eStopReasonTrace); - } else - return false; + } + return false; } #pragma mark ThreadPlanAssemblyTracer Index: source/Target/UnixSignals.cpp =================================================================== --- source/Target/UnixSignals.cpp +++ source/Target/UnixSignals.cpp @@ -132,8 +132,8 @@ collection::const_iterator pos = m_signals.find(signo); if (pos == m_signals.end()) return nullptr; - else - return pos->second.m_name.GetCString(); + + return pos->second.m_name.GetCString(); } bool UnixSignals::SignalIsValid(int32_t signo) const { @@ -179,13 +179,12 @@ collection::const_iterator end = m_signals.end(); if (pos == end) return LLDB_INVALID_SIGNAL_NUMBER; - else { - pos++; - if (pos == end) - return LLDB_INVALID_SIGNAL_NUMBER; - else - return pos->first; - } + + pos++; + if (pos == end) + return LLDB_INVALID_SIGNAL_NUMBER; + + return pos->first; } const char *UnixSignals::GetSignalInfo(int32_t signo, bool &should_suppress, @@ -194,13 +193,12 @@ collection::const_iterator pos = m_signals.find(signo); if (pos == m_signals.end()) return nullptr; - else { - const Signal &signal = pos->second; - should_suppress = signal.m_suppress; - should_stop = signal.m_stop; - should_notify = signal.m_notify; - return signal.m_name.AsCString(""); - } + + const Signal &signal = pos->second; + should_suppress = signal.m_suppress; + should_stop = signal.m_stop; + should_notify = signal.m_notify; + return signal.m_name.AsCString(""); } bool UnixSignals::GetShouldSuppress(int signo) const { Index: source/Utility/ConstString.cpp =================================================================== --- source/Utility/ConstString.cpp +++ source/Utility/ConstString.cpp @@ -264,15 +264,14 @@ if (case_sensitive) { return lhs_string_ref.compare(rhs_string_ref); - } else { - return lhs_string_ref.compare_lower(rhs_string_ref); } + return lhs_string_ref.compare_lower(rhs_string_ref); } if (lhs_cstr) return +1; // LHS isn't nullptr but RHS is - else - return -1; // LHS is nullptr but RHS isn't + + return -1; // LHS is nullptr but RHS isn't } void ConstString::Dump(Stream *s, const char *fail_value) const { Index: source/Utility/DataExtractor.cpp =================================================================== --- source/Utility/DataExtractor.cpp +++ source/Utility/DataExtractor.cpp @@ -823,19 +823,19 @@ ::memset(dst + src_len, 0, num_zeroes); } return src_len; - } else { - // We are only copying some of the value from src into dst.. + } + // We are only copying some of the value from src into dst.. - if (dst_byte_order == eByteOrderBig) { - // Big endian dst - if (m_byte_order == eByteOrderBig) { - // Big endian dst, with big endian src - ::memcpy(dst, src + (src_len - dst_len), dst_len); - } else { - // Big endian dst, with little endian src - for (uint32_t i = 0; i < dst_len; ++i) - dst[i] = src[dst_len - 1 - i]; - } + if (dst_byte_order == eByteOrderBig) { + // Big endian dst + if (m_byte_order == eByteOrderBig) { + // Big endian dst, with big endian src + ::memcpy(dst, src + (src_len - dst_len), dst_len); + } else { + // Big endian dst, with little endian src + for (uint32_t i = 0; i < dst_len; ++i) + dst[i] = src[dst_len - 1 - i]; + } } else { // Little endian dst if (m_byte_order == eByteOrderBig) { @@ -848,7 +848,6 @@ } } return dst_len; - } } return 0; } Index: source/Utility/JSON.cpp =================================================================== --- source/Utility/JSON.cpp +++ source/Utility/JSON.cpp @@ -248,27 +248,25 @@ start_index); value = std::move(error.GetString()); return Token::Status; - - } else { - const bool is_end_quote = escaped_ch == '"'; - const bool is_null = escaped_ch == 0; - if (was_escaped || (!is_end_quote && !is_null)) { - if (CHAR_MIN <= escaped_ch && escaped_ch <= CHAR_MAX) { - value.append(1, (char)escaped_ch); - } else { - error.Printf("error: wide character support is needed for unicode " - "character 0x%4.4x at offset %" PRIu64, - escaped_ch, start_index); - value = std::move(error.GetString()); - return Token::Status; - } + } + const bool is_end_quote = escaped_ch == '"'; + const bool is_null = escaped_ch == 0; + if (was_escaped || (!is_end_quote && !is_null)) { + if (CHAR_MIN <= escaped_ch && escaped_ch <= CHAR_MAX) { + value.append(1, (char)escaped_ch); + } else { + error.Printf("error: wide character support is needed for unicode " + "character 0x%4.4x at offset %" PRIu64, + escaped_ch, start_index); + value = std::move(error.GetString()); + return Token::Status; + } } else if (is_end_quote) { return Token::String; } else if (is_null) { value = "error: missing end quote for string"; return Token::Status; } - } } } break; @@ -364,35 +362,33 @@ // We have an exponent, make sure we got exponent digits if (got_exp_digits) { return Token::Float; - } else { - error.Printf("error: got exponent character but no exponent digits " - "at offset in float value \"%s\"", - value.c_str()); - value = std::move(error.GetString()); - return Token::Status; } + error.Printf("error: got exponent character but no exponent digits " + "at offset in float value \"%s\"", + value.c_str()); + value = std::move(error.GetString()); + return Token::Status; + } else { // No exponent, but we need at least one decimal after the decimal // point if (got_frac_digits) { return Token::Float; - } else { - error.Printf("error: no digits after decimal point \"%s\"", - value.c_str()); - value = std::move(error.GetString()); - return Token::Status; } + error.Printf("error: no digits after decimal point \"%s\"", + value.c_str()); + value = std::move(error.GetString()); + return Token::Status; } } else { // No decimal point if (got_int_digits) { // We need at least some integer digits to make an integer return Token::Integer; - } else { - error.Printf("error: no digits negate sign \"%s\"", value.c_str()); - value = std::move(error.GetString()); - return Token::Status; } + error.Printf("error: no digits negate sign \"%s\"", value.c_str()); + value = std::move(error.GetString()); + return Token::Status; } } else { error.Printf("error: invalid number found at offset %" PRIu64, @@ -495,7 +491,8 @@ JSONParser::Token token = GetToken(value); if (token == JSONParser::Token::Comma) { continue; - } else if (token == JSONParser::Token::ArrayEnd) { + } + if (token == JSONParser::Token::ArrayEnd) { return JSONValue::SP(array_up.release()); } else { break; Index: source/Utility/RegularExpression.cpp =================================================================== --- source/Utility/RegularExpression.cpp +++ source/Utility/RegularExpression.cpp @@ -129,7 +129,8 @@ // Matched the empty string... match_str = llvm::StringRef(); return true; - } else if (m_matches[idx].rm_eo > m_matches[idx].rm_so) { + } + if (m_matches[idx].rm_eo > m_matches[idx].rm_so) { match_str = s.substr(m_matches[idx].rm_so, m_matches[idx].rm_eo - m_matches[idx].rm_so); return true; @@ -146,7 +147,8 @@ // Matched the empty string... match_str = llvm::StringRef(); return true; - } else if (m_matches[idx1].rm_so < m_matches[idx2].rm_eo) { + } + if (m_matches[idx1].rm_so < m_matches[idx2].rm_eo) { match_str = s.substr(m_matches[idx1].rm_so, m_matches[idx2].rm_eo - m_matches[idx1].rm_so); return true; Index: source/Utility/SelectHelper.cpp =================================================================== --- source/Utility/SelectHelper.cpp +++ source/Utility/SelectHelper.cpp @@ -63,24 +63,24 @@ auto pos = m_fd_map.find(fd); if (pos != m_fd_map.end()) return pos->second.read_is_set; - else - return false; + + return false; } bool SelectHelper::FDIsSetWrite(lldb::socket_t fd) const { auto pos = m_fd_map.find(fd); if (pos != m_fd_map.end()) return pos->second.write_is_set; - else - return false; + + return false; } bool SelectHelper::FDIsSetError(lldb::socket_t fd) const { auto pos = m_fd_map.find(fd); if (pos != m_fd_map.end()) return pos->second.error_is_set; - else - return false; + + return false; } static void updateMaxFd(llvm::Optional &vold, @@ -228,8 +228,8 @@ if (error.GetError() == EINTR) { error.Clear(); continue; // Keep calling select if we get EINTR - } else - return error; + } + return error; } else if (num_set_fds == 0) { // Timeout error.SetError(ETIMEDOUT, lldb::eErrorTypePOSIX); Index: source/Utility/Status.cpp =================================================================== --- source/Utility/Status.cpp +++ source/Utility/Status.cpp @@ -284,9 +284,9 @@ int length = SetErrorStringWithVarArg(format, args); va_end(args); return length; - } else { - m_string.clear(); } + m_string.clear(); + return 0; } @@ -301,9 +301,9 @@ VASprintf(buf, format, args); m_string = buf.str(); return buf.size(); - } else { - m_string.clear(); } + m_string.clear(); + return 0; } Index: source/Utility/Stream.cpp =================================================================== --- source/Utility/Stream.cpp +++ source/Utility/Stream.cpp @@ -52,8 +52,8 @@ size_t Stream::PutSLEB128(int64_t sval) { if (m_flags.Test(eBinary)) return llvm::encodeSLEB128(sval, m_forwarder); - else - return Printf("0x%" PRIi64, sval); + + return Printf("0x%" PRIi64, sval); } //------------------------------------------------------------------ @@ -62,8 +62,8 @@ size_t Stream::PutULEB128(uint64_t uval) { if (m_flags.Test(eBinary)) return llvm::encodeULEB128(uval, m_forwarder); - else - return Printf("0x%" PRIx64, uval); + + return Printf("0x%" PRIx64, uval); } //------------------------------------------------------------------ Index: source/Utility/StreamString.cpp =================================================================== --- source/Utility/StreamString.cpp +++ source/Utility/StreamString.cpp @@ -43,10 +43,9 @@ size_t last_line_begin_pos = m_packet.find_last_of("\r\n"); if (last_line_begin_pos == std::string::npos) { return length; - } else { - ++last_line_begin_pos; - return length - last_line_begin_pos; } + ++last_line_begin_pos; + return length - last_line_begin_pos; } llvm::StringRef StreamString::GetString() const { return m_packet; } Index: source/Utility/StringExtractor.cpp =================================================================== --- source/Utility/StringExtractor.cpp +++ source/Utility/StringExtractor.cpp @@ -283,8 +283,8 @@ llvm::StringRef S = GetStringRef(); if (!S.startswith(str)) return false; - else - m_index += str.size(); + + m_index += str.size(); return true; } Index: source/Utility/StringExtractorGDBRemote.cpp =================================================================== --- source/Utility/StringExtractorGDBRemote.cpp +++ source/Utility/StringExtractorGDBRemote.cpp @@ -315,7 +315,7 @@ if (PACKET_STARTS_WITH("vFile:")) { if (PACKET_STARTS_WITH("vFile:open:")) return eServerPacketType_vFile_open; - else if (PACKET_STARTS_WITH("vFile:close:")) + if (PACKET_STARTS_WITH("vFile:close:")) return eServerPacketType_vFile_close; else if (PACKET_STARTS_WITH("vFile:pread")) return eServerPacketType_vFile_pread; @@ -602,6 +602,6 @@ // If we have a validator callback, try to validate the callback if (m_validator) return m_validator(m_validator_baton, *this); - else - return true; // No validator, so response is valid + + return true; // No validator, so response is valid } Index: source/Utility/StructuredData.cpp =================================================================== --- source/Utility/StructuredData.cpp +++ source/Utility/StructuredData.cpp @@ -95,7 +95,8 @@ JSONParser::Token token = json_parser.GetToken(value); if (token == JSONParser::Token::Comma) { continue; - } else if (token == JSONParser::Token::ArrayEnd) { + } + if (token == JSONParser::Token::ArrayEnd) { return StructuredData::ObjectSP(array_up.release()); } else { break; @@ -160,9 +161,8 @@ // we're at right now. if (match.second.empty()) { return value; - } else { - return value->GetObjectForDotSeparatedPath(match.second); } + return value->GetObjectForDotSeparatedPath(match.second); } return ObjectSP(); } Index: source/Utility/VMRange.cpp =================================================================== --- source/Utility/VMRange.cpp +++ source/Utility/VMRange.cpp @@ -53,7 +53,7 @@ bool lldb_private::operator<(const VMRange &lhs, const VMRange &rhs) { if (lhs.GetBaseAddress() < rhs.GetBaseAddress()) return true; - else if (lhs.GetBaseAddress() > rhs.GetBaseAddress()) + if (lhs.GetBaseAddress() > rhs.GetBaseAddress()) return false; return lhs.GetEndAddress() < rhs.GetEndAddress(); } Index: tools/debugserver/source/DNB.cpp =================================================================== --- tools/debugserver/source/DNB.cpp +++ tools/debugserver/source/DNB.cpp @@ -155,11 +155,10 @@ if (n_events == -1) { if (errno == EINTR) continue; - else { - DNBLogError("kqueue failed with error: (%d): %s", errno, - strerror(errno)); - return NULL; - } + + DNBLogError("kqueue failed with error: (%d): %s", errno, strerror(errno)); + return NULL; + } else if (death_event.flags & EV_ERROR) { int error_no = static_cast(death_event.data); const char *error_str = strerror(error_no); @@ -286,19 +285,17 @@ if (errno == EINTR) continue; break; - } else { - if (WIFSTOPPED(status)) { - continue; - } else // if (WIFEXITED(status) || WIFSIGNALED(status)) - { - DNBLogThreadedIf( - LOG_PROCESS, - "waitpid_thread (): setting exit status for pid = %i to %i", - child_pid, status); - DNBProcessSetExitStatus(child_pid, status); - return NULL; - } } + if (WIFSTOPPED(status)) { + continue; + } // if (WIFEXITED(status) || WIFSIGNALED(status)) + + DNBLogThreadedIf( + LOG_PROCESS, + "waitpid_thread (): setting exit status for pid = %i to %i", child_pid, + status); + DNBProcessSetExitStatus(child_pid, status); + return NULL; } // We should never exit as long as our child process is alive, so if we @@ -431,7 +428,8 @@ if (num_matching_proc_infos == 0) { DNBLogError("error: no processes match '%s'\n", name); return INVALID_NUB_PROCESS; - } else if (num_matching_proc_infos > 1) { + } + if (num_matching_proc_infos > 1) { DNBLogError("error: %llu processes match '%s':\n", (uint64_t)num_matching_proc_infos, name); size_t i; @@ -1715,35 +1713,35 @@ // Found the path relatively... ::strlcpy(resolved_path, max_path, resolved_path_size); return strlen(resolved_path) + 1 < resolved_path_size; - } else { - // Not a relative path, check the PATH environment variable if the - const char *PATH = getenv("PATH"); - if (PATH) { - const char *curr_path_start = PATH; - const char *curr_path_end; - while (curr_path_start && *curr_path_start) { - curr_path_end = strchr(curr_path_start, ':'); - if (curr_path_end == NULL) { - result.assign(curr_path_start); - curr_path_start = NULL; - } else if (curr_path_end > curr_path_start) { - size_t len = curr_path_end - curr_path_start; - result.assign(curr_path_start, len); - curr_path_start += len + 1; - } else - break; + } + // Not a relative path, check the PATH environment variable if the + const char *PATH = getenv("PATH"); + if (PATH) { + const char *curr_path_start = PATH; + const char *curr_path_end; + while (curr_path_start && *curr_path_start) { + curr_path_end = strchr(curr_path_start, ':'); + if (curr_path_end == NULL) { + result.assign(curr_path_start); + curr_path_start = NULL; + } else if (curr_path_end > curr_path_start) { + size_t len = curr_path_end - curr_path_start; + result.assign(curr_path_start, len); + curr_path_start += len + 1; + } else + break; - result += '/'; - result += path; - struct stat s; - if (stat(result.c_str(), &s) == 0) { - ::strlcpy(resolved_path, result.c_str(), resolved_path_size); - return result.size() + 1 < resolved_path_size; - } + result += '/'; + result += path; + struct stat s; + if (stat(result.c_str(), &s) == 0) { + ::strlcpy(resolved_path, result.c_str(), resolved_path_size); + return result.size() + 1 < resolved_path_size; } } - } - return false; + } + + return false; } bool DNBGetOSVersionNumbers(uint64_t *major, uint64_t *minor, uint64_t *patch) { @@ -1767,8 +1765,7 @@ if (arch && arch[0]) { if (strcasecmp(arch, "i386") == 0) return DNBArchProtocol::SetArchitecture(CPU_TYPE_I386); - else if ((strcasecmp(arch, "x86_64") == 0) || - (strcasecmp(arch, "x86_64h") == 0)) + if ((strcasecmp(arch, "x86_64") == 0) || (strcasecmp(arch, "x86_64h") == 0)) return DNBArchProtocol::SetArchitecture(CPU_TYPE_X86_64); else if (strstr(arch, "arm64") == arch || strstr(arch, "armv8") == arch || strstr(arch, "aarch64") == arch) Index: tools/debugserver/source/DNBTimer.h =================================================================== --- tools/debugserver/source/DNBTimer.h +++ tools/debugserver/source/DNBTimer.h @@ -124,13 +124,13 @@ OffsetTimeOfDay(&now); if (now.tv_sec > ts.tv_sec) return true; - else if (now.tv_sec < ts.tv_sec) + if (now.tv_sec < ts.tv_sec) return false; else { if (now.tv_nsec > ts.tv_nsec) return true; - else - return false; + + return false; } } Index: tools/debugserver/source/JSON.cpp =================================================================== --- tools/debugserver/source/JSON.cpp +++ tools/debugserver/source/JSON.cpp @@ -155,7 +155,8 @@ // We have the value, and it is true. value = true; return true; - } else if (JSONFalse::classof(value_sp.get())) { + } + if (JSONFalse::classof(value_sp.get())) { // We have the value, and it is false. value = false; return true; @@ -280,28 +281,26 @@ << start_index; value = error.str(); return Token::Status; - - } else { - const bool is_end_quote = escaped_ch == '"'; - const bool is_null = escaped_ch == 0; - if (was_escaped || (!is_end_quote && !is_null)) { - if (CHAR_MIN <= escaped_ch && escaped_ch <= CHAR_MAX) { - value.append(1, (char)escaped_ch); - } else { - error << "error: wide character support is needed for unicode " - "character 0x" - << std::setprecision(4) << std::hex << escaped_ch; - error << " at offset " << start_index; - value = error.str(); - return Token::Status; - } + } + const bool is_end_quote = escaped_ch == '"'; + const bool is_null = escaped_ch == 0; + if (was_escaped || (!is_end_quote && !is_null)) { + if (CHAR_MIN <= escaped_ch && escaped_ch <= CHAR_MAX) { + value.append(1, (char)escaped_ch); + } else { + error << "error: wide character support is needed for unicode " + "character 0x" + << std::setprecision(4) << std::hex << escaped_ch; + error << " at offset " << start_index; + value = error.str(); + return Token::Status; + } } else if (is_end_quote) { return Token::String; } else if (is_null) { value = "error: missing end quote for string"; return Token::Status; } - } } } break; @@ -395,35 +394,33 @@ // We have an exponent, make sure we got exponent digits if (got_exp_digits) { return Token::Float; - } else { - error << "error: got exponent character but no exponent digits at " - "offset in float value \"" - << value.c_str() << "\""; - value = error.str(); - return Token::Status; } + error << "error: got exponent character but no exponent digits at " + "offset in float value \"" + << value.c_str() << "\""; + value = error.str(); + return Token::Status; + } else { // No exponent, but we need at least one decimal after the decimal // point if (got_frac_digits) { return Token::Float; - } else { - error << "error: no digits after decimal point \"" << value.c_str() - << "\""; - value = error.str(); - return Token::Status; } + error << "error: no digits after decimal point \"" << value.c_str() + << "\""; + value = error.str(); + return Token::Status; } } else { // No decimal point if (got_int_digits) { // We need at least some integer digits to make an integer return Token::Integer; - } else { - error << "error: no digits negate sign \"" << value.c_str() << "\""; - value = error.str(); - return Token::Status; } + error << "error: no digits negate sign \"" << value.c_str() << "\""; + value = error.str(); + return Token::Status; } } else { error << "error: invalid number found at offset " << start_index; @@ -526,7 +523,8 @@ JSONParser::Token token = GetToken(value); if (token == JSONParser::Token::Comma) { continue; - } else if (token == JSONParser::Token::ArrayEnd) { + } + if (token == JSONParser::Token::ArrayEnd) { return JSONValue::SP(array_up.release()); } else { break; Index: tools/debugserver/source/MacOSX/DarwinLog/DarwinLogCollector.cpp =================================================================== --- tools/debugserver/source/MacOSX/DarwinLog/DarwinLogCollector.cpp +++ tools/debugserver/source/MacOSX/DarwinLog/DarwinLogCollector.cpp @@ -118,7 +118,7 @@ static FilterTarget TargetStringToEnum(const std::string &filter_target_name) { if (filter_target_name == "activity") return eFilterTargetActivity; - else if (filter_target_name == "activity-chain") + if (filter_target_name == "activity-chain") return eFilterTargetActivityChain; else if (filter_target_name == "category") return eFilterTargetCategory; @@ -483,7 +483,8 @@ if (depth > MAX_ACTIVITY_CHAIN_DEPTH) { // Terminating condition - too deeply nested. return; - } else if (activity_id == 0) { + } + if (activity_id == 0) { // Terminating condition - no activity. return; } Index: tools/debugserver/source/MacOSX/MachException.cpp =================================================================== --- tools/debugserver/source/MacOSX/MachException.cpp +++ tools/debugserver/source/MacOSX/MachException.cpp @@ -113,7 +113,8 @@ g_message->exc_type = exc_type; g_message->AppendExceptionData(exc_data, exc_data_count); return KERN_SUCCESS; - } else if (!MachTask::IsValid(g_message->task_port)) { + } + if (!MachTask::IsValid(g_message->task_port)) { // Our original exception port isn't valid anymore check for a SIGTRAP if (exc_type == EXC_SOFTWARE && exc_data_count == 2 && exc_data[0] == EXC_SOFT_SIGNAL && exc_data[1] == SIGTRAP) { Index: tools/debugserver/source/MacOSX/MachProcess.mm =================================================================== --- tools/debugserver/source/MacOSX/MachProcess.mm +++ tools/debugserver/source/MacOSX/MachProcess.mm @@ -547,8 +547,8 @@ if (kret == KERN_SUCCESS) return true; - else - return false; + + return false; } ThreadInfo::QoS MachProcess::GetRequestedQoS(nub_thread_t tid, nub_addr_t tsd, @@ -1277,7 +1277,8 @@ m_thread_actions = thread_actions; PrivateResume(); return true; - } else if (state == eStateRunning) { + } + if (state == eStateRunning) { DNBLog("Resume() - task 0x%x is already running, ignoring...", m_task.TaskPort()); return true; @@ -1331,12 +1332,13 @@ "MachProcess::Interrupt() - sent %i signal to interrupt process", m_sent_interrupt_signo); return true; - } else { - m_sent_interrupt_signo = 0; - DNBLogThreadedIf(LOG_PROCESS, "MachProcess::Interrupt() - failed to " - "send %i signal to interrupt process", - m_sent_interrupt_signo); } + m_sent_interrupt_signo = 0; + DNBLogThreadedIf(LOG_PROCESS, + "MachProcess::Interrupt() - failed to " + "send %i signal to interrupt process", + m_sent_interrupt_signo); + } else { DNBLogThreadedIf(LOG_PROCESS, "MachProcess::Interrupt() - previously " "sent an interrupt signal %i that hasn't " @@ -1684,7 +1686,8 @@ (uint64_t)addr, (uint64_t)length, reinterpret_cast(bp)); return bp; - } else if (bp->Release() == 0) { + } + if (bp->Release() == 0) { m_breakpoints.Remove(addr); } // We failed to enable the breakpoint @@ -1716,12 +1719,13 @@ (uint64_t)addr, (uint64_t)length, reinterpret_cast(wp)); return wp; - } else { - DNBLogThreadedIf(LOG_WATCHPOINTS, "MachProcess::CreateWatchpoint ( addr = " - "0x%8.8llx, length = %llu) => FAILED", - (uint64_t)addr, (uint64_t)length); - m_watchpoints.Remove(addr); } + DNBLogThreadedIf(LOG_WATCHPOINTS, + "MachProcess::CreateWatchpoint ( addr = " + "0x%8.8llx, length = %llu) => FAILED", + (uint64_t)addr, (uint64_t)length); + m_watchpoints.Remove(addr); + // We failed to enable the watchpoint return NULL; } @@ -1858,17 +1862,17 @@ "0x%8.8llx, remove = %d ) => success", (uint64_t)addr, remove); return true; - } else { - if (break_op_found) - DNBLogError("MachProcess::DisableBreakpoint ( addr = " - "0x%8.8llx, remove = %d ) : failed to restore " - "original opcode", - (uint64_t)addr, remove); - else - DNBLogError("MachProcess::DisableBreakpoint ( addr = " - "0x%8.8llx, remove = %d ) : opcode changed", - (uint64_t)addr, remove); } + if (break_op_found) + DNBLogError("MachProcess::DisableBreakpoint ( addr = " + "0x%8.8llx, remove = %d ) : failed to restore " + "original opcode", + (uint64_t)addr, remove); + else + DNBLogError("MachProcess::DisableBreakpoint ( addr = " + "0x%8.8llx, remove = %d ) : opcode changed", + (uint64_t)addr, remove); + } else { DNBLogWarning("MachProcess::DisableBreakpoint: unable to disable " "breakpoint 0x%8.8llx", @@ -1945,14 +1949,14 @@ "breakpoint already enabled.", (uint64_t)addr); return true; - } else { - if (bp->HardwarePreferred()) { - bp->SetHardwareIndex(m_thread_list.EnableHardwareBreakpoint(bp)); - if (bp->IsHardware()) { - bp->SetEnabled(true); - return true; - } + } + if (bp->HardwarePreferred()) { + bp->SetHardwareIndex(m_thread_list.EnableHardwareBreakpoint(bp)); + if (bp->IsHardware()) { + bp->SetEnabled(true); + return true; } + } const nub_size_t break_op_size = bp->ByteSize(); assert(break_op_size != 0); @@ -1977,11 +1981,11 @@ "0x%8.8llx ) : SUCCESS.", (uint64_t)addr); return true; - } else { - DNBLogError("MachProcess::EnableBreakpoint ( addr = 0x%8.8llx " - "): breakpoint opcode verification failed.", - (uint64_t)addr); } + DNBLogError("MachProcess::EnableBreakpoint ( addr = 0x%8.8llx " + "): breakpoint opcode verification failed.", + (uint64_t)addr); + } else { DNBLogError("MachProcess::EnableBreakpoint ( addr = 0x%8.8llx ): " "unable to read memory to verify breakpoint opcode.", @@ -2002,7 +2006,6 @@ "software breakpoint opcode for current architecture.", (uint64_t)addr); } - } } return false; } @@ -2019,15 +2022,14 @@ "watchpoint already enabled.", (uint64_t)addr); return true; - } else { - // Currently only try and set hardware watchpoints. - wp->SetHardwareIndex(m_thread_list.EnableHardwareWatchpoint(wp)); - if (wp->IsHardware()) { - wp->SetEnabled(true); - return true; + } + // Currently only try and set hardware watchpoints. + wp->SetHardwareIndex(m_thread_list.EnableHardwareWatchpoint(wp)); + if (wp->IsHardware()) { + wp->SetEnabled(true); + return true; } // TODO: Add software watchpoints by doing page protection tricks. - } } return false; } @@ -2098,8 +2100,8 @@ } } break; - } else if (m_sent_interrupt_signo != 0 && - signo == m_sent_interrupt_signo) { + } + if (m_sent_interrupt_signo != 0 && signo == m_sent_interrupt_signo) { received_interrupt = true; } } @@ -2512,10 +2514,9 @@ ::usleep(250000); DNBLogThreadedIf(LOG_PROCESS, "successfully attached to pid %d", pid); return m_pid; - } else { - ::snprintf(err_str, err_len, "%s", err.AsString()); - DNBLogThreadedIf(LOG_PROCESS, "error: failed to attach to pid %d", pid); } + ::snprintf(err_str, err_len, "%s", err.AsString()); + DNBLogThreadedIf(LOG_PROCESS, "error: failed to attach to pid %d", pid); } return INVALID_NUB_PROCESS; } @@ -3281,7 +3282,8 @@ // Status during fork. //-------------------------------------------------------------- return pid; - } else if (pid == 0) { + } + if (pid == 0) { //-------------------------------------------------------------- // Child process //-------------------------------------------------------------- Index: tools/debugserver/source/MacOSX/MachTask.mm =================================================================== --- tools/debugserver/source/MacOSX/MachTask.mm +++ tools/debugserver/source/MacOSX/MachTask.mm @@ -618,10 +618,10 @@ err = ::pthread_create(&m_exception_thread, NULL, MachTask::ExceptionThread, this); return err.Success(); - } else { - DNBLogError("MachTask::%s (): task invalid, exception thread start failed.", - __FUNCTION__); } + DNBLogError("MachTask::%s (): task invalid, exception thread start failed.", + __FUNCTION__); + return false; } @@ -781,12 +781,12 @@ DNBLogThreadedIf(LOG_EXCEPTIONS, "interrupted, but task still valid, continuing..."); continue; - } else { - DNBLogThreadedIf(LOG_EXCEPTIONS, "task has exited..."); - mach_proc->SetState(eStateExited); - // Our task has died, exit the thread. - break; } + DNBLogThreadedIf(LOG_EXCEPTIONS, "task has exited..."); + mach_proc->SetState(eStateExited); + // Our task has died, exit the thread. + break; + } else if (err.Status() == MACH_RCV_TIMED_OUT) { if (num_exceptions_received > 0) { // We were receiving all current exceptions with a timeout of zero @@ -804,12 +804,11 @@ // Task is still ok DNBLogThreadedIf(LOG_EXCEPTIONS, "got a timeout, continuing..."); continue; - } else { - DNBLogThreadedIf(LOG_EXCEPTIONS, "task has exited..."); - mach_proc->SetState(eStateExited); - // Our task has died, exit the thread. - break; } + DNBLogThreadedIf(LOG_EXCEPTIONS, "task has exited..."); + mach_proc->SetState(eStateExited); + // Our task has died, exit the thread. + break; } #if defined(WITH_SPRINGBOARD) && !defined(WITH_BKS) @@ -948,9 +947,9 @@ getenv("DEBUGSERVER_ZOMBIE_ALLOCATIONS")) { ::mach_vm_protect(task, (*pos).first, (*pos).second, 0, VM_PROT_NONE); return true; - } else - return ::mach_vm_deallocate(task, (*pos).first, (*pos).second) == - KERN_SUCCESS; + } + return ::mach_vm_deallocate(task, (*pos).first, (*pos).second) == + KERN_SUCCESS; } } return false; Index: tools/debugserver/source/MacOSX/MachThread.cpp =================================================================== --- tools/debugserver/source/MacOSX/MachThread.cpp +++ tools/debugserver/source/MacOSX/MachThread.cpp @@ -376,11 +376,11 @@ // This thread is sitting at a breakpoint, ask the breakpoint // if we should be stopping here. return true; - } else { - if (m_arch_ap->StepNotComplete()) { - step_more = true; - return false; - } + } + if (m_arch_ap->StepNotComplete()) { + step_more = true; + return false; + } // The thread state is used to let us know what the thread was // trying to do. MachThread::ThreadWillResume() will set the // thread state to various values depending if the thread was @@ -390,14 +390,13 @@ // If our state is running, then we should continue as we are in // the process of stepping over a breakpoint. return false; - } else { - // Stop if we have any kind of valid exception for this - // thread. - if (GetStopException().IsValid()) - return true; } - } - return false; + // Stop if we have any kind of valid exception for this + // thread. + if (GetStopException().IsValid()) + return true; + + return false; } bool MachThread::IsStepping() { return GetState() == eStateStepping; } Index: tools/debugserver/source/MacOSX/MachVMMemory.cpp =================================================================== --- tools/debugserver/source/MacOSX/MachVMMemory.cpp +++ tools/debugserver/source/MacOSX/MachVMMemory.cpp @@ -46,12 +46,12 @@ (int)vm_info.page_size); m_page_size = vm_info.page_size; return m_page_size; - } else { - DNBLogThreadedIf(LOG_TASK, "MachVMMemory::PageSize task_info call " - "failed to get page size, TASK_VM_INFO %d, " - "TASK_VM_INFO_COUNT %d, kern return %d", - TASK_VM_INFO, TASK_VM_INFO_COUNT, kr); } + DNBLogThreadedIf(LOG_TASK, + "MachVMMemory::PageSize task_info call " + "failed to get page size, TASK_VM_INFO %d, " + "TASK_VM_INFO_COUNT %d, kern return %d", + TASK_VM_INFO, TASK_VM_INFO_COUNT, kr); } #endif m_err = ::host_page_size(::mach_host_self(), &m_page_size); @@ -230,11 +230,11 @@ if (bytes_written <= 0) { // Status should have already be posted by WriteRegion... break; - } else { - total_bytes_written += bytes_written; - curr_addr += bytes_written; - curr_data += bytes_written; } + total_bytes_written += bytes_written; + curr_addr += bytes_written; + curr_data += bytes_written; + } else { DNBLogThreadedIf( LOG_MEMORY_PROTECTIONS, "Failed to set read/write protections on " Index: tools/debugserver/source/MacOSX/MachVMRegion.h =================================================================== --- tools/debugserver/source/MacOSX/MachVMRegion.h +++ tools/debugserver/source/MacOSX/MachVMRegion.h @@ -30,8 +30,8 @@ mach_vm_address_t BytesRemaining(mach_vm_address_t addr) const { if (ContainsAddress(addr)) return m_size - (addr - m_start); - else - return 0; + + return 0; } bool ContainsAddress(mach_vm_address_t addr) const { return addr >= StartAddress() && addr < EndAddress(); Index: tools/debugserver/source/MacOSX/MachVMRegion.cpp =================================================================== --- tools/debugserver/source/MacOSX/MachVMRegion.cpp +++ tools/debugserver/source/MacOSX/MachVMRegion.cpp @@ -58,23 +58,22 @@ __FUNCTION__, prot, m_task, (uint64_t)addr); // Protections are already set as requested... return true; - } else { - m_err = ::mach_vm_protect(m_task, addr, prot_size, 0, prot); - if (DNBLogCheckLogBit(LOG_MEMORY_PROTECTIONS)) + } + m_err = ::mach_vm_protect(m_task, addr, prot_size, 0, prot); + if (DNBLogCheckLogBit(LOG_MEMORY_PROTECTIONS)) + m_err.LogThreaded("::mach_vm_protect ( task = 0x%4.4x, addr = " + "0x%8.8llx, size = %llu, set_max = %i, prot = %u )", + m_task, (uint64_t)addr, (uint64_t)prot_size, 0, prot); + if (m_err.Fail()) { + // Try again with the ability to create a copy on write region + m_err = + ::mach_vm_protect(m_task, addr, prot_size, 0, prot | VM_PROT_COPY); + if (DNBLogCheckLogBit(LOG_MEMORY_PROTECTIONS) || m_err.Fail()) m_err.LogThreaded("::mach_vm_protect ( task = 0x%4.4x, addr = " - "0x%8.8llx, size = %llu, set_max = %i, prot = %u )", + "0x%8.8llx, size = %llu, set_max = %i, prot = %u " + ")", m_task, (uint64_t)addr, (uint64_t)prot_size, 0, - prot); - if (m_err.Fail()) { - // Try again with the ability to create a copy on write region - m_err = ::mach_vm_protect(m_task, addr, prot_size, 0, - prot | VM_PROT_COPY); - if (DNBLogCheckLogBit(LOG_MEMORY_PROTECTIONS) || m_err.Fail()) - m_err.LogThreaded("::mach_vm_protect ( task = 0x%4.4x, addr = " - "0x%8.8llx, size = %llu, set_max = %i, prot = %u " - ")", - m_task, (uint64_t)addr, (uint64_t)prot_size, 0, - prot | VM_PROT_COPY); + prot | VM_PROT_COPY); } if (m_err.Success()) { m_curr_protection = prot; @@ -82,7 +81,7 @@ m_protection_size = prot_size; return true; } - } + } else { DNBLogThreadedIf(LOG_MEMORY_PROTECTIONS | LOG_VERBOSE, "%s: Zero size for task 0x%4.4x at address 0x%8.8llx) ", Index: tools/debugserver/source/MacOSX/i386/DNBArchImplI386.cpp =================================================================== --- tools/debugserver/source/MacOSX/i386/DNBArchImplI386.cpp +++ tools/debugserver/source/MacOSX/i386/DNBArchImplI386.cpp @@ -547,12 +547,12 @@ if (DEBUG_FPU_REGS) { m_state.SetError(e_regSetFPU, Write, 0); return m_state.GetError(e_regSetFPU, Write); - } else { - int flavor = __i386_FLOAT_STATE; - mach_msg_type_number_t count = e_regSetWordSizeFPU; - if (CPUHasAVX512f() || FORCE_AVX_REGS) { - flavor = __i386_AVX512F_STATE; - count = e_regSetWordSizeAVX512f; + } + int flavor = __i386_FLOAT_STATE; + mach_msg_type_number_t count = e_regSetWordSizeFPU; + if (CPUHasAVX512f() || FORCE_AVX_REGS) { + flavor = __i386_AVX512F_STATE; + count = e_regSetWordSizeAVX512f; } else if (CPUHasAVX()) { flavor = __i386_AVX_STATE; @@ -564,7 +564,6 @@ (thread_state_t)&m_state.context.fpu, count)); return m_state.GetError(e_regSetFPU, Write); - } } kern_return_t DNBArchImplI386::SetEXCState() { @@ -891,8 +890,8 @@ if (kret == KERN_SUCCESS) return true; - else - return false; + + return false; } bool DNBArchImplI386::FinishTransForHWP() { m_2pc_trans_state = Trans_Done; @@ -949,9 +948,9 @@ if (kret == KERN_SUCCESS) return i; - else // Revert to the previous debug state voluntarily. The transaction - // coordinator knows that we have failed. - m_state.context.dbg = GetDBGCheckpoint(); + // Revert to the previous debug state voluntarily. The transaction + // coordinator knows that we have failed. + m_state.context.dbg = GetDBGCheckpoint(); } else { DNBLogThreadedIf(LOG_WATCHPOINTS, "DNBArchImplI386::" "EnableHardwareWatchpoint(): All " @@ -983,9 +982,9 @@ if (kret == KERN_SUCCESS) return true; - else // Revert to the previous debug state voluntarily. The transaction - // coordinator knows that we have failed. - m_state.context.dbg = GetDBGCheckpoint(); + // Revert to the previous debug state voluntarily. The transaction + // coordinator knows that we have failed. + m_state.context.dbg = GetDBGCheckpoint(); } } return false; @@ -1592,8 +1591,8 @@ return g_reg_sets_avx512f; if (CPUHasAVX()) return g_reg_sets_avx; - else - return g_reg_sets_no_avx; + + return g_reg_sets_no_avx; } void DNBArchImplI386::Initialize() { Index: tools/debugserver/source/MacOSX/x86_64/DNBArchImplX86_64.cpp =================================================================== --- tools/debugserver/source/MacOSX/x86_64/DNBArchImplX86_64.cpp +++ tools/debugserver/source/MacOSX/x86_64/DNBArchImplX86_64.cpp @@ -421,9 +421,10 @@ if (m_state.GetError(e_regSetFPU, Read) == KERN_SUCCESS) return m_state.GetError(e_regSetFPU, Read); - else - DNBLogThreadedIf(LOG_THREAD, - "::thread_get_state attempted fetch of avx512 fpu regctx failed, will try fetching avx"); + + DNBLogThreadedIf(LOG_THREAD, + "::thread_get_state attempted fetch of avx512 fpu " + "regctx failed, will try fetching avx"); } if (CPUHasAVX() || FORCE_AVX_REGS) { count = e_regSetWordSizeAVX; @@ -493,21 +494,22 @@ if (DEBUG_FPU_REGS) { m_state.SetError(e_regSetFPU, Write, 0); return m_state.GetError(e_regSetFPU, Write); - } else { - int flavor = __x86_64_FLOAT_STATE; - mach_msg_type_number_t count = e_regSetWordSizeFPU; - if (CPUHasAVX512f() || FORCE_AVX_REGS) { - count = e_regSetWordSizeAVX512f; - flavor = __x86_64_AVX512F_STATE; - m_state.SetError( - e_regSetFPU, Write, - ::thread_set_state(m_thread->MachPortNumber(), flavor, - (thread_state_t)&m_state.context.fpu, count)); - if (m_state.GetError(e_regSetFPU, Write) == KERN_SUCCESS) - return m_state.GetError(e_regSetFPU, Write); - else - DNBLogThreadedIf(LOG_THREAD, - "::thread_get_state attempted save of avx512 fpu regctx failed, will try saving avx regctx"); + } + int flavor = __x86_64_FLOAT_STATE; + mach_msg_type_number_t count = e_regSetWordSizeFPU; + if (CPUHasAVX512f() || FORCE_AVX_REGS) { + count = e_regSetWordSizeAVX512f; + flavor = __x86_64_AVX512F_STATE; + m_state.SetError(e_regSetFPU, Write, + ::thread_set_state(m_thread->MachPortNumber(), flavor, + (thread_state_t)&m_state.context.fpu, + count)); + if (m_state.GetError(e_regSetFPU, Write) == KERN_SUCCESS) + return m_state.GetError(e_regSetFPU, Write); + + DNBLogThreadedIf(LOG_THREAD, + "::thread_get_state attempted save of avx512 fpu regctx " + "failed, will try saving avx regctx"); } if (CPUHasAVX() || FORCE_AVX_REGS) { @@ -519,7 +521,6 @@ ::thread_set_state(m_thread->MachPortNumber(), flavor, (thread_state_t)&m_state.context.fpu, count)); return m_state.GetError(e_regSetFPU, Write); - } } kern_return_t DNBArchImplX86_64::SetEXCState() { @@ -846,8 +847,8 @@ if (kret == KERN_SUCCESS) return true; - else - return false; + + return false; } bool DNBArchImplX86_64::FinishTransForHWP() { m_2pc_trans_state = Trans_Done; @@ -904,9 +905,9 @@ if (kret == KERN_SUCCESS) return i; - else // Revert to the previous debug state voluntarily. The transaction - // coordinator knows that we have failed. - m_state.context.dbg = GetDBGCheckpoint(); + // Revert to the previous debug state voluntarily. The transaction + // coordinator knows that we have failed. + m_state.context.dbg = GetDBGCheckpoint(); } else { DNBLogThreadedIf(LOG_WATCHPOINTS, "DNBArchImplX86_64::" "EnableHardwareWatchpoint(): All " @@ -938,9 +939,9 @@ if (kret == KERN_SUCCESS) return true; - else // Revert to the previous debug state voluntarily. The transaction - // coordinator knows that we have failed. - m_state.context.dbg = GetDBGCheckpoint(); + // Revert to the previous debug state voluntarily. The transaction + // coordinator knows that we have failed. + m_state.context.dbg = GetDBGCheckpoint(); } } return false; @@ -2116,8 +2117,8 @@ return g_reg_sets_avx512f; if (CPUHasAVX() || FORCE_AVX_REGS) return g_reg_sets_avx; - else - return g_reg_sets_no_avx; + + return g_reg_sets_no_avx; } void DNBArchImplX86_64::Initialize() { Index: tools/debugserver/source/RNBContext.cpp =================================================================== --- tools/debugserver/source/RNBContext.cpp +++ tools/debugserver/source/RNBContext.cpp @@ -38,8 +38,8 @@ const char *RNBContext::EnvironmentAtIndex(size_t index) { if (index < m_env_vec.size()) return m_env_vec[index].c_str(); - else - return NULL; + + return NULL; } static std::string GetEnvironmentKey(const std::string &env) { @@ -64,8 +64,8 @@ const char *RNBContext::ArgumentAtIndex(size_t index) { if (index < m_arg_vec.size()) return m_arg_vec[index].c_str(); - else - return NULL; + + return NULL; } bool RNBContext::SetWorkingDirectory(const char *path) { Index: tools/debugserver/source/RNBRemote.cpp =================================================================== --- tools/debugserver/source/RNBRemote.cpp +++ tools/debugserver/source/RNBRemote.cpp @@ -140,8 +140,8 @@ int ch = decoded_hex_ascii_char(c); if (ch == -1) break; - else - arg.push_back(ch); + + arg.push_back(ch); } } return arg; @@ -1008,10 +1008,9 @@ payload.c_str()); HandlePacket_UNIMPLEMENTED(payload.c_str()); return rnb_err; - } else { - packet_info = *it; - packet_payload = payload; } + packet_info = *it; + packet_payload = payload; } return err; } @@ -1064,12 +1063,11 @@ if (type != NULL) *type = packet_info.type; return (this->*packet_callback)(packet_data.c_str()); - } else { - // Do not fall through to end of this function, if we have valid - // packet_info and it has a NULL callback, then we need to respect - // that it may not want any response or anything to be done. - return err; } + // Do not fall through to end of this function, if we have valid + // packet_info and it has a NULL callback, then we need to respect + // that it may not want any response or anything to be done. + return err; } return rnb_err; } @@ -1290,9 +1288,9 @@ #elif defined(__i386__) || defined(__x86_64__) if (sizeof(char *) == 8) { return CPU_TYPE_X86_64; - } else { - return CPU_TYPE_I386; } + return CPU_TYPE_I386; + #endif return 0; } @@ -1702,9 +1700,8 @@ ostrm << std::hex << th; } return SendPacket(ostrm.str()); - } else { - return SendPacket("l"); } + return SendPacket("l"); } rnb_err_t RNBRemote::HandlePacket_qThreadExtraInfo(const char *p) { @@ -1734,11 +1731,10 @@ const char *threadInfo = DNBThreadGetInfo(pid, tid); if (threadInfo != NULL && threadInfo[0]) { return SendHexEncodedBytePacket(NULL, threadInfo, strlen(threadInfo), NULL); - } else { - // "OK" == 4f6b - // Return "OK" as a ASCII hex byte stream if things go wrong - return SendPacket("4f6b"); } + // "OK" == 4f6b + // Return "OK" as a ASCII hex byte stream if things go wrong + return SendPacket("4f6b"); return SendPacket(""); } @@ -1822,7 +1818,8 @@ return SendPacket("OK"); } return SendPacket("E71"); - } else if (variable.compare("logmask") == 0) { + } + if (variable.compare("logmask") == 0) { char *end; errno = 0; uint32_t logmask = @@ -2299,8 +2296,8 @@ rnb_err_t result = set_logging(p); if (result == rnb_success) return SendPacket("OK"); - else - return SendPacket("E35"); + + return SendPacket("E35"); } rnb_err_t RNBRemote::HandlePacket_QSetDisableASLR(const char *p) { @@ -2368,7 +2365,8 @@ if (::stat(m_ctx.GetWorkingDirPath(), &working_dir_stat) == -1) { m_ctx.GetWorkingDir().clear(); return SendPacket("E61"); // Working directory doesn't exist... - } else if ((working_dir_stat.st_mode & S_IFMT) == S_IFDIR) { + } + if ((working_dir_stat.st_mode & S_IFMT) == S_IFDIR) { return SendPacket("OK"); } else { m_ctx.GetWorkingDir().clear(); @@ -2399,8 +2397,8 @@ } if (DNBProcessSyncThreadState(m_ctx.ProcessID(), tid)) return SendPacket("OK"); - else - return SendPacket("E61"); + + return SendPacket("E61"); } rnb_err_t RNBRemote::HandlePacket_QSetDetachOnError(const char *p) { @@ -2641,8 +2639,8 @@ if (Context().HasValidProcessID()) { if (DNBProcessSendEvent(Context().ProcessID(), p)) return SendPacket("OK"); - else - return SendPacket("E80"); + + return SendPacket("E80"); } else { Context().PushProcessEvent(p); } @@ -3064,8 +3062,8 @@ exit_packet << RAWHEX8(exit_info[i]); exit_packet << ';'; return SendPacket(exit_packet.str()); - } else - return SendPacket(pid_exited_packet); + } + return SendPacket(pid_exited_packet); } break; } return rnb_success; @@ -3140,8 +3138,8 @@ DNBProcessMemoryWrite(m_ctx.ProcessID(), addr, length, buf); if (wrote != length) return SendPacket("E09"); - else - return SendPacket("OK"); + + return SendPacket("OK"); } rnb_err_t RNBRemote::HandlePacket_m(const char *p) { @@ -3397,8 +3395,8 @@ DNBThreadSetRegisterContext(pid, tid, reg_ctx.data(), reg_ctx.size()); if (reg_ctx_size == reg_ctx.size()) return SendPacket("OK"); - else - return SendPacket("E55"); + + return SendPacket("E55"); } else { DNBLogError("RNBRemote::HandlePacket_G(%s): extracted %llu of %llu " "bytes, size mismatch\n", @@ -3415,8 +3413,8 @@ RNBRemote *remote = remoteSP.get(); if (remote->Comm().IsConnected()) return false; - else - return true; + + return true; } return true; } @@ -3521,9 +3519,9 @@ return HandlePacket_ILLFORMED( __FILE__, __LINE__, p, "No thread specified in QSaveRegisterState packet"); - else - return HandlePacket_ILLFORMED(__FILE__, __LINE__, p, - "No thread was is set with the Hg packet"); + + return HandlePacket_ILLFORMED(__FILE__, __LINE__, p, + "No thread was is set with the Hg packet"); } // Get the register context size first by calling with NULL buffer @@ -3532,9 +3530,8 @@ char response[64]; snprintf(response, sizeof(response), "%u", save_id); return SendPacket(response); - } else { - return SendPacket("E75"); } + return SendPacket("E75"); } // FORMAT: QRestoreRegisterState:SAVEID;thread:TTTT; (when thread suffix is // supported) @@ -3562,9 +3559,9 @@ return HandlePacket_ILLFORMED( __FILE__, __LINE__, p, "No thread specified in QSaveRegisterState packet"); - else - return HandlePacket_ILLFORMED(__FILE__, __LINE__, p, - "No thread was is set with the Hg packet"); + + return HandlePacket_ILLFORMED(__FILE__, __LINE__, p, + "No thread was is set with the Hg packet"); } StdStringExtractor packet(p); @@ -3576,8 +3573,8 @@ // Get the register context size first by calling with NULL buffer if (DNBThreadRestoreRegisterState(pid, tid, save_id)) return SendPacket("OK"); - else - return SendPacket("E77"); + + return SendPacket("E77"); } return SendPacket("E76"); } @@ -3662,7 +3659,8 @@ if (strcmp(p, "vCont;c") == 0) { // Simple continue return RNBRemote::HandlePacket_c("c"); - } else if (strcmp(p, "vCont;s") == 0) { + } + if (strcmp(p, "vCont;s") == 0) { // Simple step return RNBRemote::HandlePacket_s("s"); } else if (strstr(p, "vCont") == p) { @@ -3794,12 +3792,12 @@ // Send a stop reply packet to indicate we successfully attached! NotifyThatProcessStopped(); return rnb_success; - } else { - m_ctx.LaunchStatus().SetError(-1, DNBError::Generic); - if (err_str[0]) - m_ctx.LaunchStatus().SetErrorString(err_str); - else - m_ctx.LaunchStatus().SetErrorString("attach failed"); + } + m_ctx.LaunchStatus().SetError(-1, DNBError::Generic); + if (err_str[0]) + m_ctx.LaunchStatus().SetErrorString(err_str); + else + m_ctx.LaunchStatus().SetErrorString("attach failed"); #if defined(__APPLE__) && \ (__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ >= 101000) @@ -3841,7 +3839,6 @@ SendPacket("E01"); // E01 is our magic error value for attach failed. DNBLogError("Attach failed: \"%s\".", err_str); return rnb_err; - } } // All other failures come through here @@ -3925,10 +3922,10 @@ // a ref count structure with the breakID and add it to our // map. return SendPacket("OK"); - } else { - // We failed to set the software breakpoint - return SendPacket("E09"); } + // We failed to set the software breakpoint + return SendPacket("E09"); + } break; case '2': // set write watchpoint @@ -3946,10 +3943,10 @@ if (DNBWatchpointSet(pid, addr, byte_size, watch_flags, hardware)) { return SendPacket("OK"); - } else { - // We failed to set the watchpoint - return SendPacket("E09"); } + // We failed to set the watchpoint + return SendPacket("E09"); + } break; default: @@ -4242,9 +4239,8 @@ std::string data = DNBProcessGetProfileData(pid, scan_type); if (!data.empty()) { return SendPacket(data.c_str()); - } else { - return SendPacket("OK"); } + return SendPacket("OK"); } // QSetEnableAsyncProfiling;enable:[0|1]:interval_usec:XXXXXX;scan_type:0xYYYYYYY @@ -4311,7 +4307,8 @@ EnableCompressionNextSendPacket(compression_types::zlib_deflate); m_compression_minsize = new_compression_minsize; return SendPacket("OK"); - } else if (strstr(p, "type:lz4;") != nullptr) { + } + if (strstr(p, "type:lz4;") != nullptr) { EnableCompressionNextSendPacket(compression_types::lz4); m_compression_minsize = new_compression_minsize; return SendPacket("OK"); @@ -4346,7 +4343,7 @@ return HandlePacket_ILLFORMED( __FILE__, __LINE__, p, "Didn't find response_size value at right offset"); - else if (*end == ';') { + if (*end == ';') { static char g_data[4 * 1024 * 1024 + 16] = "data:"; memset(g_data + 5, 'a', response_size); g_data[response_size + 5] = '\0'; @@ -4402,7 +4399,7 @@ if (errno != 0) return HandlePacket_ILLFORMED(__FILE__, __LINE__, p, "Could not parse signal in C packet"); - else if (*end == ';') { + if (*end == ';') { errno = 0; action.addr = strtoull(end + 1, NULL, 16); if (errno != 0 && action.addr == 0) @@ -4516,7 +4513,7 @@ if (errno != 0) return HandlePacket_ILLFORMED(__FILE__, __LINE__, p, "Could not parse signal in S packet"); - else if (*end == ';') { + if (*end == ';') { errno = 0; action.addr = strtoull(end + 1, NULL, 16); if (errno != 0 && action.addr == 0) { @@ -5157,7 +5154,8 @@ if (strncmp(c, "true", 4) == 0) { value = true; return true; - } else if (strncmp(c, "false", 5) == 0) { + } + if (strncmp(c, "false", 5) == 0) { value = false; return true; } @@ -5738,9 +5736,8 @@ if (json_str.str().size() > 0) { std::string json_str_quoted = binary_encode_string(json_str.str()); return SendPacket(json_str_quoted.c_str()); - } else { - SendPacket("E84"); } + SendPacket("E84"); } } return SendPacket("OK"); @@ -5771,9 +5768,8 @@ if (json_str.str().size() > 0) { std::string json_str_quoted = binary_encode_string(json_str.str()); return SendPacket(json_str_quoted.c_str()); - } else { - SendPacket("E86"); } + SendPacket("E86"); } } return SendPacket("OK"); @@ -5971,13 +5967,12 @@ if (symbol_name.empty()) { // Done with symbol lookups return SendPacket("OK"); - } else { - std::ostringstream reply; - reply << "qSymbol:"; - for (size_t i = 0; i < symbol_name.size(); ++i) - reply << RAWHEX8(symbol_name[i]); - return SendPacket(reply.str().c_str()); } + std::ostringstream reply; + reply << "qSymbol:"; + for (size_t i = 0; i < symbol_name.size(); ++i) + reply << RAWHEX8(symbol_name[i]); + return SendPacket(reply.str().c_str()); } // Note that all numeric values returned by qProcessInfo are hex encoded, @@ -6238,8 +6233,8 @@ if (m_dispatch_queue_offsets.IsValid()) return &m_dispatch_queue_offsets; - else - return nullptr; + + return nullptr; } void RNBRemote::EnableCompressionNextSendPacket(compression_types type) { Index: tools/debugserver/source/RNBServices.cpp =================================================================== --- tools/debugserver/source/RNBServices.cpp +++ tools/debugserver/source/RNBServices.cpp @@ -222,10 +222,10 @@ if (bytes != NULL && size > 0) { plist.assign((const char *)bytes, size); return 0; // Success - } else { - DNBLogError("empty application property list."); - result = -2; } + DNBLogError("empty application property list."); + result = -2; + } else { DNBLogError("serializing task list."); result = -3; Index: tools/debugserver/source/RNBSocket.cpp =================================================================== --- tools/debugserver/source/RNBSocket.cpp +++ tools/debugserver/source/RNBSocket.cpp @@ -41,7 +41,8 @@ strcmp(hostname, "127.0.0.1") == 0) { addr = htonl(INADDR_LOOPBACK); return true; - } else if (strcmp(hostname, "*") == 0) { + } + if (strcmp(hostname, "*") == 0) { addr = htonl(INADDR_ANY); return true; } else { @@ -281,16 +282,16 @@ err.SetError(errno, DNBError::POSIX); err.LogThreaded("can't open file '%s'", path); return rnb_not_connected; - } else { - struct termios stdin_termios; + } + struct termios stdin_termios; - if (::tcgetattr(m_fd, &stdin_termios) == 0) { - stdin_termios.c_lflag &= ~ECHO; // Turn off echoing - stdin_termios.c_lflag &= ~ICANON; // Get one char at a time - ::tcsetattr(m_fd, TCSANOW, &stdin_termios); + if (::tcgetattr(m_fd, &stdin_termios) == 0) { + stdin_termios.c_lflag &= ~ECHO; // Turn off echoing + stdin_termios.c_lflag &= ~ICANON; // Get one char at a time + ::tcsetattr(m_fd, TCSANOW, &stdin_termios); } - } - return rnb_success; + + return rnb_success; } int RNBSocket::SetSocketOption(int fd, int level, int option_name, @@ -339,7 +340,8 @@ if (bytesread == 0) { m_fd = -1; return rnb_not_connected; - } else if (bytesread == -1) { + } + if (bytesread == -1) { m_fd = -1; return rnb_err; } Index: tools/debugserver/source/libdebugserver.cpp =================================================================== --- tools/debugserver/source/libdebugserver.cpp +++ tools/debugserver/source/libdebugserver.cpp @@ -93,16 +93,16 @@ if (type == RNBRemote::vattach || type == RNBRemote::vattachwait) { if (err == rnb_success) return eRNBRunLoopModeInferiorExecuting; - else { - RNBLogSTDERR("error: attach failed."); - return eRNBRunLoopModeExit; - } + + RNBLogSTDERR("error: attach failed."); + return eRNBRunLoopModeExit; } if (err == rnb_success) { DNBLogThreadedIf(LOG_RNB_MINIMAL, "%s Got success...", __FUNCTION__); continue; - } else if (err == rnb_not_connected) { + } + if (err == rnb_not_connected) { RNBLogSTDERR("error: connection lost."); return eRNBRunLoopModeExit; } else { Index: tools/lldb-mi/MICmdArgValFile.cpp =================================================================== --- tools/lldb-mi/MICmdArgValFile.cpp +++ tools/lldb-mi/MICmdArgValFile.cpp @@ -73,8 +73,8 @@ m_argValue = rFile.Trim('"'); vwArgContext.RemoveArg(rFile); return MIstatus::success; - } else - return MIstatus::failure; + } + return MIstatus::failure; } // In reality there are more than one option, if so the file option @@ -90,8 +90,8 @@ m_bValid = true; m_argValue = rTxt.Trim('"'); return MIstatus::success; - } else - return MIstatus::success; + } + return MIstatus::success; } // Next Index: tools/lldb-mi/MICmdArgValListOfN.cpp =================================================================== --- tools/lldb-mi/MICmdArgValListOfN.cpp +++ tools/lldb-mi/MICmdArgValListOfN.cpp @@ -83,8 +83,8 @@ m_bValid = true; vwArgContext.RemoveArg(rArg); return MIstatus::success; - } else - return MIstatus::failure; + } + return MIstatus::failure; } //++ Index: tools/lldb-mi/MICmdArgValNumber.cpp =================================================================== --- tools/lldb-mi/MICmdArgValNumber.cpp +++ tools/lldb-mi/MICmdArgValNumber.cpp @@ -78,8 +78,8 @@ m_argValue = GetNumber(); vwArgContext.RemoveArg(rArg); return MIstatus::success; - } else - return MIstatus::failure; + } + return MIstatus::failure; } // More than one option... @@ -94,8 +94,8 @@ m_bValid = true; m_argValue = GetNumber(); return MIstatus::success; - } else - return MIstatus::failure; + } + return MIstatus::failure; } // Next Index: tools/lldb-mi/MICmdArgValOptionLong.cpp =================================================================== --- tools/lldb-mi/MICmdArgValOptionLong.cpp +++ tools/lldb-mi/MICmdArgValOptionLong.cpp @@ -129,8 +129,8 @@ m_bIsMissingOptions = true; return MIstatus::failure; - } else - return MIstatus::failure; + } + return MIstatus::failure; } // More than one option... @@ -153,10 +153,9 @@ m_bIsMissingOptions = true; return MIstatus::failure; - } else { - m_bValid = true; - return MIstatus::success; } + m_bValid = true; + return MIstatus::success; } // Next Index: tools/lldb-mi/MICmdArgValString.cpp =================================================================== --- tools/lldb-mi/MICmdArgValString.cpp +++ tools/lldb-mi/MICmdArgValString.cpp @@ -169,8 +169,8 @@ m_bValid = true; m_argValue = rArg.StripSlashes(); return MIstatus::success; - } else - return MIstatus::failure; + } + return MIstatus::failure; } // Next Index: tools/lldb-mi/MICmdArgValThreadGrp.cpp =================================================================== --- tools/lldb-mi/MICmdArgValThreadGrp.cpp +++ tools/lldb-mi/MICmdArgValThreadGrp.cpp @@ -72,8 +72,8 @@ m_argValue = GetNumber(); vwArgContext.RemoveArg(rArg); return MIstatus::success; - } else - return MIstatus::failure; + } + return MIstatus::failure; } // More than one option... @@ -88,8 +88,8 @@ m_bValid = true; m_argValue = GetNumber(); return MIstatus::success; - } else - return MIstatus::failure; + } + return MIstatus::failure; } // Next Index: tools/lldb-mi/MICmdCmdData.cpp =================================================================== --- tools/lldb-mi/MICmdCmdData.cpp +++ tools/lldb-mi/MICmdCmdData.cpp @@ -615,7 +615,8 @@ if (error.Fail()) { SetError(error.GetCString()); return MIstatus::failure; - } else if (!addrExprValue.IsValid()) { + } + if (!addrExprValue.IsValid()) { SetError(CMIUtilString::Format(MIRSRC(IDS_CMD_ERR_EXPR_INVALID), rAddrExpr.c_str())); return MIstatus::failure; Index: tools/lldb-mi/MICmdCmdGdbShow.cpp =================================================================== --- tools/lldb-mi/MICmdCmdGdbShow.cpp +++ tools/lldb-mi/MICmdCmdGdbShow.cpp @@ -169,7 +169,8 @@ miValueResult); m_miResultRecord = miRecordResult; return MIstatus::success; - } else if (m_bGdbOptionFnSuccessful) { + } + if (m_bGdbOptionFnSuccessful) { // Ignore empty value (for fallback) const CMICmnMIResultRecord miRecordResult( m_cmdData.strMiCmdToken, CMICmnMIResultRecord::eResultClass_Done); Index: tools/lldb-mi/MICmnLLDBDebugSessionInfo.cpp =================================================================== --- tools/lldb-mi/MICmnLLDBDebugSessionInfo.cpp +++ tools/lldb-mi/MICmnLLDBDebugSessionInfo.cpp @@ -310,8 +310,8 @@ if (bYesAccessible) { vwrResolvedPath = strTestPath; return MIstatus::success; - } else - nFoldersBack++; + } + nFoldersBack++; } // No files exist in the union of working directory and debuginfo path Index: tools/lldb-mi/MICmnLLDBUtilSBValue.cpp =================================================================== --- tools/lldb-mi/MICmnLLDBUtilSBValue.cpp +++ tools/lldb-mi/MICmnLLDBUtilSBValue.cpp @@ -136,9 +136,10 @@ if (nChildren == 0) { vwrValue = GetValueSummary(!m_bHandleCharType && IsCharType(), kUnknownValue); return MIstatus::success; - } else if (IsPointerType()) { - vwrValue = - GetValueSummary(!m_bHandleCharType && IsPointeeCharType(), kUnknownValue); + } + if (IsPointerType()) { + vwrValue = GetValueSummary(!m_bHandleCharType && IsPointeeCharType(), + kUnknownValue); return MIstatus::success; } else if (IsArrayType()) { CMICmnLLDBDebugSessionInfo &rSessionInfo( @@ -152,7 +153,8 @@ IsFirstChildCharType()) { vwrValue = GetValueSummary(false); return MIstatus::success; - } else if (vbHandleArrayType) { + } + if (vbHandleArrayType) { vwrValue = CMIUtilString::Format("[%u]", nChildren); return MIstatus::success; } @@ -408,7 +410,7 @@ process.ReadMemory(addr, &ch, sizeof(ch), error); if (error.Fail() || nReadBytes != sizeof(ch)) return kUnknownValue; - else if (ch == 0) + if (ch == 0) break; result.append( CMIUtilString::ConvertToPrintableASCII(ch, true /* bEscapeQuotes */)); Index: tools/lldb-mi/MIDriverMgr.cpp =================================================================== --- tools/lldb-mi/MIDriverMgr.cpp +++ tools/lldb-mi/MIDriverMgr.cpp @@ -367,10 +367,9 @@ CMIUtilString CMIDriverMgr::DriverGetError() const { if (m_pDriverCurrent != nullptr) return m_pDriverCurrent->GetError(); - else { - const CMIUtilString errMsg(MIRSRC(IDS_DRIVER_ERR_CURRENT_NOT_SET)); - CMICmnStreamStdout::Instance().Write(errMsg, true); - } + + const CMIUtilString errMsg(MIRSRC(IDS_DRIVER_ERR_CURRENT_NOT_SET)); + CMICmnStreamStdout::Instance().Write(errMsg, true); return CMIUtilString(); } @@ -387,10 +386,9 @@ CMIUtilString CMIDriverMgr::DriverGetName() const { if (m_pDriverCurrent != nullptr) return m_pDriverCurrent->GetName(); - else { - const CMIUtilString errMsg(MIRSRC(IDS_DRIVER_ERR_CURRENT_NOT_SET)); - CMICmnStreamStdout::Instance().Write(errMsg, true); - } + + const CMIUtilString errMsg(MIRSRC(IDS_DRIVER_ERR_CURRENT_NOT_SET)); + CMICmnStreamStdout::Instance().Write(errMsg, true); return CMIUtilString(); } Index: tools/lldb-mi/MIUtilMapIdToVariant.h =================================================================== --- tools/lldb-mi/MIUtilMapIdToVariant.h +++ tools/lldb-mi/MIUtilMapIdToVariant.h @@ -122,10 +122,9 @@ vrwbFound = true; vrwData = *pDataObj; return MIstatus::success; - } else { - SetErrorDescription(MIRSRC(IDS_VARIANT_ERR_USED_BASECLASS)); - return MIstatus::failure; } + SetErrorDescription(MIRSRC(IDS_VARIANT_ERR_USED_BASECLASS)); + return MIstatus::failure; } return MIstatus::success; Index: tools/lldb-server/lldb-platform.cpp =================================================================== --- tools/lldb-server/lldb-platform.cpp +++ tools/lldb-server/lldb-platform.cpp @@ -324,12 +324,12 @@ // Parent will continue to listen for new connections. continue; - } else { - // Child process will handle the connection and exit. - g_server = 0; - // Listening socket is owned by parent process. - acceptor_up.release(); } + // Child process will handle the connection and exit. + g_server = 0; + // Listening socket is owned by parent process. + acceptor_up.release(); + } else { // If not running as a server, this process will not accept // connections while a connection is active. Index: unittests/Host/NativeProcessProtocolTest.cpp =================================================================== --- unittests/Host/NativeProcessProtocolTest.cpp +++ unittests/Host/NativeProcessProtocolTest.cpp @@ -52,8 +52,8 @@ bool Hardware) override { if (Hardware) return SetHardwareBreakpoint(Addr, Size); - else - return SetSoftwareBreakpoint(Addr, Size); + + return SetSoftwareBreakpoint(Addr, Size); } // Redirect base class Read/Write Memory methods to functions whose signatures