forked from OSchip/llvm-project
parent
15a63ed26e
commit
001f168e94
|
@ -358,11 +358,8 @@ RegistryMaps::RegistryMaps() {
|
|||
}
|
||||
|
||||
RegistryMaps::~RegistryMaps() {
|
||||
for (ConstructorMap::iterator it = Constructors.begin(),
|
||||
end = Constructors.end();
|
||||
it != end; ++it) {
|
||||
delete it->second;
|
||||
}
|
||||
for (auto &E : Constructors)
|
||||
delete E.getValue();
|
||||
}
|
||||
|
||||
static llvm::ManagedStatic<RegistryMaps> RegistryData;
|
||||
|
@ -433,12 +430,13 @@ Registry::getMatcherCompletions(ArrayRef<ArgKind> AcceptedTypes) {
|
|||
std::vector<MatcherCompletion> Completions;
|
||||
|
||||
// Search the registry for acceptable matchers.
|
||||
for (ConstructorMap::const_iterator I = RegistryData->constructors().begin(),
|
||||
E = RegistryData->constructors().end();
|
||||
I != E; ++I) {
|
||||
for (const auto &M : RegistryData->constructors()) {
|
||||
const auto *Matcher = M.getValue();
|
||||
StringRef Name = M.getKey();
|
||||
|
||||
std::set<ASTNodeKind> RetKinds;
|
||||
unsigned NumArgs = I->second->isVariadic() ? 1 : I->second->getNumArgs();
|
||||
bool IsPolymorphic = I->second->isPolymorphic();
|
||||
unsigned NumArgs = Matcher->isVariadic() ? 1 : Matcher->getNumArgs();
|
||||
bool IsPolymorphic = Matcher->isPolymorphic();
|
||||
std::vector<std::vector<ArgKind>> ArgsKinds(NumArgs);
|
||||
unsigned MaxSpecificity = 0;
|
||||
for (const ArgKind& Kind : AcceptedTypes) {
|
||||
|
@ -446,13 +444,13 @@ Registry::getMatcherCompletions(ArrayRef<ArgKind> AcceptedTypes) {
|
|||
continue;
|
||||
unsigned Specificity;
|
||||
ASTNodeKind LeastDerivedKind;
|
||||
if (I->second->isConvertibleTo(Kind.getMatcherKind(), &Specificity,
|
||||
&LeastDerivedKind)) {
|
||||
if (Matcher->isConvertibleTo(Kind.getMatcherKind(), &Specificity,
|
||||
&LeastDerivedKind)) {
|
||||
if (MaxSpecificity < Specificity)
|
||||
MaxSpecificity = Specificity;
|
||||
RetKinds.insert(LeastDerivedKind);
|
||||
for (unsigned Arg = 0; Arg != NumArgs; ++Arg)
|
||||
I->second->getArgKinds(Kind.getMatcherKind(), Arg, ArgsKinds[Arg]);
|
||||
Matcher->getArgKinds(Kind.getMatcherKind(), Arg, ArgsKinds[Arg]);
|
||||
if (IsPolymorphic)
|
||||
break;
|
||||
}
|
||||
|
@ -463,9 +461,9 @@ Registry::getMatcherCompletions(ArrayRef<ArgKind> AcceptedTypes) {
|
|||
llvm::raw_string_ostream OS(Decl);
|
||||
|
||||
if (IsPolymorphic) {
|
||||
OS << "Matcher<T> " << I->first() << "(Matcher<T>";
|
||||
OS << "Matcher<T> " << Name << "(Matcher<T>";
|
||||
} else {
|
||||
OS << "Matcher<" << RetKinds << "> " << I->first() << "(";
|
||||
OS << "Matcher<" << RetKinds << "> " << Name << "(";
|
||||
for (const std::vector<ArgKind> &Arg : ArgsKinds) {
|
||||
if (&Arg != &ArgsKinds[0])
|
||||
OS << ", ";
|
||||
|
@ -488,11 +486,11 @@ Registry::getMatcherCompletions(ArrayRef<ArgKind> AcceptedTypes) {
|
|||
}
|
||||
}
|
||||
}
|
||||
if (I->second->isVariadic())
|
||||
if (Matcher->isVariadic())
|
||||
OS << "...";
|
||||
OS << ")";
|
||||
|
||||
std::string TypedText = I->first();
|
||||
std::string TypedText = Name;
|
||||
TypedText += "(";
|
||||
if (ArgsKinds.empty())
|
||||
TypedText += ")";
|
||||
|
|
Loading…
Reference in New Issue