[cfe-commits] [PATCH] Expressions have lvalues and rvalues

Zhongxing Xu xuzhongxing at gmail.com
Fri Oct 10 04:07:50 PDT 2008


On Fri, Oct 10, 2008 at 4:52 PM, wasti <sebastian.redl at getdesigned.at>wrote:

>
> On Thu, 9 Oct 2008 22:21:47 -0700, Chris Lattner <clattner at apple.com>
> wrote:
> > On Oct 9, 2008, at 8:07 AM, Sebastian Redl wrote:
> >
> >> Zhongxing Xu wrote:
> >>> We have two kinds of RVal: LVal and NonLVal. LVal represents location
> >>> value,
> >>> NonLVal represents non-location value.
> >> All other considerations aside, this terminology is a spawn of the
> >> deepest hell and must be eradicated. Rvalue/lvalue considerations are
> >> complicated enough without messing them up this way.
> >
> > Sebastian, please be civil here - we attempt to maintain a positive
> > and helpful community.  What are you getting at? What do you suggest?
>
> I'm sorry. But I've always learned that rvalues and lvalues are strictly
> opposed. The statement above thus is illogical - rvals cannot be lvals or
> non-lvals. Non-lvals *are* rvals. Values can be lvalues or rvalues.
> Anything else is opposed to the terminology the C++ standard (at least)
> uses and can only bring chaotic confusion. In a few months, nobody will be
> able to understand the code in question anymore.
>
> In fact, something I've noticed in the code of Clang is that rvalues and
> lvalues are not seen as strictly distinct, probably because this
> distinction is not that important in C. In C++, with references and (in
> C++0x) rvalue vs lvalue references, with complicated rules about which
> temporaries can be elided that also partially depend on rvalue vs lvalue
> issues, this distinction feels very important to me. In writing code (and
> thinking about code to write) for validation of the C++ cast operators, I
> have felt the lack of a clear distinction as something that made my code
> harder to understand.
>
> I will look at the code to give some concrete suggestions as soon as I can.
> However, I just started a new job, and my life is somewhat hectic at the
> moment.
>
In static analysis, when an expression is on the LHS of an assignment
statement, we want to get the storage location it represents, I call it
lvalue of the expression. When an expression is on the RHS of an assignment
statement, we want to get its value in the normal sense, I call it the
rvalue of the expression. If such terminology should cause confusion, I am
OK to change the terminology.

Talking about the abstract values occuring in the static analysis, we divide
them into two categories: LVal and NonLVal. LVal represents some kind of
abstract location value, that is some address. NonLVal represent
non-location value.

So an expression's lvalue must be LVal, while its rvalue might be either
LVal or NonLVal.

The terminologies used here are not intended to be strictly consistent with
the C/C++ standard. Because we are not doing codegen, but doing static
analysis - symbolically simulating the execution of the program.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20081010/f0311fc3/attachment.html>


More information about the cfe-commits mailing list