On May 12, 2009, at 9:21 AM, David Greene wrote:> I'm adding some new operators to TableGen and I've run into a
memory
> ownership
> issue.
>
> We have all of these Inits and RecTys flying around but I don't see
> any scheme
> to assign ownership. It looks like we're leaking memory all over.
>
> This is getting worse as I'm adding operators because I need to
> create new
> objects on-the-fly and/or return operands of operators as the result
> of
> the folding of the operation.
Yes, this is horrible. It would be really nice (tm) if C++ allowed
you to say "anything derived from this class should be garbage
collected". Alas, that doesn't exist. :)
> Is there an ownership scheme or should we consider smart pointers or
> a similar
> mechanism?
I think smart pointers would make sense, though I generally prefer an
explicit ownership model. I'm happy with whatever you think is best,
-Chris