<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Aug 12, 2015 at 1:03 PM, Aaron Ballman <span dir="ltr"><<a href="mailto:aaron@aaronballman.com" target="_blank">aaron@aaronballman.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="HOEnZb"><div class="h5">On Wed, Aug 12, 2015 at 3:37 PM, David Blaikie <<a href="mailto:dblaikie@gmail.com">dblaikie@gmail.com</a>> wrote:<br>
><br>
><br>
> On Wed, Aug 12, 2015 at 12:00 PM, Aaron Ballman via cfe-commits<br>
> <<a href="mailto:cfe-commits@lists.llvm.org">cfe-commits@lists.llvm.org</a>> wrote:<br>
>><br>
>> Author: aaronballman<br>
>> Date: Wed Aug 12 14:00:39 2015<br>
>> New Revision: 244792<br>
>><br>
>> URL: <a href="http://llvm.org/viewvc/llvm-project?rev=244792&view=rev" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project?rev=244792&view=rev</a><br>
>> Log:<br>
>> RangRangify some more for loops; NFC.<br>
>><br>
>> Modified:<br>
>>     cfe/trunk/lib/ASTMatchers/Dynamic/Registry.cpp<br>
>><br>
>> Modified: cfe/trunk/lib/ASTMatchers/Dynamic/Registry.cpp<br>
>> URL:<br>
>> <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/ASTMatchers/Dynamic/Registry.cpp?rev=244792&r1=244791&r2=244792&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/ASTMatchers/Dynamic/Registry.cpp?rev=244792&r1=244791&r2=244792&view=diff</a><br>
>><br>
>> ==============================================================================<br>
>> --- cfe/trunk/lib/ASTMatchers/Dynamic/Registry.cpp (original)<br>
>> +++ cfe/trunk/lib/ASTMatchers/Dynamic/Registry.cpp Wed Aug 12 14:00:39<br>
>> 2015<br>
>> @@ -358,11 +358,8 @@ RegistryMaps::RegistryMaps() {<br>
>>  }<br>
>><br>
>>  RegistryMaps::~RegistryMaps() {<br>
>> -  for (ConstructorMap::iterator it = Constructors.begin(),<br>
>> -                                end = Constructors.end();<br>
>> -       it != end; ++it) {<br>
>> -    delete it->second;<br>
>> -  }<br>
>> +  for (auto &E : Constructors)<br>
>> +    delete E.getValue();<br>
><br>
><br>
> This looks like "DeleteContainerSeconds" (but even better if they could be<br>
> switched to unique_ptr)<br>
<br>
</div></div>Ooh, I will switch to that. I tried to unique_ptr'ify the code, but<br>
it's... complicated.<br></blockquote><div><br>:(<br> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<span class="HOEnZb"><font color="#888888"><br>
~Aaron<br>
</font></span><div class="HOEnZb"><div class="h5"><br>
><br>
>><br>
>>  }<br>
>><br>
>>  static llvm::ManagedStatic<RegistryMaps> RegistryData;<br>
>> @@ -433,12 +430,13 @@ Registry::getMatcherCompletions(ArrayRef<br>
>>    std::vector<MatcherCompletion> Completions;<br>
>><br>
>>    // Search the registry for acceptable matchers.<br>
>> -  for (ConstructorMap::const_iterator I =<br>
>> RegistryData->constructors().begin(),<br>
>> -                                      E =<br>
>> RegistryData->constructors().end();<br>
>> -       I != E; ++I) {<br>
>> +  for (const auto &M : RegistryData->constructors()) {<br>
>> +    const auto *Matcher = M.getValue();<br>
>> +    StringRef Name = M.getKey();<br>
>> +<br>
>>      std::set<ASTNodeKind> RetKinds;<br>
>> -    unsigned NumArgs = I->second->isVariadic() ? 1 :<br>
>> I->second->getNumArgs();<br>
>> -    bool IsPolymorphic = I->second->isPolymorphic();<br>
>> +    unsigned NumArgs = Matcher->isVariadic() ? 1 : Matcher->getNumArgs();<br>
>> +    bool IsPolymorphic = Matcher->isPolymorphic();<br>
>>      std::vector<std::vector<ArgKind>> ArgsKinds(NumArgs);<br>
>>      unsigned MaxSpecificity = 0;<br>
>>      for (const ArgKind& Kind : AcceptedTypes) {<br>
>> @@ -446,13 +444,13 @@ Registry::getMatcherCompletions(ArrayRef<br>
>>          continue;<br>
>>        unsigned Specificity;<br>
>>        ASTNodeKind LeastDerivedKind;<br>
>> -      if (I->second->isConvertibleTo(Kind.getMatcherKind(), &Specificity,<br>
>> -                                     &LeastDerivedKind)) {<br>
>> +      if (Matcher->isConvertibleTo(Kind.getMatcherKind(), &Specificity,<br>
>> +                                   &LeastDerivedKind)) {<br>
>>          if (MaxSpecificity < Specificity)<br>
>>            MaxSpecificity = Specificity;<br>
>>          RetKinds.insert(LeastDerivedKind);<br>
>>          for (unsigned Arg = 0; Arg != NumArgs; ++Arg)<br>
>> -          I->second->getArgKinds(Kind.getMatcherKind(), Arg,<br>
>> ArgsKinds[Arg]);<br>
>> +          Matcher->getArgKinds(Kind.getMatcherKind(), Arg,<br>
>> ArgsKinds[Arg]);<br>
>>          if (IsPolymorphic)<br>
>>            break;<br>
>>        }<br>
>> @@ -463,9 +461,9 @@ Registry::getMatcherCompletions(ArrayRef<br>
>>        llvm::raw_string_ostream OS(Decl);<br>
>><br>
>>        if (IsPolymorphic) {<br>
>> -        OS << "Matcher<T> " << I->first() << "(Matcher<T>";<br>
>> +        OS << "Matcher<T> " << Name << "(Matcher<T>";<br>
>>        } else {<br>
>> -        OS << "Matcher<" << RetKinds << "> " << I->first() << "(";<br>
>> +        OS << "Matcher<" << RetKinds << "> " << Name << "(";<br>
>>          for (const std::vector<ArgKind> &Arg : ArgsKinds) {<br>
>>            if (&Arg != &ArgsKinds[0])<br>
>>              OS << ", ";<br>
>> @@ -488,11 +486,11 @@ Registry::getMatcherCompletions(ArrayRef<br>
>>            }<br>
>>          }<br>
>>        }<br>
>> -      if (I->second->isVariadic())<br>
>> +      if (Matcher->isVariadic())<br>
>>          OS << "...";<br>
>>        OS << ")";<br>
>><br>
>> -      std::string TypedText = I->first();<br>
>> +      std::string TypedText = Name;<br>
>>        TypedText += "(";<br>
>>        if (ArgsKinds.empty())<br>
>>          TypedText += ")";<br>
>><br>
>><br>
>> _______________________________________________<br>
>> cfe-commits mailing list<br>
>> <a href="mailto:cfe-commits@lists.llvm.org">cfe-commits@lists.llvm.org</a><br>
>> <a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits</a><br>
><br>
><br>
</div></div></blockquote></div><br></div></div>