[cfe-users] How to check custom "malloc"?

Grissiom chaos.proton at gmail.com
Sun Jul 14 19:00:11 PDT 2013


On Sun, Jul 14, 2013 at 11:08 PM, Jean-Daniel Dupas
<devlists at shadowlab.org>wrote:

> Hello,
>
> 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:
>
>
> http://stackoverflow.com/questions/16285498/is-there-an-equivalent-to-attribute-ns-returns-retained-for-a-mallocd-po
>
> And you can also have a look at the file testing theses attributes at
> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/malloc-annotations.c?view=markup
>
> 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.
>
>
Thank you very much! It works like a charm.

Le 14 juil. 2013 à 16:35, Grissiom <chaos.proton at gmail.com> a écrit :
>
> > Hi all,
> >
> > 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?
> >
> > 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"?
> >
> >
> >
> > --
> > Cheers,
> > Grissiom
> > _______________________________________________
> > cfe-users mailing list
> > cfe-users at cs.uiuc.edu
> > http://lists.cs.uiuc.edu/mailman/listinfo/cfe-users
>
> -- Jean-Daniel
>
>
>
>
>


-- 
Cheers,
Grissiom
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-users/attachments/20130715/8c60412b/attachment.html>


More information about the cfe-users mailing list