This is an archive of the discontinued LLVM Phabricator instance.

Filter the toplevel matchers by kind.
ClosedPublic

Authored by sbenza on Nov 21 2014, 12:41 PM.

Details

Summary

Filter the toplevel matchers by kind.
Decl and Stmt matchers are tied to a specific node kind and trying to
match incompatible nodes is a waste.
Precalculate a filtered list of matchers that have a chance of matching
the node and ignore the rest.
Speeds up our clang-tidy benchmark by ~10%

Diff Detail

Event Timeline

sbenza updated this revision to Diff 16506.Nov 21 2014, 12:41 PM
sbenza retitled this revision from to Filter the toplevel matchers by kind..
sbenza updated this object.
sbenza edited the test plan for this revision. (Show Details)
sbenza added a reviewer: klimek.
sbenza added a subscriber: Unknown Object (MLST).
klimek added inline comments.Nov 21 2014, 1:01 PM
include/clang/AST/ASTTypeTraits.h
393–395

Is all that whitespace intentional?

include/clang/ASTMatchers/ASTMatchersInternal.h
292–295

Either \c both false and true, or none :)

309–311

I'd spend the extra 6 characters and call it matchesWithoutKindCheck.

lib/ASTMatchers/ASTMatchersInternal.cpp
187–191

Shouldn't every matcher already do that?

sbenza updated this revision to Diff 16509.Nov 21 2014, 1:55 PM

Minor fixes

include/clang/AST/ASTTypeTraits.h
393–395

Not really. Fixed.

include/clang/ASTMatchers/ASTMatchersInternal.h
292–295

\c ALL the keywords!

309–311

What about SkipKindCheck ?

lib/ASTMatchers/ASTMatchersInternal.cpp
187–191

Do what? Delete the bindings?
This is where it happens, right?
The MatcherInterface implementations don't delete anything.

I pretty much copied matches() and modified it. That stayed the same.

klimek accepted this revision.Nov 24 2014, 1:52 AM
klimek edited edge metadata.

LG (as the only question I have is basically unrelated to this patch), but I'd still like to get to the bottom of the question...

lib/ASTMatchers/ASTMatchersInternal.cpp
187–191

Hm, curious - does that actually make a difference in any test if we remove it (both here and in matches)?

This revision is now accepted and ready to land.Nov 24 2014, 1:52 AM
sbenza added inline comments.Nov 24 2014, 1:04 PM
lib/ASTMatchers/ASTMatchersInternal.cpp
187–191

Removing this doesn't affect the tests.
The callers should already be ignoring the contents Builder if matches() return false.
This is here as a protection in case some caller doesn't ignore it.

sbenza closed this revision.Nov 24 2014, 1:21 PM
sbenza updated this revision to Diff 16578.

Closed by commit rL222688 (authored by @sbenza).