[cfe-commits] [PATCH] Implements hasAncestor.

Michael Diamond reviews at llvm-reviews.chandlerc.com
Thu Sep 6 13:07:52 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),
----------------
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.

================
Comment at: include/clang/ASTMatchers/ASTMatchersInternal.h:834
@@ +833,3 @@
+  TOOLING_COMPILE_ASSERT(IsBaseType<AncestorT>::value,
+                         has_descendant_only_accepts_base_type_matcher);
+public:
----------------
Copy/paste typo: has_ancestor, not has_descendant.


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



More information about the cfe-commits mailing list