[PATCH] D65877: [libTooling] In Transformer, generalize `applyFirst` to admit rules with incompatible matchers.
Yitzhak Mandelbaum via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Mon Aug 12 10:45:09 PDT 2019
ymandel marked 2 inline comments as done.
ymandel added a comment.
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. 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?
================
Comment at: clang/lib/Tooling/Refactoring/Transformer.cpp:127
+ // in `taggedMatchers`.
+ std::map<ASTNodeKind, SmallVector<std::pair<size_t, RewriteRule::Case>, 1>>
+ Buckets;
----------------
gribozavr wrote:
> `unordered_map`?
fails because `ASTNodeKind` doesn't have a hash function. Which is odd since there's an obvious one we could define, but doesn't seem worth doing just for here.
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