This is an archive of the discontinued LLVM Phabricator instance.

[ASTMatchers] Add own version of VariadicFunction.
ClosedPublic

Authored by sbenza on Mar 18 2016, 12:03 PM.

Details

Summary

llvm::VariadicFunction is only being used by ASTMatchers.
Having own copy here allows us to remove the other one from llvm/ADT.
Also, we can extend the API to our needs without modifying the common
implementation.

Diff Detail

Repository
rL LLVM

Event Timeline

sbenza updated this revision to Diff 51053.Mar 18 2016, 12:03 PM
sbenza retitled this revision from to [ASTMatchers] Add own version of VariadicFunction..
sbenza updated this object.
sbenza added a reviewer: alexfh.
sbenza added a subscriber: cfe-commits.

Alex, this is what we discussed to make hasAnyName take a vector<StringRef> directly.

alexfh accepted this revision.Mar 22 2016, 4:50 PM
alexfh edited edge metadata.

LG

include/clang/ASTMatchers/ASTMatchersInternal.h
80 ↗(On Diff #51053)

It's unfortunate that we need to create an array of the argument pointers here, but it seems there's no larger common denominator of the two ways this functions can be called.

One nit though: SmallVector will be a better container here.

This revision is now accepted and ready to land.Mar 22 2016, 4:50 PM
sbenza updated this revision to Diff 51447.Mar 23 2016, 11:01 AM
sbenza edited edge metadata.

Minor fix

include/clang/ASTMatchers/ASTMatchersInternal.h
80 ↗(On Diff #51053)

It's unfortunate that we need to create an array of the argument pointers here, but it seems there's no larger common denominator of the two ways this functions can be called.

Now that we control it, we can change it to be something different.
For example, instead of passing a function pointer as template parameter we could pass a class that contains overloaded operator() for both ArrayRef<T> and ArrayRef<const T*>.

On the other hand, constructing the matchers has never been the performance bottleneck of the framework.
They are usually created once and used thousands/millions of times.
Might not be worth it to optimize this too much.

One nit though: SmallVector will be a better container here.

Done.

Still LG.

include/clang/ASTMatchers/ASTMatchersInternal.h
82 ↗(On Diff #51447)

On the other hand, constructing the matchers has never been the performance bottleneck of the framework.

I was confused then. I thought, the operator() in question gets called when traversing the AST, not when constructing the matcher.

This revision was automatically updated to reflect the committed changes.

Any plan for doing the same for : hasOverloadedOperatorName ?