[PATCH] D75365: [AST Matchers] Fix bug in 'optionally' matcher wherein all previous bindings are cleared when all inner matchers fail.

Yitzhak Mandelbaum via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Mar 2 05:52:11 PST 2020


ymandel added a comment.

In D75365#1900784 <https://reviews.llvm.org/D75365#1900784>, @gribozavr2 wrote:

> +1 to this fix.
>
> However, regarding `allOf` vs. `anyOf` semantics, since `optionally` always succeeds, is there a difference between the two semantics?
>
> It seems to me that there should be no difference between `allOf(optionally(a), optionally(b))` vs. `anyOf(optionally(a), optionally(b))`.


I think the difference is in whether you continue with the submatchers after a success. Allof does while anyof does not.  That said, the original issue was forEach vs allOf/anyOf. So, I think Aaron's point holds - let optionally take one argument and then leave it to the user to explicitly specify forEach, allOf, anyOf, etc.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D75365/new/

https://reviews.llvm.org/D75365





More information about the cfe-commits mailing list