[PATCH] Refactor Matcher<T> and DynTypedMatcher to reduce overhead of casts.

Samuel Benzaquen sbenza at google.com
Thu Sep 25 06:18:14 PDT 2014


fyi, I think this breaks memoization. The ID is now not enough to uniquely identify a matcher. The RestrictKind should also be part of it.
I will investigate before submitting this change.

================
Comment at: lib/ASTMatchers/ASTMatchersInternal.cpp:54-60
@@ +53,9 @@
+
+  bool matches(const ast_type_traits::DynTypedNode &DynNode,
+               ASTMatchFinder *Finder,
+               BoundNodesTreeBuilder *Builder) const override {
+    bool Result = InnerMatcher->matches(DynNode, Finder, Builder);
+    if (Result) Builder->setBinding(ID, DynNode);
+    return Result;
+  }
+
----------------
klimek wrote:
> Can we somehow put this implementation and the IdMatcher implementation closer together? I'm concerned if somebody changes one and the other breaks.
My plan is to refector all template matcher that do not need the type into DynMatcherInterface. That includes IdMatcher, TrueMatcher, VariadicOperator, etc.
I did not do it on this change to limit the scope. Added some FIXME for them, though.

http://reviews.llvm.org/D5485






More information about the cfe-commits mailing list