[cfe-dev] AST processing toolbox
clattner at apple.com
Fri Jun 12 15:47:36 CDT 2009
On Jun 12, 2009, at 3:14 AM, Olaf Krzikalla wrote:
> 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
> become handy for others too - cloning, garbage collecting aso. Of
> I'm eager to share these stuff. However there are some issues to solve
> 1. I use boost, in particular boost::bind and boost::function (that
discussed elsewhere :). We do have a simple llvm::tie function in
llvm/ADT/STLExtras.h if you want, this allows you to write code like:
int x, y;
tie(x, y) = my_fn_returning_pair_of_ints();
However, there is a bigger issue here: in the absence of c++ lambdas, c
++ code that uses a highly functional style is often very difficult to
read. Are you sure that using these actually helps improve the
readability of your code?
> 2. Sometimes it seemed to me that having a parent member in a
> would be better then the ParentMap. Nevertheless I worked with
> 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.
Improving parentmap sounds great! Feel free to propose this as a
patch independent of your other changes.
> 3. I'd like to extend the PrintingPolicy so we can rewrite in other
> styles too, e.g.
This seems reasonable.
> For all the new stuff: where to put in? Or is it better to create a
> separate ASTProcessing library?
It is best to split up your changes into logically independent ones:
different pieces probably go in different places. Thanks for working
More information about the cfe-dev