[Lldb-commits] [PATCH] D148863: Make sure SelectMostRelevantFrame happens only when returning to the user

Jim Ingham via Phabricator via lldb-commits lldb-commits at lists.llvm.org
Fri Apr 21 10:00:20 PDT 2023


jingham added a comment.

In D148863#4285797 <https://reviews.llvm.org/D148863#4285797>, @JDevlieghere wrote:

> I looked at all the call sites and they all seemed reasonable in terms of doing work on behalf of the user or not and selecting the most relevant frame respectively. My only concern is that we now have a bunch of places where we're passing a blind `true` or `false`. While it's pretty obvious in this patch, it won't be so obvious when you're reading the same code in the future, let alone when someone inevitably copy-pastes it. I can think of two easy ways to improve readability:
>
> 1. Add an inline comment:
>
>   StackFrameSP frame_sp = GetSelectedFrame(/*select_most_relevant=*/false);
>
>
>
> 2. Add an enum to `Frame`:
>
>   enum SelectMostRelevant : bool {
>     SelectMostRelevantFrame = true,
>     DoNoSelectMostRelevantFrame = false,
>   };
>
>
>
>   StackFrameSP frame_sp = GetSelectedFrame(SelectMostRelevantFrame);
>
> This is a trick that @dexonsmith thought me a long time ago. I personally like it the best because it makes things very explicit without the hassle of having to actually treat the value like an enum.

Oh, that's cute, I'll try that.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D148863/new/

https://reviews.llvm.org/D148863



More information about the lldb-commits mailing list