This is an archive of the discontinued LLVM Phabricator instance.

[ASTMatchers] Always create a "binding" for the node being matched on.
Needs ReviewPublic

Authored by njames93 on Mar 2 2021, 10:27 AM.

Details

Summary

Most often when using matchers, there is a need to get the root node that the matcher matched on.
Currently the only way to do this is to manually create a binding the the root matcher, however this has some drawbacks.
It can be prone to typos and there is no universal agreed name to give the root node, so an API that accepts a DynTypedMatcher wont be able to figure out what the root actually is.

By altering the infrastructure to always provide access to the node being matched on, that isn't dependent on names, it can simplify workflow a lot.

Diff Detail

Event Timeline

njames93 created this revision.Mar 2 2021, 10:27 AM
Herald added a project: Restricted Project. · View Herald TranscriptMar 2 2021, 1:51 PM
Herald added a subscriber: cfe-commits. · View Herald Transcript

Can you add some tests for this?