[cfe-dev] How to get the corresponding MemRegion with a MemberExpr or an ArraySubscriptExpr?

Arthur Yoo phjy007 at gmail.com
Wed Mar 5 05:08:25 PST 2014


Hi all,


I want to get the corresponding MemRegion with a MemberExpr or an
ArraySubscriptExpr.


For an example:

*int arr[10][10][10];*

*arr[3][3][3] = 8;*

*arr[2][3][4] = arr[3][3][3];*

When evaluating the statement '*arr[2][3][4] = arr[3][3][3]*', I want to
get the two MemRegion which represent *arr[2][3][4] *and*
arr[2][3][4]*respectively. Since  '*arr[2][3][4]
= arr[3][3][3]*' is essentially an assign operator '=' rooted
BinaryOperator Expr, I can get its LHS and RHS easily. The LHS is a
ArraySubscriptExpr that represents the *arr[2][3][4]. *Although the RHS is
an ImpicitCastExpr (<LValueToRValue>), I can easily get its sub-Expr, which
is also an ArraySubscriptExpr representing the *arr[3][3][3]. *However,
what I really want to get are the MemRegions (ElementRegions) that
representing *arr[2][3][4] *and* arr[3][3][3] *respectively. Is there any
way to get the MemRegions (ElementRegions) through these
ArraySubscriptExprs?



As for MemberExpr, here is another example:

*typedef struct {*

*           int a, b;*

*} Obj;*

*Obj o;*

*o.a = 9;*

*o.b = o.a*;

When evaluating the statement '*o.b = o.a*', I want to get the two
MemRegion which represent *o.b *and* o.b* respectively. Quite similarly
with the example above, I can get the two MemberExprs representing *o.b *and*
o.b. *What I want to know is that, is there any way to get the MemRegions
(FieldRegions) through these MemberExprs? My structure here is quite
simple. In fact, the structure can be nested with tow or more hierarchies.
So it means the MemberExpr can also be nested.



Any help would be greatly appreciated. Thanks a lot.

-- 
Best regards,
Arthur Yoo
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20140305/742fd496/attachment.html>


More information about the cfe-dev mailing list