[PATCH] Add support for polymorphic matchers.

Samuel Benzaquen sbenza at google.com
Tue May 14 12:35:52 PDT 2013



================
Comment at: lib/ASTMatchers/Dynamic/DynMatchers.cpp:35
@@ +34,3 @@
+          ast_matchers::internal::BoundNodesTreeBuilder *Builder) const {
+    return M1->matches(DynNode, Finder, Builder) ||
+        M2->matches(DynNode, Finder, Builder);
----------------
Manuel Klimek wrote:
> How much harder would it be to not re-implement the matchers? I'd like to keep matcher implementations as cohesive as possible, as we want to be able to change the implementations when we introduce new features.
The ones that are easier to reimplement are the ones that are way too generic, like anything() or equals().

anything() returns a polymorphic matcher which is not a DynTypedMatcher.
I don't have specific Ts to create a Matcher<T> from anything(). I could list all possible types (the ones that DynTypedNode supports) and merge them, but it seemed to me that a reimplementation of it would be simpler.


http://llvm-reviews.chandlerc.com/D794



More information about the cfe-commits mailing list