Author: Jonas Devlieghere Date: 2021-04-06T10:07:22-07:00 New Revision: 801cea2ce9515cc6b6c9b59dfac6e48074737da1
URL: https://github.com/llvm/llvm-project/commit/801cea2ce9515cc6b6c9b59dfac6e48074737da1 DIFF: https://github.com/llvm/llvm-project/commit/801cea2ce9515cc6b6c9b59dfac6e48074737da1.diff LOG: [lldb] Fix else-after-return in AppleObjCRuntimeV2 (NFC) Use early returns to associate the error message with the corresponding condition and eliminate some else-after-returns in the process. Added: Modified: lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp Removed: ################################################################################ diff --git a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp index debdfeaf909a7..752162109468f 100644 --- a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp +++ b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp @@ -454,30 +454,33 @@ ExtractRuntimeGlobalSymbol(Process *process, ConstString name, error.SetErrorString("no process"); return default_value; } + if (!module_sp) { error.SetErrorString("no module"); return default_value; } + if (!byte_size) byte_size = process->GetAddressByteSize(); const Symbol *symbol = module_sp->FindFirstSymbolWithNameAndType(name, lldb::eSymbolTypeData); - if (symbol && symbol->ValueIsAddress()) { - lldb::addr_t symbol_load_addr = - symbol->GetAddressRef().GetLoadAddress(&process->GetTarget()); - if (symbol_load_addr != LLDB_INVALID_ADDRESS) { - if (read_value) - return process->ReadUnsignedIntegerFromMemory( - symbol_load_addr, byte_size, default_value, error); - return symbol_load_addr; - } else { - error.SetErrorString("symbol address invalid"); - return default_value; - } - } else { + + if (!symbol || !symbol->ValueIsAddress()) { error.SetErrorString("no symbol"); return default_value; } + + lldb::addr_t symbol_load_addr = + symbol->GetAddressRef().GetLoadAddress(&process->GetTarget()); + if (symbol_load_addr == LLDB_INVALID_ADDRESS) { + error.SetErrorString("symbol address invalid"); + return default_value; + } + + if (read_value) + return process->ReadUnsignedIntegerFromMemory(symbol_load_addr, byte_size, + default_value, error); + return symbol_load_addr; } static void RegisterObjCExceptionRecognizer(Process *process); @@ -571,8 +574,8 @@ LanguageRuntime *AppleObjCRuntimeV2::CreateInstance(Process *process, ObjCRuntimeVersions::eAppleObjC_V2) return new AppleObjCRuntimeV2(process, objc_module_sp); return nullptr; - } else - return nullptr; + } + return nullptr; } static constexpr OptionDefinition g_objc_classtable_dump_options[] = { _______________________________________________ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits