This is hoisted from clang-tidy where it's used everywhere. The implementation
is not particularly efficient right now, but there is no easy fix for that.
Details
Diff Detail
Event Timeline
include/clang/ASTMatchers/ASTMatchers.h | ||
---|---|---|
2970–2982 | Perhaps add comment that this will not match if the node itself is a template instantiation (so functionDecl(isInTemplateInstantiation()) will not match anything here). I'd also add a comment about node sharing; for example, given stmt(unless(isInTemplateInstnatiation())) will not match j += 42 (because the template independent node is shared between the definition and the instantiations), but will match 'T i;' (with the dependent type), because the dependent nodes cannot be shared. Of course: stmt(isInTemplateInstnatiation()) will match all. | |
2980 | Also matches the block '{ T i; }'. |
include/clang/ASTMatchers/ASTMatchers.h | ||
---|---|---|
2970–2982 |
Maybe add a separate version for decl, which will handle this? Something along the lines of: auto IsInstantiation = decl(anyOf(recordDecl(isTemplateInstantiation()), functionDecl(isTemplateInstantiation()))); auto InnerMatcher = decl(anyOf(isInstantiation, hasAncestor(isInstantiation)); |
Split into two matchers, one for Decl (also matches itself) and one for Stmt.
Update tests and document node sharing artifacts.
include/clang/ASTMatchers/ASTMatchers.h | ||
---|---|---|
2970 | I find this comment somewhat hard to understand. I'd say that this matches declarations that are template instantiations or are inside template instantiations. | |
2998 | Did you mean isInTemplateInstantiation (here and below)? | |
lib/ASTMatchers/Dynamic/Registry.cpp | ||
246 | Why do you register only one matcher? |
I find this comment somewhat hard to understand. I'd say that this matches declarations that are template instantiations or are inside template instantiations.