On Sat, Oct 25, 2008 at 3:38 PM, Ted Kremenek <[EMAIL PROTECTED]> wrote: > > On Oct 25, 2008, at 2:07 AM, Argiris Kirtzidis wrote: > >>> It does seem odd that we're destroying the TypedefDecl before >>> destroying the FunctionDecl but I'll look into it. >>> >> >> TranslationUnit destroys the decls at the order of receiving them, should >> that be reverse order ? > > The order shouldn't matter if we have a clear ownership policy. While > TranslationUnit may free AST nodes in a particular order, there's no reason > to expect that when clients create and free AST nodes that they do it in a > particular order either. The only requirement is that memory that is freed > is no longer accessed.
I don't think the ownership policy would necessarily clear this up. For ownership to solve this problem, we would need to have the FunctionDecl "own" the TypedefDecl that is used to express it's type. It can't have sole ownership, of course, since another FunctionDecl might use it as the type. There are a few solutions here. One easy option, which I've committed already as a band-aid, is as Argiris said: destroy the decls in reverse order. Since a Decl should only depend on Decls before it, this works. Another alternative is to ban destructors that look through any non-owned pointer; for example, this would mean that FunctionDecl would have to have its own NumParams field rather than looking through its type field to find the number of parameters. Then, order of destruction would never matter. - Doug _______________________________________________ cfe-commits mailing list [email protected] http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
