This is an archive of the discontinued LLVM Phabricator instance.

[ASTMatchers] Add mapAnyOf matcher
ClosedPublic

Authored by steveire on Jan 5 2021, 3:31 PM.

Details

Summary

Make it possible to compose a matcher for different base nodes.

This accepts one or more node matcher functors and zero or more
matchers, composing the latter into the former.

This allows composing of matchers where the same inner matcher name is
used for the same concept, but with a different node functor. Currently,
there is a limitation that the nodes must be in the same "clade", so
while

mapAnyOf(ifStmt, forStmt).with(hasBody(stmt()))

can be used, functionDecl can not be added to the tuple.

It is possible to use this in clang-query, but it will require changes
to the QueryParser, so is deferred to a future review.

Diff Detail

Event Timeline

steveire requested review of this revision.Jan 5 2021, 3:31 PM
steveire created this revision.
Herald added a project: Restricted Project. · View Herald TranscriptJan 5 2021, 3:31 PM
Herald added a subscriber: cfe-commits. · View Herald Transcript

This is part of a series of commits. See them in context here: https://github.com/steveire/llvm-project/commits/mapAnyOf

This revision is now accepted and ready to land.Jan 11 2021, 6:53 AM
steveire updated this revision to Diff 316712.Jan 14 2021, 11:18 AM

Changed the implementation a bit to make clang-query integration easier

This revision was landed with ongoing or failed builds.Jan 16 2021, 4:53 AM
This revision was automatically updated to reflect the committed changes.