<div dir="ltr">
















<p class="MsoNormal" style="line-height:14pt">Hi
Jordan, </p>

<p class="MsoNormal" style="line-height:14pt">Actually,
I am using the Clang Static Analyzer to do some platform-dependent detection
work by developing a checker. The Static Analyzer and my checker are running on
an X86-64bit/Linux platform. I’ve set two platform specifications in my checker.
So during the evaluation, it can do some platform-dependent detection work by
calculation. As a part of my design, given a MemRegion, I need to get its ‘Top
Region’ and then to calculate the offset between them. For example:</p>

<p class="MsoNormal" style="line-height:14pt">……</p>

<p class="MsoNormal" style="line-height:14pt">int
a = sizeof(long), arr[10][10];</p>

<p class="MsoNormal" style="line-height:14pt">arr[a][3]
= 8;</p>

<p class="MsoNormal" style="line-height:14pt">……</p>

<p class="MsoNormal" style="line-height:14pt">For ‘arr[a][3]’,
its MemRegion can be represented as ‘&element{element{arr,8 S32b,int
[10]},3 S32b,int}’ on an X86-64bit machine. And its Top Region is ‘&arr’.
Now I want to calculate the offset as if the code was running on an X86-32bit
machine. So ‘&arr[a][3]’ should be ‘&element{element{arr,4 S32b,int
[10]},3 S32b,int}’ on that platform, rather than ‘&element{element{arr,8
S32b,int [10]},3 S32b,int}’. In this way, I need to know the SVal for ‘variable
a’. </p>

<p class="MsoNormal" style="line-height:14pt"> </p>

<p class="MsoNormal" style="line-height:14pt">Another
related problem in my previous mail post (<a href="http://lists.cs.uiuc.edu/pipermail/cfe-dev/2014-April/036205.html">http://lists.cs.uiuc.edu/pipermail/cfe-dev/2014-April/036205.html</a>)
is for pointers. For example:</p>

<p class="MsoNormal" style="line-height:14pt">0 /*
example 2 */</p>

<p class="MsoNormal" style="line-height:14pt">1
struct st0 {</p>

<p class="MsoNormal" style="line-height:14pt">2     int i;</p>

<p class="MsoNormal" style="line-height:14pt">3 };</p>

<p class="MsoNormal" style="line-height:14pt">4
struct st1 {</p>

<p class="MsoNormal" style="line-height:14pt">5    int i;</p>

<p class="MsoNormal" style="line-height:14pt">6    struct st0 struct0;</p>

<p class="MsoNormal" style="line-height:14pt">7};</p>

<p class="MsoNormal" style="line-height:14pt">8struct
st2 {</p>

<p class="MsoNormal" style="line-height:14pt">9    struct st1 *p;</p>

<p class="MsoNormal" style="line-height:14pt">10
};</p>

<p class="MsoNormal" style="line-height:14pt">11
int main() {</p>

<p class="MsoNormal" style="line-height:14pt">12    struct st1 s1;</p>

<p class="MsoNormal" style="line-height:14pt">13    struct st2 s2;</p>

<p class="MsoNormal" style="line-height:14pt">14    s2.p = &s1;</p>

<p class="MsoNormal" style="line-height:14pt">15    s2.p->struct0.i = 3;</p>

<p class="MsoNormal" style="line-height:14pt">16 }</p>

<p class="MsoNormal" style="line-height:14pt">In
fact, the ‘s2.p->struct0.i’ in line 15 should be ‘&s1-> struct0.i’. I
want to get the Top Region (&s1) and calculate the offsets between ‘&field_i’
and its Top MemRegion for different platforms. So I tried to use
getSuperRegion() repeatedly to get the Top Region starting from the Button MemRegion
‘&field_i’. However, there is a pointer reference along this path.
Consequently, if I only use getSuperRegion() all the way, the Top Region will
be MemRegion ‘&s2’. Obviously, it isn’t the right Top Region I want. And
the right Top Region should be ‘&s1’. So during the upward tracking, if the
current MemRegion is a pointer MemRegion, then its pointee MemRegion (the
MemRegion which is referred by the pointer) should be achieved. Then I tried to
get the pointee MemRegion referred by ‘&s2.p’ via Store (StoreManager.getBinding()).
But I got an Undefined SVal. However, the expected SVal should be a
MemRegionVal wrapping MemRegion ‘&s1’. So how can I get the pointee
MemRegion in such situation? </p>

<p class="MsoNormal" style="line-height:14pt">I've been trapped in these problems for weeks. Any help would be greatly appreciated.</p><p class="MsoNormal" style="line-height:14pt">Thanks
a lot.</p>

</div><div class="gmail_extra"><br><br><div class="gmail_quote">2014-05-08 12:05 GMT+08:00 Jordan Rose <span dir="ltr"><<a href="mailto:jordan_rose@apple.com" target="_blank">jordan_rose@apple.com</a>></span>:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div style="word-wrap:break-word"><div>Hi, Arthur. I don't understand what you mean about the MemRegion for 'a'. 'a' is an integer variable, and when it's used in line 5 (not 3) you'll just get its value back, which will be 2. The expression "arr[a][1]" should give you an ElementRegion for "&arr[2][1]", but at that point 'a' isn't involved any more. Once a value is loaded from a variable (by an LValueToRValue implicit conversion), the variable isn't really interesting anymore. What are you actually trying to do?</div>
<div><br></div><div>Jordan</div><br><div><div><div class="h5"><div>On May 7, 2014, at 5:09 , Arthur Yoo <<a href="mailto:phjy007@gmail.com" target="_blank">phjy007@gmail.com</a>> wrote:</div><br></div></div><blockquote type="cite">
<div><div class="h5"><div dir="ltr"><p class="MsoNormal">Hi all,</p><p class="MsoNormal">I want to get the MemRegion representing an index of an
array in my checker. For example:</p><p class="MsoNormal">1 void func() {</p><p class="MsoNormal">2     int a, b,
arr[10][10];</p><p class="MsoNormal">3     a = 2;</p><p class="MsoNormal">4     b = 3;</p><p class="MsoNormal">3    arr[a][1] = 3;</p><p class="MsoNormal">4 }</p><div> <br></div><p class="MsoNormal">In the CheckLocation() method for checking the store
operation at line 3 ‘<i>arr[a][1] = 3;</i>’,
I want to get the MemRegion and SVal of variable <i>a</i>, which is the index of the array. Is there any way to get the
corresponding MemRegion and SVal of variable <i>a. </i></p><p class="MsoNormal">My previous mail post on a related problem is <a href="http://lists.cs.uiuc.edu/pipermail/cfe-dev/2014-April/036205.html" target="_blank">http://lists.cs.uiuc.edu/pipermail/cfe-dev/2014-April/036205.html</a>.
Unfortunately, there was no reply or solution. In fact, this problem has
trapped me for several weeks. So I really need help.</p><p class="MsoNormal">Any help would be greatly appreciated.</p>

<div><br></div>-- <br><div dir="ltr"><font color="#444444">Best regards,</font><div><font color="#444444">Arthur Yoo</font></div></div>
</div></div></div>
_______________________________________________<br>cfe-dev mailing list<br><a href="mailto:cfe-dev@cs.uiuc.edu" target="_blank">cfe-dev@cs.uiuc.edu</a><br><a href="http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev</a><br>
</blockquote></div><br></div></blockquote></div><br><br clear="all"><div><br></div>-- <br><div dir="ltr"><font color="#444444">Best regards,</font><div><font color="#444444">岳佳圆 | Yue Jiayuan | Arthur Yoo</font></div></div>

</div>