ASTMatchers: isVirtual and isOverride

Ok, what I’m trying to do is not to repeat the same code again and again in different methods (process_matcher1(), process_matcher2()…) For example, matcher1 and matcher2 are treated in the same way except in a little part. At first, I thought of having a Decl* variable and casting the node result, but I’m not sure if this is a good option. Later, for instance, I need to use the getPreviousDecl() method that you told me and then I’ll have to know the class type (or maybe I can cast to Decl* again).


El dia 14 may 2013 20:15, Gábor Kozár escribió:

I don’t see the problem.
You’ll have one process(Decl*) method that does all the common stuff, and overloads for more specific types as needed, e.g. process(FunctionDecl*), which then call the Decl* overload by explicit casting. Have overload resolution work for you.