diff options
author | Samuel Benzaquen <sbenza@google.com> | 2016-05-03 20:11:09 +0000 |
---|---|---|
committer | Samuel Benzaquen <sbenza@google.com> | 2016-05-03 20:11:09 +0000 |
commit | 4e05b82cc495a15dac4ce05ad1d2648ba3c739bc (patch) | |
tree | abafe757df576d40f9865c5911ea4e8503a42b3c /clang-tools-extra/clang-tidy/misc/StaticAssertCheck.cpp | |
parent | 296d12cd403fc1d813a145201f8369d5c068a5e4 (diff) | |
download | llvm-4e05b82cc495a15dac4ce05ad1d2648ba3c739bc.zip llvm-4e05b82cc495a15dac4ce05ad1d2648ba3c739bc.tar.gz llvm-4e05b82cc495a15dac4ce05ad1d2648ba3c739bc.tar.bz2 |
[clang-tidy] Speedup misc-static-assert.
Summary:
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.
Reviewers: alexfh
Subscribers: cfe-commits
Differential Revision: http://reviews.llvm.org/D19877
llvm-svn: 268430
Diffstat (limited to 'clang-tools-extra/clang-tidy/misc/StaticAssertCheck.cpp')
-rw-r--r-- | clang-tools-extra/clang-tidy/misc/StaticAssertCheck.cpp | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/clang-tools-extra/clang-tidy/misc/StaticAssertCheck.cpp b/clang-tools-extra/clang-tidy/misc/StaticAssertCheck.cpp index 2b08cd5..39eb7896 100644 --- a/clang-tools-extra/clang-tidy/misc/StaticAssertCheck.cpp +++ b/clang-tools-extra/clang-tidy/misc/StaticAssertCheck.cpp @@ -63,11 +63,15 @@ void StaticAssertCheck::registerMatchers(MatchFinder *Finder) { 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) { |