[cfe-dev] valgrind memcheck shows leaks in svn clang compile of simplest c++ program

Larry Evans cppljevans at suddenlink.net
Sun Dec 30 12:44:09 PST 2012


On 12/30/12 12:52, Sebastian Redl wrote:
> 
> On 30.12.2012, at 14:33, Larry Evans wrote:
> 
>> Is using valgrind memcheck a good way to detect memory leaks in clang?
> 
> No. Look at this part of the command line:
> 
>>> ==5556== Command: /home/evansl/download/llvm/svn/top/out/debug/install/bin/clang -cc1 -disable-free
> 
> This option (passed by default from the driver to the main compiler) instructs Clang not to free 
> any of the AST nodes it allocates, to save time on process shutdown. So obviously they all leak.
> 
> Sebastian
Is there an -enable-free flag to the driver that stops these leaks?
(The `clang -help` shows none, but maybe it's hidden like the ### flag).
Grepping the sources shows:

  CmdArgs.push_back("-disable-free");
8373719  224 -rw-r--r--   1 evansl   evansl     221926 Dec 29 19:36
./Driver/Tools.cpp

but Tools.cpp looks like that's hardcoded (IOW, it's not guarded by
some test that looks like a check of the input args).

-Larry





More information about the cfe-dev mailing list