I'm planning a bunch of refactorings on a large code base that I'd like to automate using Clang tooling. For this, I'm trying to write a Clang AST Matcher expression.
Specifically, I'm trying to match pairs of statements that I'd like to replace with something else, like
a(); => a_and_b(x);
b(x);
So I'm trying to match an a
callExpr() followed by a b
callExpr() (but could be any statement, really). I have constructed matchers for the first and the second statements, independently, let's call them aMatcher()
and bMatcher()
but haven't found how to combine them so that they match only if they're back-to-back, something like bMatcher(follows(aMatcher())
. None of the existing matchers seems to be pertinent (looked for "next", "prev", "position", ...).
How do I go about this the correct way, please?