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

_______________________________________________
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits

Reply via email to