[Lldb-commits] [PATCH] D81471: [lldb] Add support for using integral const static data members in the expression evaluator

Pavel Labath via Phabricator via lldb-commits lldb-commits at lists.llvm.org
Mon Jul 11 01:52:26 PDT 2022


labath added a comment.

In D81471#3637057 <https://reviews.llvm.org/D81471#3637057>, @werat wrote:

> In D81471#3632297 <https://reviews.llvm.org/D81471#3632297>, @labath wrote:
>
>> I guess the condition we really want to express here is "does this expression refer to a constexpr variable (ideally one without a location)"? And the problem is that clang does not give us the means to detect that?
>>
>> Is that really the case? Would it maybe be possible to use some c++ magic to get clang to do that for us. Write something like `if constexpr (__builtin_constant_p(user_expression)) do_something_rvalue_like(); else assume_regular_lvalue();` ?
>
> I think you're right here, but I don't know a better way to express this. My clangfu is not good enough for this yet :)
>
> As I understand it, we can't express it purely in the expression (via `__builtin_constant_p` or something), because we need to know the answer before executing the expression (it changes the way we do materialization/dematerialization).

Well, yes, either that, or change how the dematerialization works -- prepare for both options and then choose the one that was actually used.

> Could this be something to improve in the future?

Well.. maybe... I don't know. I think this is definitely useful, and I don't see much of a downside. The main difference I see is that you won't be able to "modify a constant" via expressions like `p const_int`, `p (int&)$0 = 47`, but: a) you will still be able to do that within a single expression; and b) such an operation is unlikely to produce predictable results in anything but pure C (which doesn't really have constants).

So, if noone objects to this, then I think it's fine.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D81471



More information about the lldb-commits mailing list