[PATCH] D65877: [libTooling] In Transformer, generalize `applyFirst` to admit rules with incompatible matchers.

Dmitri Gribenko via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Aug 12 11:27:49 PDT 2019


gribozavr added a comment.

In D65877#1625493 <https://reviews.llvm.org/D65877#1625493>, @ymandel wrote:

> I was going to add a test for `Type`/`QualType` and realized that they don't carry any source location info.  Therefore, I don't think they belong as top-level matchers for rewrite rules.


Agreed.

> Instead, users should use `typeLoc(loc(<type matcher here>)`.  Therefore, the logic of `getKind` can be eliminated in favor of using `K.getSupportedKind()` directly.  However, that means we'll need to keep them out of the collection of matchers that we're processing.
> 
> For that, I propose either we ban them in `buildMatchers()` or we detect them and wrap them in `typeLoc(loc(<type matcher here>)`. I'm fine with either one, but prefer the latter. WDYT?

I'd prefer we ban them completely, and let the user wrap them manually if they need to. While some users would appreciate the ergonomics, I think AST matchers are complicated even without us adding more implicit behavior on top.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D65877





More information about the cfe-commits mailing list