[lldb] NFC: refactor CompileUnit::ResolveSymbolContext

Summary:
I found the above named method hard to read because it had

a) many nested blocks and
b) one return statement at the end with some logic involved.

I decided to refactor this function by employing an early exit strategy.
In order to capture the logic in the return statement and to not have it
repeated more than once I chose to implement a very small lamda function
that captures all the variables it needs.

This is a non-functional change (NFC).

Reviewers: jdoerfert

Subscribers: lldb-commits

Tags: #lldb

Differential Revision: https://reviews.llvm.org/D70774
This commit is contained in:
Konrad Kleine
2019-11-27 10:57:06 +01:00
parent 3c3aca245e
commit 373e2a4f69
4 changed files with 71 additions and 90 deletions

View File

@@ -914,9 +914,10 @@ SBError SBThread::StepOverUntil(lldb::SBFrame &sb_frame,
const bool exact = false;
SymbolContextList sc_list;
const uint32_t num_matches = frame_sc.comp_unit->ResolveSymbolContext(
step_file_spec, line, check_inlines, exact, eSymbolContextLineEntry,
sc_list);
frame_sc.comp_unit->ResolveSymbolContext(step_file_spec, line,
check_inlines, exact,
eSymbolContextLineEntry, sc_list);
const uint32_t num_matches = sc_list.GetSize();
if (num_matches > 0) {
SymbolContext sc;
for (uint32_t i = 0; i < num_matches; ++i) {