diff options
author | Daniel Jasper <djasper@google.com> | 2013-07-25 09:32:14 +0000 |
---|---|---|
committer | Daniel Jasper <djasper@google.com> | 2013-07-25 09:32:14 +0000 |
commit | abe2a36b7eeac46d1b9c0aabf616e68125dd329d (patch) | |
tree | e67904e9b7f761b89029beae1aa9e901d554530f /clang/lib/ASTMatchers/ASTMatchFinder.cpp | |
parent | 5b463ceaf5fc07201a866dc0cabf584b755f5804 (diff) | |
download | bcm5719-llvm-abe2a36b7eeac46d1b9c0aabf616e68125dd329d.tar.gz bcm5719-llvm-abe2a36b7eeac46d1b9c0aabf616e68125dd329d.zip |
Use memoization for has()-matcher.
In TUs with large classes, a matcher like
methodDecl(ofClass(recordDecl(has(varDecl()))))
(finding all member functions of classes with static variables)
becomes unbearably slow otherwise.
llvm-svn: 187115
Diffstat (limited to 'clang/lib/ASTMatchers/ASTMatchFinder.cpp')
-rw-r--r-- | clang/lib/ASTMatchers/ASTMatchFinder.cpp | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/clang/lib/ASTMatchers/ASTMatchFinder.cpp b/clang/lib/ASTMatchers/ASTMatchFinder.cpp index 9ed86177b7f..5dc67e17c97 100644 --- a/clang/lib/ASTMatchers/ASTMatchFinder.cpp +++ b/clang/lib/ASTMatchers/ASTMatchFinder.cpp @@ -419,8 +419,10 @@ public: BoundNodesTreeBuilder *Builder, TraversalKind Traversal, BindKind Bind) { - return matchesRecursively(Node, Matcher, Builder, 1, Traversal, - Bind); + if (ResultCache.size() > MaxMemoizationEntries) + ResultCache.clear(); + return memoizedMatchesRecursively(Node, Matcher, Builder, 1, Traversal, + Bind); } // Implements ASTMatchFinder::matchesDescendantOf. virtual bool matchesDescendantOf(const ast_type_traits::DynTypedNode &Node, |