<div dir="ltr">On Sun, Jul 14, 2013 at 11:08 PM, Jean-Daniel Dupas <span dir="ltr"><<a href="mailto:devlists@shadowlab.org" target="_blank">devlists@shadowlab.org</a>></span> wrote:<br><div class="gmail_extra"><div class="gmail_quote">
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hello,<br>
<br>
You can use the "ownership" attributes to annotate your functions. I can't find documentation for theses attributes, but there is a discussion about it at:<br>
<br>
<a href="http://stackoverflow.com/questions/16285498/is-there-an-equivalent-to-attribute-ns-returns-retained-for-a-mallocd-po" target="_blank">http://stackoverflow.com/questions/16285498/is-there-an-equivalent-to-attribute-ns-returns-retained-for-a-mallocd-po</a><br>
<br>
And you can also have a look at the file testing theses attributes at <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/malloc-annotations.c?view=markup" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/malloc-annotations.c?view=markup</a><br>
<br>
As stats in the StackOverflow discussion, you may have to enable this check explicitly by passing "-Xclang -analyzer-checker=alpha.unix.MallocWithAnnotations" to clang when invoking the static analyzer.<br>
<br></blockquote><div><br></div><div>Thank you very much! It works like a charm.</div><div><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Le 14 juil. 2013 à 16:35, Grissiom <<a href="mailto:chaos.proton@gmail.com">chaos.proton@gmail.com</a>> a écrit :<br>
<div><div class="h5"><br>
> Hi all,<br>
><br>
> I'm doing embedded programming and want to use clang to do some static analyze with the code. One problem I'm facing is we use custom memory allocater in the project, namely "rt_malloc" etc. Is there any way to make clang check such calls just like normal malloc without writing my own plugin?<br>
><br>
> I've checked cfe/trunk/lib/StaticAnalyzer/Checkers/MallocChecker.cpp and I know I could substitute "malloc" with "rt_malloc" and compile that file as so libs. But I think it's an overkill. Is there anyway to tell clang that "rt_malloc" is just an alias of "malloc"?<br>
><br>
><br>
><br>
> --<br>
> Cheers,<br>
> Grissiom<br>
</div></div>> _______________________________________________<br>
> cfe-users mailing list<br>
> <a href="mailto:cfe-users@cs.uiuc.edu">cfe-users@cs.uiuc.edu</a><br>
> <a href="http://lists.cs.uiuc.edu/mailman/listinfo/cfe-users" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/cfe-users</a><br>
<span class="HOEnZb"><font color="#888888"><br>
-- Jean-Daniel<br>
<br>
<br>
<br>
<br>
</font></span></blockquote></div><br><br clear="all"><div><br></div>-- <br>Cheers,<br>Grissiom
</div></div>