[cfe-dev] clang --analyze: how do I get more verbose diagnostics?

Magnus Reftel magnus.reftel at gmail.com
Fri Nov 15 04:50:07 PST 2013


On 12 November 2013 20:56, Richard <legalize at xmission.com> wrote:
> clang --analyze reports this problem in my code:
>
> warning: Potential memory leak
>         for (extent_vector_iter deit = disk_.provided_extents.begin();
>              deit != disk_.provided_extents.end(); ++deit)
>                                                    ^~
> 1 warning generated.
>
> Context:
>         typedef std::vector<extent_data> extent_vector;
>         typedef extent_vector::const_iterator extent_vector_iter;
>
>         extent_data has no raw pointers, only non-pointer POD types and other
>         standard library classes like string and vector of string, etc.
>
> The problem with this diagnostic is that it points to the place where
> it thinks a memory leak may occur, but it doesn't provide me with a
> chain of reasoning that makes me understand why it thinks this
> particular chunk of code may leak memory.
>
> Am I missing some magic flag to tell me this extra level of
> information, or is that ability simply lacking?

You can get HTML reports (which show the whole chain of reasoning) using

clang --analyze -Xclang -analyzer-output=html -o somedir ...

BR
Magnus Reftel



More information about the cfe-dev mailing list