[AST Matchers] Fix bug in 'optionally' matcher wherein all previous bindings are...
authorYitzhak Mandelbaum <yitzhakm@google.com>
Fri, 28 Feb 2020 17:45:19 +0000 (12:45 -0500)
committerYitzhak Mandelbaum <yitzhakm@google.com>
Fri, 28 Feb 2020 18:46:27 +0000 (13:46 -0500)
commit586f13aeac3fd51916774f523e30f0aee2b62d46
tree4a8011ae4af60025320cbd4e151ffb2d1a2351b4
parent1de10705594c7a2c9b8fde901c391bd84062ae04
[AST Matchers] Fix bug in 'optionally' matcher wherein all previous bindings are cleared when all inner matchers fail.

Summary: The implementation of 'optionally' doesn't preserve bindings when none of the submatchers succeed. This patch adds a regression test for that behavior and fixes it.

Reviewers: aaron.ballman, sbenza

Subscribers: cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D75365
clang/lib/ASTMatchers/ASTMatchersInternal.cpp
clang/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp