[cfe-commits] [PATCH] Implements hasAncestor.

Michael Diamond reviews at llvm-reviews.chandlerc.com
Thu Sep 6 13:59:46 PDT 2012



================
Comment at: include/clang/ASTMatchers/ASTMatchersInternal.h:461
@@ +460,3 @@
+                            llvm::is_base_of<Stmt, T>::value),
+                           only_Decl_or_Stmt_allowed_for_recursive_matching);
+    return matchesAncestorOf(ast_type_traits::DynTypedNode::create(Node),
----------------
Daniel Jasper wrote:
> Michael Diamond wrote:
> > Manuel Klimek wrote:
> > > Daniel Jasper wrote:
> > > > Unlike descendants, all node types should have ancestors. Is it intentional to not allow this for QualTypes or possibly other types? 
> > > > - If there is a good reason for it: Comment.
> > > > - If it would be significant additional work: Command + FIXME
> > > > - Otherwise: Implement ;-)
> > > Like with the other methods here, there are many more nodes for which we want them implemented than are currently implemented.
> > > 
> > > You're right that for hasAncestor probably pretty much all nodes make sense. Added a class-level comment that outlines the differences.
> > I really need this to work for QualTypes. Any chance of getting that in this CL? We don't have to update both ancestor and child matchers together necessarily.
> Could you quickly elaborate on what you are in need of matching? This is actually not quite as easy (from a design perspective) and I think it should be in a different patch. But maybe we can find a way around it :-).
If it has to hold of to another patch, alright, but I need it ASAP. :)

Basically, I am refactoring from using one class to using a parent of it. However, for references and pointers, I want to use an interface that is a parent of that class.

Example:
Interface
  |
Parent
  |
CurrentClass

I want "CurrentClass*" to become "Interface*", but "new CurrentClass" to become "new Parent".


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



More information about the cfe-commits mailing list