[clang-tools-extra] [clang-tidy] Fix `modernize-use-constraints` crash on uses of nonstandard `enable_if`s (PR #152938)
Victor Chernyakin via cfe-commits
cfe-commits at lists.llvm.org
Sun Aug 10 15:17:09 PDT 2025
================
@@ -78,6 +79,15 @@ matchEnableIfSpecializationImplTypename(TypeLoc TheType) {
if (!TD || TD->getName() != "enable_if")
return std::nullopt;
+ const TemplateParameterList *Params = TD->getTemplateParameters();
+ if (Params->size() != 2)
+ return std::nullopt;
----------------
localspook wrote:
It looks like specializations of different kinds are represented in the AST as:
- `FunctionDecl`
- `VarTemplatePartialSpecializationDecl`
- `VarTemplateSpecializationDecl`
- `ClassTemplatePartialSpecializationDecl`
- `ClassTemplateSpecializationDecl`
None of those are subclasses of `TemplateDecl`. That means they wouldn't get past the `getAsTemplateDecl()` check above, so I'm hesitantly removing this check.
https://godbolt.org/z/PqeMe3fsx
https://github.com/llvm/llvm-project/pull/152938
More information about the cfe-commits
mailing list