[PATCH] D88275: [ASTMatchers] Add matcher `hasParentIgnoringImplicit`.

Yitzhak Mandelbaum via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Sep 25 10:40:59 PDT 2020


ymandel added a comment.

In D88275#2295379 <https://reviews.llvm.org/D88275#2295379>, @aaron.ballman wrote:

> This seems to be strongly related to the `TK_IgnoreUnlessSpelledInSource` traversal behavior; is there a reason you can't use that traversal mode with `hasParent()` (does it behave differently)?

Aaron, that's a good point.  I hadn't realized that the traversal mode supported parent traversal. That said, even with it available, I have strong reservations about modal matching, especially given that it had severe issues when `TK_IgnoreUnlessSpelledInSource` went live a few months ago as the default setting. I don't know what the resolution of those discussions were, but I thought we simply agreed to restore the default, and left fixing the underlying issues as future work.

But, even it if worked as desired, to achieve the same effect, you would have to restore the current mode as well once you're reached your desired destination. e.g. inspired by the tests, given some matcher `m`,

  integerLiteral(hasParentIgnoringImplicit(varDecl(m)))

becomes

  integerLiteral(traversal(TK_IgnoreUnlessSpelledInSource, hasParent(varDecl(traversal(TK_AsIs, m)))))

which seems a lot worse to me. We could however implement this new one in terms of `traverse`, but that would go back to the question of whether it is working correctly and also gets somewhat tricky (specifically, restoring the ambient traversal mode).  Do you know the current status?

thanks


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D88275/new/

https://reviews.llvm.org/D88275



More information about the cfe-commits mailing list