[cfe-dev] Toward the AST cloning

Olaf Krzikalla Olaf.Krzikalla at tu-dresden.de
Fri Jun 5 04:11:04 PDT 2009


Hi @all,

while my AST XML patch still seems to be in the pipeline (I hope it is 
in someones pipeline) I worked on at AST level 
source-to-source-transformations. Quickly I came at the point where I 
need the AST cloning feature too which was already discussed here. 
However I choosed a non-intrusive approach using the StmtVisitor. I 
attached a almost working sketch (it's a cut-out, just add the includes 
and namespaces and yes, I know, the DenseMap again :-). The advantage is 
that you get a mapping between original and cloned AST nodes (in a 
productive version this would be an optional feature), which is needed 
for rechaining gotos to cloned labels, DeclRefs to other variables aso. 
Indeed someone could compute such a mapping by hand but this would be 
overly complex and needs to traverse the AST a second time.
As you can see, the decl-cloning issue isn't resolved yet. I will work 
on it next week.
Opinions? Suggestions?

Best
Olaf Krzikalla


BTW: do we have a macro for stack-based variable-sized arrays? In my 
former company I introduced such a thing, which internally either used 
the gcc extension or on msvc the alloca approach (which however was 
somewhat tricky in the presence of loops).

-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: cut-out.txt
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20090605/ee16b57d/attachment.txt>


More information about the cfe-dev mailing list