<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;"><br><div><blockquote type="cite"><div>On Jun 23, 2014, at 9:37 AM, Arthur Yoo <<a href="mailto:phjy007@gmail.com">phjy007@gmail.com</a>> wrote:</div><br class="Apple-interchange-newline"><div><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><div> <br class="webkit-block-placeholder"></div><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></div></div></blockquote>You can find out more about how heap region is used and constructed from commit r158136. The SymRegion should have heapRegion() as it's parent. Maybe the printing is off?</div><div><br><blockquote type="cite"><div><div dir="ltr"><div> <br class="webkit-block-placeholder"></div><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><div> <br class="webkit-block-placeholder"></div></div></div></blockquote><div><br></div><div>It should work. How are you testing this? </div><br><blockquote type="cite"><div><div dir="ltr"><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>
_______________________________________________<br>cfe-dev mailing list<br><a href="mailto:cfe-dev@cs.uiuc.edu">cfe-dev@cs.uiuc.edu</a><br>http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev<br></div></blockquote></div><br></body></html>