}
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;
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) {
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;
}
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 << ", ";
}
}
}
- if (I->second->isVariadic())
+ if (Matcher->isVariadic())
OS << "...";
OS << ")";
- std::string TypedText = I->first();
+ std::string TypedText = Name;
TypedText += "(";
if (ArgsKinds.empty())
TypedText += ")";