[PATCH] Refactor VariantMatcher to use a tagged union.

Samuel Benzaquen sbenza at google.com
Wed Aug 21 07:40:01 PDT 2013

Comment at: include/clang/ASTMatchers/Dynamic/VariantValue.h:140
@@ +139,3 @@
+  };
+  union {
+    SingleRep *AsSingle;
Manuel Klimek wrote:
> Any reason not to use an interface with two implementations? This smells a lot like building our own inheritance implementation ...
These two could hide behind an interface, but I don't know how the interface would work for the variadic case coming next (from D1427).
The basic idea for that one is that on getTypedMatcher<T> it will convert all the inner matchers to Matcher<T>, then create a VariadicOperatorMatcherInterface<T> with them and return it.
If I try to use interfaces, I will need two: one for the payload of the matcher, and one for the operations from <T>. It can be done, but it might be messier.
I'll give it a try to see how it looks.


More information about the cfe-commits mailing list