optimizations done on ASTs

Hi all,

Just a quick question. What optimizations are done on ASTs in clang? By scanning the code, I did not find any optimizations done directly on ASTs. Shortly after preprocessed code is parsed in ParseAST.cpp, it is translated into bitcode which lots of optimizations manipulate. If any, please point me to the right direction.

Thanks a lot in advance.
-Bin Zeng

Clang does not perform an optimization on ASTs. The ASTs describe the code as written in the source file, augmented with semantic information (types, implicit conversions, etc.) describing the actual behavior. The AST -> IR lowering performs some simple optimizations, but the real optimization work is performed on the IR.

  - Doug

Just to expand on this slightly: we sometimes do record information that's useful for optimization in the ASTs. For example, we mark that a local variable is a candidate for NRVO when processing that function. But we still never do optimization on the ASTs: they're intended to exactly represent the high-level syntax and semantics of the source file.