Skip to content

Commit 168f812

Browse files
committed
[clang][ASTMatcher] Fix execution order of hasOperands submatchers
The `hasOperands` matcher does not always execute matchers in the order they are written. This can cause issue in code using bindings when one operand matcher is relying on a binding set by the other. With this change, the first matcher present in the code is always executed first and any binding it sets are available to the second matcher.
1 parent 1fb1a5d commit 168f812

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

clang/include/clang/ASTMatchers/ASTMatchers.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6027,7 +6027,7 @@ AST_POLYMORPHIC_MATCHER_P2(
60276027
internal::Matcher<Expr>, Matcher1, internal::Matcher<Expr>, Matcher2) {
60286028
return internal::VariadicDynCastAllOfMatcher<Stmt, NodeType>()(
60296029
anyOf(allOf(hasLHS(Matcher1), hasRHS(Matcher2)),
6030-
allOf(hasLHS(Matcher2), hasRHS(Matcher1))))
6030+
allOf(hasRHS(Matcher1), hasLHS(Matcher2))))
60316031
.matches(Node, Finder, Builder);
60326032
}
60336033

0 commit comments

Comments
 (0)