[cfe-dev] why does clang re-evaluate the target info for each input file?

Sam Bishop sam at bishop.dhs.org
Mon Mar 3 13:35:02 PST 2008

Hi, Ted.

> On Mar 1, 2008, at 12:31 PM, Sam Bishop wrote:
>> What got me looking at this was valgrind complaining about target
>> information being leaked.  I've looked at this a little closer, and
>> it appears that the leak is in the library code.  I should be able
>> to fix that.

Hmm...  I can see what the problem is, but I'm not sure how it should be

As stated in its header file, the TargetInfo class does not take
ownership of the TargetInfoImpl objects it uses.  On the other hand, the
primary TargetInfoImpl object can only be set indirectly, by calling the
CreateTargetInfo() function, but there's no way to get a pointer to the
object the function creates.

The solution I'm leaning toward is making the
TargetInfo::AddSecondaryTarget() method private, since it isn't used
anywhere else, and have the TargetInfo class cleanup any TargetInfoImpl
objects it creates and uses.  A patch is attached, if you think that's
the way to go.

-------------- next part --------------
A non-text attachment was scrubbed...
Name: TargetInfo-class-takes-ownership-of-TargetInfoImpl-objects.patch
Type: application/octet-stream
Size: 1731 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20080303/47dbb0e5/attachment.obj>

More information about the cfe-dev mailing list