arphaman added a comment. I don't think AST manipulation is the right way to do patching. You've already hit the limitations here in this patch where you can't really remove a statement unless its parent is a `CompoundStmt`.
I think the right way to do AST patching is to take a 3rd AST(lets call it a target AST), find the set of matching nodes that correspond to all nodes that have to be patched and then perform patching by rewriting the source for the target AST. Let's say you want to start with `remove`. If you take the following files: $ cat src.cpp void printf(const char *, ...); void foo(int x) { printf("%d", x, x); } $ cat dst.cpp void printf(const char *, ...); void foo(int x) { printf("%d", x); // the second 'x' is removed. } $ cat target.cpp void printf(const char *, ...); void foo(int x) { printf("different string %d", x, x); } You'll find that the difference between src.cpp and dst.cpp is `Delete DeclRefExpr: x(10)`. Then you can take target.cpp, find the matching `DeclRefExpr` node, and create a source replacement (see tooling's Replacement) that removes ", x" from target.cpp. https://reviews.llvm.org/D37005 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits