[cfe-dev] Crash in TagType::getAsString()

steve naroff snaroff at apple.com
Tue Jan 13 22:34:29 PST 2009


Hi Alexei,

Some brief comments...

On Jan 13, 2009, at 9:29 PM, Alexei Svitkine wrote:

> Ok I figured out my problem.
>
> Turns out the Preprocessor owns the IdentifierTable and I wasn't
> keeping the Preprocessor around.


> Are there any docs on what parts of the AST are owned by what? Also,
> is there any way to get at the objects allocated by ParseAST if the
> FreeMemory argument is false, so that I can delete them when I am done
> with them?
>

Nope. It looks like ASTContext and TranslationUnit should be passed  
into ParseAST.

This would give the client much more flexibility (and enable us to  
remove the "FreeMemory" argument).

> Is there a reason that there isn't a self-contained AST object that
> contains and owns everything necessary, rather than having different
> parts of it owned by different classes?
>
> It seems weird to me that the Preprocessor would retain ownership to
> something used by the AST. To me, the name Preprocessor suggests that
> its purpose it to preprocess the code, and I shouldn't need to keep it
> around after that's done (but evidently that's not the case).


It is weird (and needs to be refined). The good news is core objects  
(like ASTContext) don't depend on having a Preprocessor object. So  
fixing this should be straightforward/localized.

snaroff

> Sorry if there is a good reason to keep it this way, and I am just  
> missing it.
>
> -Alexei
> _______________________________________________
> cfe-dev mailing list
> cfe-dev at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev




More information about the cfe-dev mailing list