<div dir="ltr">
<p class="MsoNormal" style="line-height:16pt">Hi
all,</p>
<p class="MsoNormal" style="line-height:16pt">It
seems that I was confused by the Static Analyzer’s bindings. Here are two
examples that make me confused.</p>
<p class="MsoNormal" style="line-height:16pt">1 /*
example 1 */</p>
<p class="MsoNormal" style="line-height:16pt">2
void func() {</p>
<p class="MsoNormal" style="line-height:16pt">3 int arr[10][10];</p>
<p class="MsoNormal" style="line-height:16pt">4 int b;</p>
<p class="MsoNormal" style="line-height:16pt">5 b = 5;</p>
<p class="MsoNormal" style="line-height:16pt">6 arr[b][2] = 9;</p>
<p class="MsoNormal" style="line-height:16pt">7 }</p>
<p class="MsoNormal" style="line-height:16pt">When
evaluating the <i>checkLocation(Store) </i>of
“arr[b][2]” in line 6, I can get the MemRegion of b. Then I tried to get the
SVal of MemRegion b via Store(StoreManager.getBinding()). But I got an
Undefined SVal. And the Store mapping of ProgramState at that time was empty,
too. In addition, I tried to get the b’s SVal with its DeclRefExpr using
ProgramStateRef->getSVal(). But it returned me an Unknown SVal. In fact, it’s
easy to know that the SVal of b at that time should be (5, S32b). Is there any
way to make it?</p>
<p class="MsoNormal" style="line-height:16pt"> </p>
<p class="MsoNormal" style="line-height:16pt">Another
example here is similar, but is for pointer.</p><p class="MsoNormal" style="line-height:16pt">0 /* example 2 */</p>
<p class="MsoNormal" style="line-height:16pt">1 struct
st0 {</p>
<p class="MsoNormal" style="line-height:16pt">2 int i;</p>
<p class="MsoNormal" style="line-height:16pt">3 };</p>
<p class="MsoNormal" style="line-height:16pt">4 struct
st1 {</p>
<p class="MsoNormal" style="line-height:16pt">5 int i;</p>
<p class="MsoNormal" style="line-height:16pt">6 struct st0 struct0;</p>
<p class="MsoNormal" style="line-height:16pt">7};</p>
<p class="MsoNormal" style="line-height:16pt">8struct
st2 {</p>
<p class="MsoNormal" style="line-height:16pt">9 struct st1 *p;</p>
<p class="MsoNormal" style="line-height:16pt">10 };</p>
<p class="MsoNormal" style="line-height:16pt">11 int
main() {</p>
<p class="MsoNormal" style="line-height:16pt">12 struct
st1 s1;</p>
<p class="MsoNormal" style="line-height:16pt">13 struct st2 s2;</p>
<p class="MsoNormal" style="line-height:16pt">14 s2.p = &s1; </p>
<p class="MsoNormal" style="line-height:16pt">15 s2.p->struct0.i = 3;</p>
<p class="MsoNormal" style="line-height:16pt">16 }</p>
<p class="MsoNormal" style="line-height:16pt">When
evaluating the <i>checkLocation(Store) </i>of
“s2.p->struct0.i” in line 15, I can get the MemRegion of s2.p. Then I tried
to get the SVal of MemRegion s2.p via Store(StoreManager.getBinding()). But I got
an Undefined SVal. However, the expected SVal should be a MemRegionVal wrapping
MemRegion s1. Because MemRegion s1 is the pointee region of s2.p. How can I get
that?</p><p class="MsoNormal" style="line-height:16pt"><br></p><p class="MsoNormal" style="line-height:16pt">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>