Skip to content

Commit 03b7766

Browse files
authored
[lldb][Expression][NFC] Make LoadAddressResolver::m_target a reference (#149490)
The only place that passes a target to `LoadAddressResolver` already checks for pointer validity. And inside of the resolver we have been dereferencing the target anyway without nullptr checks. So codify the non-nullness of `m_target` by making it a reference.
1 parent 311847b commit 03b7766

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

lldb/source/Expression/IRExecutionUnit.cpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -700,7 +700,7 @@ void IRExecutionUnit::CollectCandidateCPlusPlusNames(
700700

701701
class LoadAddressResolver {
702702
public:
703-
LoadAddressResolver(Target *target, bool &symbol_was_missing_weak)
703+
LoadAddressResolver(Target &target, bool &symbol_was_missing_weak)
704704
: m_target(target), m_symbol_was_missing_weak(symbol_was_missing_weak) {}
705705

706706
std::optional<lldb::addr_t> Resolve(SymbolContextList &sc_list) {
@@ -722,20 +722,20 @@ class LoadAddressResolver {
722722

723723
// First try the symbol.
724724
if (candidate_sc.symbol) {
725-
load_address = candidate_sc.symbol->ResolveCallableAddress(*m_target);
725+
load_address = candidate_sc.symbol->ResolveCallableAddress(m_target);
726726
if (load_address == LLDB_INVALID_ADDRESS) {
727727
Address addr = candidate_sc.symbol->GetAddress();
728-
load_address = m_target->GetProcessSP()
729-
? addr.GetLoadAddress(m_target)
728+
load_address = m_target.GetProcessSP()
729+
? addr.GetLoadAddress(&m_target)
730730
: addr.GetFileAddress();
731731
}
732732
}
733733

734734
// If that didn't work, try the function.
735735
if (load_address == LLDB_INVALID_ADDRESS && candidate_sc.function) {
736736
Address addr = candidate_sc.function->GetAddress();
737-
load_address = m_target->GetProcessSP() ? addr.GetLoadAddress(m_target)
738-
: addr.GetFileAddress();
737+
load_address = m_target.GetProcessSP() ? addr.GetLoadAddress(&m_target)
738+
: addr.GetFileAddress();
739739
}
740740

741741
// We found a load address.
@@ -766,7 +766,7 @@ class LoadAddressResolver {
766766
}
767767

768768
private:
769-
Target *m_target;
769+
Target &m_target;
770770
bool &m_symbol_was_missing_weak;
771771
lldb::addr_t m_best_internal_load_address = LLDB_INVALID_ADDRESS;
772772
};
@@ -790,7 +790,7 @@ IRExecutionUnit::FindInSymbols(const std::vector<ConstString> &names,
790790
for (size_t i = 0; i < m_preferred_modules.GetSize(); ++i)
791791
non_local_images.Remove(m_preferred_modules.GetModuleAtIndex(i));
792792

793-
LoadAddressResolver resolver(target, symbol_was_missing_weak);
793+
LoadAddressResolver resolver(*target, symbol_was_missing_weak);
794794

795795
ModuleFunctionSearchOptions function_options;
796796
function_options.include_symbols = true;

0 commit comments

Comments
 (0)