[PATCH] D54307: [clang] overload ignoringParens for Expr

Aaron Ballman via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Nov 9 11:52:22 PST 2018


aaron.ballman accepted this revision.
aaron.ballman added a comment.
This revision is now accepted and ready to land.

LGTM!



================
Comment at: include/clang/ASTMatchers/ASTMatchers.h:814
 /// would match the declaration for fp.
-AST_MATCHER_P(QualType, ignoringParens,
-              internal::Matcher<QualType>, InnerMatcher) {
+AST_MATCHER_P_OVERLOAD(QualType, ignoringParens, internal::Matcher<QualType>,
+                       InnerMatcher, 0) {
----------------
sbenza wrote:
> JonasToth wrote:
> > aaron.ballman wrote:
> > > JonasToth wrote:
> > > > aaron.ballman wrote:
> > > > > Can you do this via `AST_POLYMORPHIC_MATCHER_P` instead, given that the implementation is the same?
> > > > Do you want me to add more types? e.g. `TypeLoc` has `IgnoreParens()`, too. 
> > > I'd not be opposed, given that we already expose the `typeLoc()` matcher. I'll leave that to your discretion.
> > as discussed on IRC making it an `AST_POLYMORPHIC_MATCHER_P` does not seem to work, as the polymorphism is only in the return type. We do need the `Node` itself to be polymorphic (same type as returntype). The only working version I got was using the overloads.
> You can't use AST_POLYMORPHIC_MATCHER_P to overload on input types.
> You could try using templates, but that will make registering the matcher harder.
> Another one that does input+output polymorphism, `id`, is simply not supported dynamically.
Good to know, thank you!


Repository:
  rC Clang

https://reviews.llvm.org/D54307





More information about the cfe-commits mailing list