From 001f168e94edeed9521bf5383bf6b9ca60277bb0 Mon Sep 17 00:00:00 2001 From: Aaron Ballman Date: Wed, 12 Aug 2015 19:00:39 +0000 Subject: [PATCH] RangRangify some more for loops; NFC. llvm-svn: 244792 --- clang/lib/ASTMatchers/Dynamic/Registry.cpp | 32 ++++++++++++++---------------- 1 file changed, 15 insertions(+), 17 deletions(-) diff --git a/clang/lib/ASTMatchers/Dynamic/Registry.cpp b/clang/lib/ASTMatchers/Dynamic/Registry.cpp index be04ed4..9c8fa1c 100644 --- a/clang/lib/ASTMatchers/Dynamic/Registry.cpp +++ b/clang/lib/ASTMatchers/Dynamic/Registry.cpp @@ -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 RegistryData; @@ -433,12 +430,13 @@ Registry::getMatcherCompletions(ArrayRef AcceptedTypes) { std::vector 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 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> ArgsKinds(NumArgs); unsigned MaxSpecificity = 0; for (const ArgKind& Kind : AcceptedTypes) { @@ -446,13 +444,13 @@ Registry::getMatcherCompletions(ArrayRef 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 AcceptedTypes) { llvm::raw_string_ostream OS(Decl); if (IsPolymorphic) { - OS << "Matcher " << I->first() << "(Matcher"; + OS << "Matcher " << Name << "(Matcher"; } else { - OS << "Matcher<" << RetKinds << "> " << I->first() << "("; + OS << "Matcher<" << RetKinds << "> " << Name << "("; for (const std::vector &Arg : ArgsKinds) { if (&Arg != &ArgsKinds[0]) OS << ", "; @@ -488,11 +486,11 @@ Registry::getMatcherCompletions(ArrayRef AcceptedTypes) { } } } - if (I->second->isVariadic()) + if (Matcher->isVariadic()) OS << "..."; OS << ")"; - std::string TypedText = I->first(); + std::string TypedText = Name; TypedText += "("; if (ArgsKinds.empty()) TypedText += ")"; -- 2.7.4