We can get AST after a number of clang’s semantical and syntactical analysis on the source file. I would like to know where is the place that stores the resulting AST’s. Is there any database that can store the intermediate results while parsing source files? Or is AST built on the fly automatically without being stored anywhere? To clarify more, I can dump AST for the given source code by using clang command. where is the source of this dumped file? I guess, when running the dump command, it automatically parse the source and and build AST on the fly and show the result. But am not sure. How someone able to capture AST if he/she needs to transform it. I will be thankful for any clarification.
We can get AST after a number of clang’s semantical and syntactical analysis on the source file. I would like to know where is the place that stores the resulting AST’s. Is there any database that can store the intermediate results while parsing source files? Or is AST built on the fly automatically without being stored anywhere?
This last is the most accurate description. The AST is not (generally) persisted, it is built as we parse the file.
To clarify more, I can dump AST for the given source code by using clang command. where is the source of this dumped file? I guess, when running the dump command, it automatically parse the source and and build AST on the fly and show the result.
Correct.
How someone able to capture AST if he/she needs to transform it.
Typically it is transformed in memory after parsing has constructed it. If you need to serialize the AST to disk, there are serialization routines for the AST as well as deserialization routines to read it back off of the disk. All of the AST transformations happen on a complete AST held in memory. How you get it there and what you do afterward are orthogonal questions.