diff options
author | David L. Jones <dlj@google.com> | 2019-08-15 04:10:11 +0000 |
---|---|---|
committer | David L. Jones <dlj@google.com> | 2019-08-15 04:10:11 +0000 |
commit | 7f1a63eb34a417c80506f92bc59893ba010e9ce0 (patch) | |
tree | fb0f4210e1821d6307103576efa50ccb05248b7d | |
parent | 7061b97979f0e3d560178980672b3138c43261af (diff) | |
download | clang-7f1a63eb34a417c80506f92bc59893ba010e9ce0.tar.gz |
[Tooling] Add a hack to work around issues with matcher binding in r368681.
The change in r368681 contains a (probably unintentional) behavioral change for
rewrite rules with a single matcher. Previously, the single matcher would not
need to be bound (`joinCaseMatchers` returned it directly), even though a final
DynTypeMatcher was created and bound by `buildMatcher`. With the new change, a
single matcher will be bound, in addition to the final binding (which is now in
`buildMatchers`, but happens roughly at the same point in the overall flow).
This patch simply duplicates the "final matcher" trick: it creates an extra
DynTypedMatcher for each rewrite rule case matcher, and unconditionally makes it
bindable. This is probably not the right long-term fix, but it does allow
existing code to continue to work with this interface.
Subscribers: cfe-commits, gribozavr, ymandel
Tags: #clang
Differential Revision: https://reviews.llvm.org/D66273
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@368958 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | lib/Tooling/Refactoring/Transformer.cpp | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/lib/Tooling/Refactoring/Transformer.cpp b/lib/Tooling/Refactoring/Transformer.cpp index 24f9b58897..c27739c596 100644 --- a/lib/Tooling/Refactoring/Transformer.cpp +++ b/lib/Tooling/Refactoring/Transformer.cpp @@ -98,8 +98,10 @@ static std::vector<DynTypedMatcher> taggedMatchers( Matchers.reserve(Cases.size()); for (const auto &Case : Cases) { std::string Tag = (TagBase + Twine(Case.first)).str(); - auto M = Case.second.Matcher.tryBind(Tag); - assert(M && "RewriteRule matchers should be bindable."); + // HACK: Many matchers are not bindable, so ensure that tryBind will work. + DynTypedMatcher BoundMatcher(Case.second.Matcher); + BoundMatcher.setAllowBind(true); + auto M = BoundMatcher.tryBind(Tag); Matchers.push_back(*std::move(M)); } return Matchers; |