[lldb] NFC: refactor CompileUnit::ResolveSymbolContext
authorKonrad Kleine <kkleine@redhat.com>
Thu, 28 Nov 2019 15:54:15 +0000 (16:54 +0100)
committerKonrad Kleine <kkleine@redhat.com>
Thu, 28 Nov 2019 20:37:31 +0000 (21:37 +0100)
commitc671639af6a96c31d3c0e5487051bef28bad1640
treea9bfbff7b14d2ec0d8c9189533e57c94a7c0d6c9
parentbdad3ec75ab35ade2433b1278689d483dcf9abc4
[lldb] NFC: refactor CompileUnit::ResolveSymbolContext

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

a) many nested blocks,
b) one return statement at the end with some logic involved,
c) a duplicated while-loop with just small differences in it.

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.
I also replaced the two while-loops with just one.

This is a non-functional change (NFC).

Reviewers: jdoerfert, teemperor

Reviewed By: teemperor

Subscribers: labath, teemperor, lldb-commits

Tags: #lldb

Differential Revision: https://reviews.llvm.org/D70774
lldb/include/lldb/Symbol/CompileUnit.h
lldb/source/API/SBThread.cpp
lldb/source/Core/AddressResolverFileLine.cpp
lldb/source/Symbol/CompileUnit.cpp