r244792 - RangRangify some more for loops; NFC.

David Blaikie via cfe-commits cfe-commits at lists.llvm.org
Wed Aug 12 13:05:12 PDT 2015


On Wed, Aug 12, 2015 at 1:03 PM, Aaron Ballman <aaron at aaronballman.com>
wrote:

> On Wed, Aug 12, 2015 at 3:37 PM, David Blaikie <dblaikie at gmail.com> wrote:
> >
> >
> > On Wed, Aug 12, 2015 at 12:00 PM, Aaron Ballman via cfe-commits
> > <cfe-commits at lists.llvm.org> wrote:
> >>
> >> Author: aaronballman
> >> Date: Wed Aug 12 14:00:39 2015
> >> New Revision: 244792
> >>
> >> URL: http://llvm.org/viewvc/llvm-project?rev=244792&view=rev
> >> Log:
> >> RangRangify some more for loops; NFC.
> >>
> >> Modified:
> >>     cfe/trunk/lib/ASTMatchers/Dynamic/Registry.cpp
> >>
> >> Modified: cfe/trunk/lib/ASTMatchers/Dynamic/Registry.cpp
> >> URL:
> >>
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/ASTMatchers/Dynamic/Registry.cpp?rev=244792&r1=244791&r2=244792&view=diff
> >>
> >>
> ==============================================================================
> >> --- cfe/trunk/lib/ASTMatchers/Dynamic/Registry.cpp (original)
> >> +++ cfe/trunk/lib/ASTMatchers/Dynamic/Registry.cpp Wed Aug 12 14:00:39
> >> 2015
> >> @@ -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();
> >
> >
> > This looks like "DeleteContainerSeconds" (but even better if they could
> be
> > switched to unique_ptr)
>
> Ooh, I will switch to that. I tried to unique_ptr'ify the code, but
> it's... complicated.
>

:(


>
> ~Aaron
>
> >
> >>
> >>  }
> >>
> >>  static llvm::ManagedStatic<RegistryMaps> RegistryData;
> >> @@ -433,12 +430,13 @@ Registry::getMatcherCompletions(ArrayRef
> >>    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
> >>          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
> >>        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
> >>            }
> >>          }
> >>        }
> >> -      if (I->second->isVariadic())
> >> +      if (Matcher->isVariadic())
> >>          OS << "...";
> >>        OS << ")";
> >>
> >> -      std::string TypedText = I->first();
> >> +      std::string TypedText = Name;
> >>        TypedText += "(";
> >>        if (ArgsKinds.empty())
> >>          TypedText += ")";
> >>
> >>
> >> _______________________________________________
> >> cfe-commits mailing list
> >> cfe-commits at lists.llvm.org
> >> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
> >
> >
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20150812/a9764e55/attachment.html>


More information about the cfe-commits mailing list