[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 13:20:00 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:

This is a check to make sure that on line 87, accessing the first parameter is valid. But now that I think about it, it might be unnecessary; are there cases where a template can have zero parameters?

https://github.com/llvm/llvm-project/pull/152938


More information about the cfe-commits mailing list