[PATCH] D117846: [ASTMatchers] Add `isConstinit` matcher
Evgeny Shulgin via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Thu Jan 20 16:38:21 PST 2022
Izaron added a comment.
I'm going to use this matcher very soon in my new `clang-tidy` check.
If you're interested and want to read more, I have a design document about my ne check - here (gist.github.com) <https://gist.github.com/Izaron/74b087007380a901714e8bd23f61fba2#initialized-constinit-object-that-is-const-qualified-and-has-constant-destruction-should-rather-be-constexpr> is the concrete check for `constinit` variables.
I think an ASTMatcher would be good, because:
1. As far I tried there is no way to get only `constinit` variables in `clang-query` (?)
2. The way to check in code if a variable is `constinit` is not quite obvious. A user may expect `Node.isConstinit()` (because `Node.isConstexpr()` works), but it's not working. The user has to examine AST and grep until they find `Node.hasAttr<ConstInitAttr>()`.
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
More information about the cfe-commits