This patch adds postorder traversal support to the RecursiveASTVisitor.
This feature needs to be explicitly enabled by overriding shouldTraversePostOrder()
as it has performance drawbacks for the iterative Stmt-traversal.
Paths
| Differential D20382
Add postorder support to RecursiveASTVisitor ClosedPublic Authored by teemperor on May 18 2016, 1:41 PM.
Details Summary This patch adds postorder traversal support to the RecursiveASTVisitor. This feature needs to be explicitly enabled by overriding shouldTraversePostOrder()
Diff Detail Event Timelineteemperor updated this object. Comment ActionsThe motivation for this patch is a hashing algorithm for all AST nodes The full code that currently uses this feature can be seen here: teemperor added a child revision: D20795: Added basic capabilities to detect source code clones..May 30 2016, 10:41 AM Comment Actions Having postorder traversal makes sense to me. The thing I'm worried about is how much this will bloat object code. RecursiveASTVisitor is already a major contributor to the size of clang's binary and we've hit issues with it in the past (hitting .obj size limits on Windows for example) can you show numbers of the size of clang before and after this change? Ideally in Release and Debug configurations. If it grows it too much we'll have to find another way of enabling/disabling it. Comment Actions The previous stats were wrong (only applied this patch, not the patch using the code): Release: Comment Actions IMO a 20% release binary size increase is not acceptable. Is there a way to compile in support only if it's actually used? Maybe some constexpr or template magic? teemperor edited edge metadata. Comment ActionsReduced executable size bloat. Made postorder and preorder mutually exclusive and postorder also uses the normal Visit* methods for callbacks. Comment Actions Agreed. The new patch is now reusing the Visit methods so that the executable size stays the same. Comment Actions @bkramer are those modifications enough to accept this patch? It is holding back quite a lot of ongoing development from @teemperor as part of his GSoC project. bkramer edited edge metadata. Comment ActionsIf there's no more executable size bloat this seems fine to me. This revision is now accepted and ready to land.Jun 27 2016, 8:27 AM
teemperor edited edge metadata. Comment Actions
Revision Contents
Diff 62015 include/clang/AST/RecursiveASTVisitor.hunittests/AST/CMakeLists.txt
unittests/AST/PostOrderASTVisitor.cpp
|
Does this really give a postorder traversal rather than some kind of postorder / reverse preorder hybrid (based on whether we use data recursion or regular recursion for different parts of the graph)?
I would expect the right way to handle this would be to call PostVisitStmt from the if (Visited) branch above, where we call dataTraverseStmtPost.