[cfe-dev] AST processing toolbox

Olaf Krzikalla Olaf.Krzikalla at tu-dresden.de
Fri Jun 12 03:14:50 PDT 2009


Hi @clang,

now I'm quite finished with the very first part of my AST processing - 
function inlining at AST level.
One result of the development are a lot of AST processing tools that can 
become handy for others too - cloning, garbage collecting aso. Of course 
I'm eager to share these stuff. However there are some issues to solve 
before:
1. I use boost, in particular boost::bind and boost::function (that is, 
header only for the moment). Unless there is something similiar in llvm 
(which I didn't found yet), I won't like to change this. However this 
would add dependencies to boost and I don't know the opinions of the 
main developers regarding this issue.
2. Sometimes it seemed to me that having a parent member in a statement 
would be better then the ParentMap. Nevertheless I worked with ParentMap 
but needed to add ParentMap::addStmt, which adds and/or updates the 
parent/child relations of the given Stmt tree. However I'm not really 
satisfied with the function name yet.
3. I'd like to extend the PrintingPolicy so we can rewrite in other 
styles too, e.g.

if (x)
{
  y;
}

Also there are some fixes needed: I already mentioned the DoStmt bug. A 
second thing striking me regulary is the wrong indentation:
voif foo()
{
  //...
  {                  // here reprinting starts;
}
  //... here it ends
}

Maybe this issue goes away if I stop using Rewriter::ReplaceStmt, which 
I need to do anyway. I have to test this.

For all the new stuff: where to put in? Or is it better to create a 
separate ASTProcessing library?

Best,
Olaf Krzikalla




More information about the cfe-dev mailing list