-
Notifications
You must be signed in to change notification settings - Fork 6
Description
When using the AST traversal functionality (inheriting from one of the rumur::BaseTraversal children), a common pattern is searching for a node matching some criteria. I.e. you start not knowing whether a matching node exists and are effectively done as soon as you find a matching node (something like std::any_of). However, the traversal class has no mechanism for aborting an in-progress traversal. That is, there's no way to signal, "I'm done, please stop recursing." You can throw an exception but it is kind of unpleasant to use an exception for this kind of control flow.
The effect of this is that you keep (uselessly) traversing the AST when you already know the answer. The result is correct but performance is impacted.
This was a problem that was anticipated some time ago. The most expedient solution might be something like LLVM's design. I'd avoided doing this before now because I don't find their design particularly ergonomic either. It might be the least bad one though, and is certainly an improvement on the current implementation.