Skip to content

Commit 3e1d574

Browse files
committed
[lldb][Expression][NFC] Make LoadAddressResolver::m_target a reference (llvm#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. (cherry picked from commit 03b7766)
1 parent 6cf2732 commit 3e1d574

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
@@ -742,7 +742,7 @@ void IRExecutionUnit::CollectCandidateCPlusPlusNames(
742742

743743
class LoadAddressResolver {
744744
public:
745-
LoadAddressResolver(Target *target, bool &symbol_was_missing_weak)
745+
LoadAddressResolver(Target &target, bool &symbol_was_missing_weak)
746746
: m_target(target), m_symbol_was_missing_weak(symbol_was_missing_weak) {}
747747

748748
std::optional<lldb::addr_t> Resolve(SymbolContextList &sc_list) {
@@ -764,20 +764,20 @@ class LoadAddressResolver {
764764

765765
// First try the symbol.
766766
if (candidate_sc.symbol) {
767-
load_address = candidate_sc.symbol->ResolveCallableAddress(*m_target);
767+
load_address = candidate_sc.symbol->ResolveCallableAddress(m_target);
768768
if (load_address == LLDB_INVALID_ADDRESS) {
769769
Address addr = candidate_sc.symbol->GetAddress();
770-
load_address = m_target->GetProcessSP()
771-
? addr.GetLoadAddress(m_target)
770+
load_address = m_target.GetProcessSP()
771+
? addr.GetLoadAddress(&m_target)
772772
: addr.GetFileAddress();
773773
}
774774
}
775775

776776
// If that didn't work, try the function.
777777
if (load_address == LLDB_INVALID_ADDRESS && candidate_sc.function) {
778778
Address addr = candidate_sc.function->GetAddress();
779-
load_address = m_target->GetProcessSP() ? addr.GetLoadAddress(m_target)
780-
: addr.GetFileAddress();
779+
load_address = m_target.GetProcessSP() ? addr.GetLoadAddress(&m_target)
780+
: addr.GetFileAddress();
781781
}
782782

783783
// We found a load address.
@@ -808,7 +808,7 @@ class LoadAddressResolver {
808808
}
809809

810810
private:
811-
Target *m_target;
811+
Target &m_target;
812812
bool &m_symbol_was_missing_weak;
813813
lldb::addr_t m_best_internal_load_address = LLDB_INVALID_ADDRESS;
814814
};
@@ -866,7 +866,7 @@ IRExecutionUnit::FindInSymbols(const std::vector<ConstString> &names,
866866
for (size_t i = 0; i < m_preferred_modules.GetSize(); ++i)
867867
non_local_images.Remove(m_preferred_modules.GetModuleAtIndex(i));
868868

869-
LoadAddressResolver resolver(target, symbol_was_missing_weak);
869+
LoadAddressResolver resolver(*target, symbol_was_missing_weak);
870870

871871
ModuleFunctionSearchOptions function_options;
872872
function_options.include_symbols = true;

0 commit comments

Comments
 (0)