diff options
author | Samuel Benzaquen <sbenza@google.com> | 2014-10-09 22:08:52 +0000 |
---|---|---|
committer | Samuel Benzaquen <sbenza@google.com> | 2014-10-09 22:08:52 +0000 |
commit | b63c251894521a4237a5e8e8a1babaa87191b3ba (patch) | |
tree | c9e90369af9544d2d7098ad7ed5997a32cccb6f9 /clang/lib/ASTMatchers/Dynamic/Registry.cpp | |
parent | b722e31906c52aa14749248bda5fc982ad3ff3fc (diff) | |
download | bcm5719-llvm-b63c251894521a4237a5e8e8a1babaa87191b3ba.tar.gz bcm5719-llvm-b63c251894521a4237a5e8e8a1babaa87191b3ba.zip |
Fix completion logic to allow for heterogeneous argument types in matcher overloads.
Summary:
There was an assumption that there were no matchers that were overloaded
on matchers and other types of arguments.
This assumption was broken recently with the addition of new matcher
overloads.
Fixes http://llvm.org/PR21226
Reviewers: pcc
Subscribers: klimek, cfe-commits
Differential Revision: http://reviews.llvm.org/D5711
llvm-svn: 219450
Diffstat (limited to 'clang/lib/ASTMatchers/Dynamic/Registry.cpp')
-rw-r--r-- | clang/lib/ASTMatchers/Dynamic/Registry.cpp | 25 |
1 files changed, 15 insertions, 10 deletions
diff --git a/clang/lib/ASTMatchers/Dynamic/Registry.cpp b/clang/lib/ASTMatchers/Dynamic/Registry.cpp index 5672169d3dc..b92e8ef6bf3 100644 --- a/clang/lib/ASTMatchers/Dynamic/Registry.cpp +++ b/clang/lib/ASTMatchers/Dynamic/Registry.cpp @@ -443,17 +443,22 @@ Registry::getMatcherCompletions(ArrayRef<ArgKind> AcceptedTypes) { for (const std::vector<ArgKind> &Arg : ArgsKinds) { if (&Arg != &ArgsKinds[0]) OS << ", "; - // This currently assumes that a matcher may not overload a - // non-matcher, and all non-matcher overloads have identical - // arguments. - if (Arg[0].getArgKind() == ArgKind::AK_Matcher) { - std::set<ASTNodeKind> MatcherKinds; - std::transform(Arg.begin(), Arg.end(), - std::inserter(MatcherKinds, MatcherKinds.end()), - std::mem_fun_ref(&ArgKind::getMatcherKind)); + + bool FirstArgKind = true; + std::set<ASTNodeKind> MatcherKinds; + // Two steps. First all non-matchers, then matchers only. + for (const ArgKind &AK : Arg) { + if (AK.getArgKind() == ArgKind::AK_Matcher) { + MatcherKinds.insert(AK.getMatcherKind()); + } else { + if (!FirstArgKind) OS << "|"; + FirstArgKind = false; + OS << AK.asString(); + } + } + if (!MatcherKinds.empty()) { + if (!FirstArgKind) OS << "|"; OS << "Matcher<" << MatcherKinds << ">"; - } else { - OS << Arg[0].asString(); } } } |