[cfe-dev] match OffsetOfExpr

Aaron Ballman via cfe-dev cfe-dev at lists.llvm.org
Fri Aug 14 03:30:39 PDT 2020


On Fri, Aug 14, 2020 at 6:11 AM Bruno Ricci via cfe-dev
<cfe-dev at lists.llvm.org> wrote:
> On 14/08/2020 10:35, Billy Araujo via cfe-dev wrote:
> > Hi,
> >
> > I don't know how it should be matched, using classOf, dyn_cast, or isa.
> >
> > I tried:
> >
> > namespace
> > {
> >     AST_MATCHER(clang::Stmt, isOffsetOf) { return clang::isa<clang::OffsetOfExpr>(&Node); }
> > }
> >
> > and still doesn't match.
> >
>
> You can use a VariadicDynCastAllOfMatcher<Stmt, OffsetOfExpr> like the other matchers
> for statements/expressions. That said, why are we manually adding matchers for each nodes?
> It seems to me that they could be auto-generated from the statement/declaration/type databases.

Each matcher we add increases the compile time overhead due to the
template instantiations involved, so we typically only add global
matchers where there's an expressed need for one rather than try to
add matchers for the entire AST automatically. That said, for node
matchers, I wonder how far off we are from supporting all node types
already (like, do we need 10 matchers? 100?). If we're only missing a
handful, then it might sense to consider auto-generating them all at
this point (and shifting the concern to traversal or narrowing
matchers), depending on how many we're missing.

~Aaron

>
> ~Bruno
>
>
> _______________________________________________
> cfe-dev mailing list
> cfe-dev at lists.llvm.org
> https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev


More information about the cfe-dev mailing list