forked from OSchip/llvm-project
[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.
This commit is contained in:
parent
4059c1c32d
commit
801cea2ce9
|
@ -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,7 +574,7 @@ LanguageRuntime *AppleObjCRuntimeV2::CreateInstance(Process *process,
|
|||
ObjCRuntimeVersions::eAppleObjC_V2)
|
||||
return new AppleObjCRuntimeV2(process, objc_module_sp);
|
||||
return nullptr;
|
||||
} else
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue