Re: [PATCH] D49840: [AST] Add MatchFinder::matchSubtree

2018-08-27 Thread Manuel Klimek via cfe-commits
On Mon, Aug 6, 2018 at 4:47 PM Gabor Marton via Phabricator < revi...@reviews.llvm.org> wrote: > martong added a comment. > > Ping. > > Manuel, I still don't see how could we apply `match(anyOf(node), > hasDescendant(node))` to the problem of general subtree traversal. > (I'd like to have support

[PATCH] D49840: [AST] Add MatchFinder::matchSubtree

2018-08-06 Thread Gabor Marton via Phabricator via cfe-commits
martong added a comment. Ping. Manuel, I still don't see how could we apply `match(anyOf(node), hasDescendant(node))` to the problem of general subtree traversal. (I'd like to have support for not just `decl()` but other kind of nodes too.) Could you please advise how to move on? Also, could

Re: [PATCH] D49840: [AST] Add MatchFinder::matchSubtree

2018-07-30 Thread Manuel Klimek via cfe-commits
On Mon, Jul 30, 2018 at 10:02 AM Stephen Kelly via Phabricator < revi...@reviews.llvm.org> wrote: > steveire added a comment. > > In https://reviews.llvm.org/D49840#1176405, @klimek wrote: > > > Usually we use match(anyOf(node), hasDescendant(node)). Or did I > misunderstand what you want? > > >

[PATCH] D49840: [AST] Add MatchFinder::matchSubtree

2018-07-30 Thread Stephen Kelly via Phabricator via cfe-commits
steveire added a comment. In https://reviews.llvm.org/D49840#1176405, @klimek wrote: > Usually we use match(anyOf(node), hasDescendant(node)). Or did I > misunderstand what you want? See http://lists.llvm.org/pipermail/cfe-dev/2018-July/058625.html for a bug that prevents this working.

[PATCH] D49840: [AST] Add MatchFinder::matchSubtree

2018-07-27 Thread Gabor Marton via Phabricator via cfe-commits
martong added a comment. > If you know the node is a decl, wrapping it in decl() should be enough. > Does this work? > auto WrappedMatcher = decl(anyOf(...)); Unfortunately this gives again the private ctor error (the same error when I called explicitly the overload with the

Re: [PATCH] D49840: [AST] Add MatchFinder::matchSubtree

2018-07-27 Thread Manuel Klimek via cfe-commits
On Fri, Jul 27, 2018 at 12:43 PM Gabor Marton via Phabricator < revi...@reviews.llvm.org> wrote: > martong added a comment. > > > Finder.match also has an overload that takes the node. Can you wrap > "Pattern" above in the anyOf(hasDescendant(...), ...) and match on the node > instead of the full

[PATCH] D49840: [AST] Add MatchFinder::matchSubtree

2018-07-27 Thread Gabor Marton via Phabricator via cfe-commits
martong added a comment. > Finder.match also has an overload that takes the node. Can you wrap "Pattern" > above in the anyOf(hasDescendant(...), ...) and match on the node instead of > the full AST? Ok, I changed and wrapped the pattern: template NodeType *match(const Decl *D, const

Re: [PATCH] D49840: [AST] Add MatchFinder::matchSubtree

2018-07-27 Thread Manuel Klimek via cfe-commits
On Fri, Jul 27, 2018 at 10:39 AM Gabor Marton via Phabricator < revi...@reviews.llvm.org> wrote: > martong added a comment. > > > MatchFinder::match allows you to match a node. Wrapping your matcher > code with: > > auto m = ; > > ast_matchers::match(anyOf(m, hashDescendant(m)), node, context);

[PATCH] D49840: [AST] Add MatchFinder::matchSubtree

2018-07-27 Thread Gabor Marton via Phabricator via cfe-commits
martong added a comment. > MatchFinder::match allows you to match a node. Wrapping your matcher code > with: > auto m = ; > ast_matchers::match(anyOf(m, hashDescendant(m)), node, context); Okay, I understand and accept that. However, I consider that a different level of abstraction.

Re: [PATCH] D49840: [AST] Add MatchFinder::matchSubtree

2018-07-27 Thread Manuel Klimek via cfe-commits
On Thu, Jul 26, 2018 at 12:44 PM Gabor Marton via Phabricator < revi...@reviews.llvm.org> wrote: > martong added a comment. > > > Usually we use match(anyOf(node), hasDescendant(node)). Or did I > misunderstand what you want? > > My understanding is that, the free function template `match` uses >

[PATCH] D49840: [AST] Add MatchFinder::matchSubtree

2018-07-26 Thread Gabor Marton via Phabricator via cfe-commits
martong added a comment. > Usually we use match(anyOf(node), hasDescendant(node)). Or did I > misunderstand what you want? My understanding is that, the free function template `match` uses `MatchFinder::matchAST`, which will start the traverse from the TranslationUnitDecl. And there is no

[PATCH] D49840: [AST] Add MatchFinder::matchSubtree

2018-07-26 Thread Manuel Klimek via Phabricator via cfe-commits
klimek added a comment. Usually we use match(anyOf(node), hasDescendant(node)). Or did I misunderstand what you want? Repository: rC Clang https://reviews.llvm.org/D49840 ___ cfe-commits mailing list cfe-commits@lists.llvm.org

[PATCH] D49840: [AST] Add MatchFinder::matchSubtree

2018-07-26 Thread Gabor Marton via Phabricator via cfe-commits
martong created this revision. martong added reviewers: klimek, aprantl, pcc, sbenza, Prazek, dblaikie, balazske, xazax.hun. Herald added subscribers: cfe-commits, dkrupp, rnkovacs. Add matchSubtree, so we can traverse on a subtree rooted on a specific node. Currently, we can match **one** node