[cfe-commits] plug a memory leak in the -E code
Chris Lattner
clattner at apple.com
Tue Mar 4 09:26:41 PST 2008
>>>
>>> When clang is acting on the -E option, it creates a
>>> PrintPPOutputPPCallbacks object but never deletes it. The object is
>>> passed to the Preprocessor object, but it doesn't delete it either.
>>>
>>> It seems to me that the Driver code ought to do the deleting. So I
>>> have attached a patch which does just that.
>>
>> Nice catch. However, I think it makes more sense for the PP to take
>> ownership of the callbacks object. What do you think?
>
> Do the LLVM and clang projects have a general rule of thumb for making
> these kinds of decisions? "The object/module that calls new calls
> delete" is the rule I have always gone with, but I can see your point
> and could be easily swayed.
Not specifically. This is why it's really important to add good
comments (like you did!) saying "this method takes ownership" or not.
-Chris
More information about the cfe-commits
mailing list