On Feb 8, 2013, at 8:24 AM, Jeff Law <l...@redhat.com> wrote: >> I'm not quite sure that this clean split is possible, even after making >> amends for template instantiation. It's great for syntax-driven tools, >> but once you move beyond that, you tend to ignore stuff like destructors >> (or the cleanup attribute), life-times of temporaries etc., things which >> are just not visible in an AST. You have to reimplement many program >> analysis algorithms typically part of compiler optimizers, after >> lowering the AST to a less elaborate intermediate representation (a step >> which requires a fair amount of knowledge about the language in question). > There's always going to be some things that are best done with the raw ASTs > and others which are best done when we've got a lowered IL, CFG, SSA graph, > etc. > > The big question is how well can you go from the output of clang into a lower > level IR where you can do in depth analysis and how much you allow optimizers > to perturb the results of the analysis. One could argue that clang -> gimple > would be a useful translator to allow the nice things from the clang > front-end, but also still allow the more in-depth analysis done by our > tree-ssa code.
FWIW, the Clang static analyzer uses just such a representation: it is a CFG formed out of AST nodes. -Chris