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).
cut-out.txt (2.12 KB)