Page MenuHomePhabricator

[ASTMatchers] proof-of-concept: allow matching within a restricted scope.
AbandonedPublic

Authored by sammccall on Nov 8 2018, 7:00 AM.

Details

Reviewers
shafik
Summary

Tools may want to match only within e.g. the main file.
We can run the matcher only over those "top-level decls" but if it "escapes"
e.g. using the hasAncestor() matcher, then all bets are off.
In fact, any use of hasAncestor() or hasParent() will cause us to pay O(|TU|) in
performance to build the parent map, which is unacceptably bad for clangd.

The approach taken here is to restrict the parent map to only include edges
reachable from the top-level decls.
We create a "bounds" object wrapping the decls, and store the parent map cache
in it. This object must be plumbed around manually.

Not asking for review and probably won't in this form, too much plumbing.
Sadly, the better option is probably to make this a mutable attribute of
ASTContext.

Diff Detail