Skip to content

Commit 4ed5521

Browse files
committed
[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 llvm-svn: 368958
1 parent 10e3fa2 commit 4ed5521

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

clang/lib/Tooling/Refactoring/Transformer.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,8 +98,10 @@ static std::vector<DynTypedMatcher> taggedMatchers(
9898
Matchers.reserve(Cases.size());
9999
for (const auto &Case : Cases) {
100100
std::string Tag = (TagBase + Twine(Case.first)).str();
101-
auto M = Case.second.Matcher.tryBind(Tag);
102-
assert(M && "RewriteRule matchers should be bindable.");
101+
// HACK: Many matchers are not bindable, so ensure that tryBind will work.
102+
DynTypedMatcher BoundMatcher(Case.second.Matcher);
103+
BoundMatcher.setAllowBind(true);
104+
auto M = BoundMatcher.tryBind(Tag);
103105
Matchers.push_back(*std::move(M));
104106
}
105107
return Matchers;

0 commit comments

Comments
 (0)