[cfe-dev] Quenstion about ParseAST()

Journeyer J. Joh oosaprogrammer at gmail.com
Sun Aug 19 14:12:47 PDT 2012


Hello Sean Silva,

I now can understand ParseAST().
Thank you very much!

I thought this question was a little bit too much surd. (I am not sure
of the meaning of this word 'surd'. I used it after I found it from
the dictionary)

But you answered this question.
Thank you very much..

Sincerely
Journeyer J. Joh




2012/8/20 Sean Silva <silvas at purdue.edu>:
>> 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



-- 
----------------------------------------
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
----------------------------------------



More information about the cfe-dev mailing list