RangRangify some more for loops; NFC.

llvm-svn: 244792
This commit is contained in:
Aaron Ballman 2015-08-12 19:00:39 +00:00
parent 15a63ed26e
commit 001f168e94
1 changed files with 15 additions and 17 deletions

View File

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