<div dir="ltr">
















<p class="MsoNormal">Hi all, </p>

<p class="MsoNormal">I have some problem on the result of Clang Static Analyzer
dealing with malloc().  Here is the
simple test code, which I tried:</p>

<p class="MsoNormal">int *pi;</p>

<p class="MsoNormal">pi = (int *)malloc(sizeof(int));</p>

<p class="MsoNormal">*pi = 8;</p>

<p class="MsoNormal">free(pi);</p>

<p class="MsoNormal"> </p>

<p class="MsoNormal">The <i>pi</i> is a
pointer variable. After malloc() being called, <i>pi</i> points to an object which is located on the heap. However, in
the Clang Static Analyzer, I found that after malloc() being called, <i>pi</i> pointed to<i> element{SymRegion{conj_$2{void *}},0 S32b,int}</i>. Then I tried to
get the super region of <i>SymRegion{conj_$2{void
*}}. </i>What confused me is that, the super region of <i>SymRegion{conj_$2{void *}}</i> was <i>UnkonwnSpaceRegion</i>.
I thought its super region should be HeapSapceRegion, because I use malloc()
for dynamic memory allocation in the code. But now I get the different result. So
I wonder how does Static Analyzer deal with malloc()? Does Static Analyzer
regard malloc() as an ordinary function which returns an pointer?</p>

<p class="MsoNormal"> </p>

<p class="MsoNormal">What’s more, I have a question on the method<i> isInSystemHeader()
</i>of CallEvent. I use it to test whether the CallEvent is an system function call,
such as <i>scanf(), printf()</i> and etc. But it seems it does work. It seems that
Static Analyzer cannot tell whether a function call is in system header rightly.
And my Clang version is 3.5. </p>

<p class="MsoNormal"> </p>

<p class="MsoNormal">Thanks a lot.</p>

<div><br></div>-- <br><div dir="ltr"><font color="#444444">Best regards,</font><div><font color="#444444">Arthur Yoo</font></div></div>
</div>