[PATCH] Rewrite eachOf/allOf/anyOf to use a variadic operator.

Manuel Klimek klimek at google.com
Fri Aug 16 13:53:16 PDT 2013


On Fri, Aug 16, 2013 at 10:48 PM, Samuel Benzaquen <sbenza at google.com>wrote:

>
>   The reason I can't see this implemented using llvm::VariadicFunction is
> that *Of() has arbitrary arguments, than then get converted into Matcher<T>
> when the variadic is bound on the outer matcher.
>   llvm::VariadicFunction needs one specific type on its declaration.
>   Some of the arguments might not even be Matcher<*> (eg could be another
> polymorphic object) so we can't make it a variadic function on const
> DynTypedMatcher&.
>

In the C++ code this is afaik not possible, as *Of returns a
return-type-deduction object, and return-type-deduction never works through
two layers. So I think we should be able to use DynTypedMatcher (and I'd
have implemented *Of with it if it had existed back in the day ;)


>   I am willing to simplify/merge the logic if you see a way.
>
>
> ================
> Comment at: lib/ASTMatchers/ASTMatchersInternal.cpp:61
> @@ +60,3 @@
> +    BoundNodesTreeBuilder BuilderI(*Builder);
> +    bool MatchedI = InnerMatchers[i]->matches(DynNode, Finder, &BuilderI);
> +    if (MatchedI) {
> ----------------
> Manuel Klimek wrote:
> > Any reason to have this variable pulled out?
> It was out on the previous implementation, but I don't need it anymore so
> its gone.
>
> ================
> Comment at: lib/ASTMatchers/ASTMatchersInternal.cpp:60
> @@ +59,3 @@
> +  for (size_t i = 0, e = InnerMatchers.size(); i != e; ++i) {
> +    BoundNodesTreeBuilder BuilderI(*Builder);
> +    bool MatchedI = InnerMatchers[i]->matches(DynNode, Finder, &BuilderI);
> ----------------
> Manuel Klimek wrote:
> > I assume "I" stands for "Inner"? I'd rather type that out ;) (here and
> below)
> Done.
>
>
> http://llvm-reviews.chandlerc.com/D1427
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20130816/397c673e/attachment.html>


More information about the cfe-commits mailing list