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

Zhongxing Xu xuzhongxing at gmail.com
Thu Oct 9 06:45:29 PDT 2008


This patch introduces VisitLValue() to evaluate the lvalue of an expression.
VisitLValue()
is different from VisitLVal(). The motivation of this patch is as follows.

We have two kinds of RVal: LVal and NonLVal. LVal represents location value,
NonLVal represents non-location value.

Expressions have two kinds of value: rvalue and lvalue. The rvalue of an
expression is is the normal value it evaluates to when placed at the RHS of
an
assignment. The lvalue of an expression is the address of the memory object
it
represents.

We should distinguish rvalue/lvalue from NonLVal/LVal. An expression's
lvalue
must be a LVal. An expression's rvalue can be either NonLVal or LVal. Every
expressoin has its rvalue. But not all of the expressions have lvalues. For
example:

int x = 3;

"3" has rvalue 3, but no lvalue
"x" has rvalue 3, lvalue is its associated memregion MemRegionVal
"&x" has no lvalue, but has rvalue, which is the lvalue of 'x', i.e.
MemRegionVal of x

So I suggest when we evaluate expressions, we pass on an argument indicating
whether we want to get its lvalue/rvalue, instead of specifying we are
getting a
LVal or NonLVal.

In this patch, I use LValue/RValue to distinguish from LVal/NonLVal.

This patch cleans up a bunch of code. It lets store manager to evaluate the
lvalue
of an expression.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20081009/9b44ea9c/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: lvalue.patch
Type: application/octet-stream
Size: 21357 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20081009/9b44ea9c/attachment.obj>


More information about the cfe-commits mailing list