sbenza created this revision. sbenza added a reviewer: alexfh. sbenza added a subscriber: cfe-commits.
Speedup the misc-static-assert check by not use `stmt()` as the toplevel matcher. The framework runs a filter on the matchers before trying them on each node and uses the toplevel type for this. Using `stmt()` as the toplevel causes the matcher to be run on every `Stmt` node, even if the node doesn't match the desired types. This change speeds up clang-tidy by ~5% in a benchmark. http://reviews.llvm.org/D19877 Files: clang-tidy/misc/StaticAssertCheck.cpp Index: clang-tidy/misc/StaticAssertCheck.cpp =================================================================== --- clang-tidy/misc/StaticAssertCheck.cpp +++ clang-tidy/misc/StaticAssertCheck.cpp @@ -62,11 +62,15 @@ hasArgument(0, AssertCondition))), AssertCondition); - Finder->addMatcher(stmt(anyOf(conditionalOperator(hasCondition(Condition)), - ifStmt(hasCondition(Condition))), - unless(isInTemplateInstantiation())) + Finder->addMatcher(conditionalOperator(hasCondition(Condition), + unless(isInTemplateInstantiation())) .bind("condStmt"), this); + + Finder->addMatcher( + ifStmt(hasCondition(Condition), unless(isInTemplateInstantiation())) + .bind("condStmt"), + this); } void StaticAssertCheck::check(const MatchFinder::MatchResult &Result) {
Index: clang-tidy/misc/StaticAssertCheck.cpp =================================================================== --- clang-tidy/misc/StaticAssertCheck.cpp +++ clang-tidy/misc/StaticAssertCheck.cpp @@ -62,11 +62,15 @@ hasArgument(0, AssertCondition))), AssertCondition); - Finder->addMatcher(stmt(anyOf(conditionalOperator(hasCondition(Condition)), - ifStmt(hasCondition(Condition))), - unless(isInTemplateInstantiation())) + Finder->addMatcher(conditionalOperator(hasCondition(Condition), + unless(isInTemplateInstantiation())) .bind("condStmt"), this); + + Finder->addMatcher( + ifStmt(hasCondition(Condition), unless(isInTemplateInstantiation())) + .bind("condStmt"), + this); } void StaticAssertCheck::check(const MatchFinder::MatchResult &Result) {
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits