A suggestion and questions about ASTMatchers

Question 1:

Would it be possible to have hasParameter(unsigned N,…), hasArgument(unsigned N,…), hasTemplateArgument(unsigned N,…) etc
to take signed integer N as an argument and use negative values to address the parameters, arguments etc from the right hand side of the list?

Or is there another way to explicitly match on the last or second last parameter, argument etc if I don’t know how many entries are available for a particular node?

Question 2:
When reading the documentation at http://clang.llvm.org/docs/LibASTMatchersReference.html

What does it mean in the AST Traversal Matchers when the Parameters are "Matcher<Type>" vs "Matcher<Expr> InnerMatcher”?
What does the “InnerMatcher” part refer to - if this is anything other than the matcher argument that you put inside the parentheses as an argument. If all it means is the argument then why does “hasElementType” have the parameter “Matcher<Type>”?

Sorry if question 2 is not very clear, perhaps I’m reading too much into what is written in the parameter column of each matcher.

Best,

.Chris.

Christian Schafmeister
chris.schaf@verizon.net

Question 1:

Would it be possible to have hasParameter(unsigned N,…),
hasArgument(unsigned N,…), hasTemplateArgument(unsigned N,…) etc
to take signed integer N as an argument and use negative values to address
the parameters, arguments etc from the right hand side of the list?

It most certainly would...

Or is there another way to explicitly match on the last or second last
parameter, argument etc if I don’t know how many entries are available for
a particular node?

Nope. You can of course always match "any" (and bind it) and then use the
callback to figure out which one it was.

Question 2:
When reading the documentation at
http://clang.llvm.org/docs/LibASTMatchersReference.html

What does it mean in the AST Traversal Matchers when the Parameters are
"Matcher<Type>" vs "Matcher<Expr> InnerMatcher”?
What does the “InnerMatcher” part refer to - if this is anything other
than the matcher argument that you put inside the parentheses as an
argument. If all it means is the argument then why does “hasElementType”
have the parameter “Matcher<Type>”?

Yes, I think it's pretty much what you're saying :slight_smile: