[cfe-dev] Quenstion about ParseAST()
Sean Silva
silvas at purdue.edu
Sun Aug 19 11:15:12 PDT 2012
> In my investigation, 2,3 loops for each top level declarations.
I think you're getting confused by a lot of the other stuff that is
happening in ParseAST that isn't really all that important. ParseAST
is basically 3 steps:
1. prepare for parsing
2. repeatedly call P.ParseTopLevelDecl() until the whole source file
has been parsed
3. do other stuff that has to happen after parsing
> Expecially I wonder why CodeGenAction works before the complete AST is built.
Clang's AST is immutable. Once the top-level decl is finished, it
never changes, hence it is safe to pass to codegen at that point.
I believe this is primarily a locality optimization so that codegen
operates on the AST while it is still hot on cache; you could just as
easily perform all codegen based on the final AST.
> And Constants folding occurs in 3.
Clang does not do constant folding; it's AST exactly represents the
expression. Clang has facilities for evaluating constant expressions
when necessary, but it doesn't really "fold" them.
-- Sean Silva
On Sun, Aug 19, 2012 at 1:42 AM, Journeyer J. Joh
<oosaprogrammer at gmail.com> wrote:
> Hello list,
>
> http://www.opencpp.kr/ParseAST.jpg
>
> I made a diagram about the global function ParseAST() in ParseAST.cpp
>
> Could someone explain about the 1,2,3,4 above?
>
> In my investigation, 2,3 loops for each top level declarations.
> And the AST Parse Tree is completed before number 4 starts.
> And Constants folding occurs in 3.
>
> Expecially I wonder why CodeGenAction works before the complete AST is built.
>
> Thank you very much in advance.
>
> Journeyer J. Joh
>
>
>
>
> --
> ----------------------------------------
> Journeyer J. Joh
> o o s a p r o g r a m m e r
> a t
> g m a i l d o t c o m
> ----------------------------------------
> _______________________________________________
> 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