Life span of AST data

Greetings,

I’m working on a src-2-src transformer, and I want it to be as modular as possible.
Currently I’m doing the transformations by invoking Rewriter from within ASTConsumer methods.
What I want is to have methods like: setFuncName, insertTextAfterCall etc, which will be separated from the parsing process, and could be invoked independantly. The problem is that all the data generated during the parsing (Decl, Stmt, SourceLocation) is deleted after the parsing ends.

Is there a better way but doing a deep copy of the required data during the parsing?

Thanks,
Ilya

Greetings,

I'm working on a src-2-src transformer, and I want it to be as modular as possible.
Currently I'm doing the transformations by invoking Rewriter from within ASTConsumer methods.

Good, that's the right approach.

What I want is to have methods like: setFuncName, insertTextAfterCall etc, which will be separated from the parsing process, and could be invoked independantly. The problem is that all the data generated during the parsing (Decl, Stmt, SourceLocation) is deleted after the parsing ends.

Why can't you just perform all of the necessary operations within ASTConsumer::HandleTranslationUnit?

  - Doug

It's not deleted after parsing ends; it's deleted when you destroy the ASTContext (or the SourceManager, for SourceLocations).

John.

It's not deleted after parsing ends; it's deleted when you destroy the ASTContext (or the SourceManager, for SourceLocations).

John.