[Lldb-commits] [PATCH] D58792: Add "operator bool" to SB APIs

Pavel Labath via Phabricator via lldb-commits lldb-commits at lists.llvm.org
Sat Mar 2 12:37:06 PST 2019

labath added a comment.

In D58792#1415631 <https://reviews.llvm.org/D58792#1415631>, @clayborg wrote:

> If this is new API I guess it is ok to have them all be const. I was mostly worried that you wouldn't be able to call a non const function from a const function. Do we have any IsValid() calls that are const? I believe we do. If so, how are we calling IsValid() if it is const from a non const conversion operator?

The easiest way to fix that is to invert the calling direction. We can make the "operator bool" (which I guess we have agreed we want to be const?) contain the "canonical" implementation of the validity check, and then have the IsValid function (const or non-const) call into that. Since the bool operator will always be const, this will work regardless of whether the IsValid operation is declared to be const or not. If we then wanted to, we could make the "IsValid" function deprecated and remove it in the hypothetical v2 API.

That latest version of the patch implements that idea (the first part of it, the APIv2 thingy is just an idea).



More information about the lldb-commits mailing list