]> granicus.if.org Git - clang/commitdiff
RangRangify some more for loops; NFC.
authorAaron Ballman <aaron@aaronballman.com>
Wed, 12 Aug 2015 19:00:39 +0000 (19:00 +0000)
committerAaron Ballman <aaron@aaronballman.com>
Wed, 12 Aug 2015 19:00:39 +0000 (19:00 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@244792 91177308-0d34-0410-b5e6-96231b3b80d8

lib/ASTMatchers/Dynamic/Registry.cpp

index be04ed476333e42643fc0e14fe0e91f7e627087f..9c8fa1c9f502f8196521e13c28eba3230efe4cbf 100644 (file)
@@ -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 += ")";