[clang] [clang] CTAD: implement the missing IsDeducible constraint for alias templates (PR #89358)

via cfe-commits cfe-commits at lists.llvm.org
Wed May 8 01:14:51 PDT 2024


================
@@ -6116,6 +6116,17 @@ static bool EvaluateBinaryTypeTrait(Sema &Self, TypeTrait BTT, const TypeSourceI
                               tok::kw___is_pointer_interconvertible_base_of);
 
     return Self.IsPointerInterconvertibleBaseOf(Lhs, Rhs);
+  }
+  case BTT_IsDeducible: {
+    if (const auto *TSTToBeDeduced =
+            LhsT->getAs<DeducedTemplateSpecializationType>()) {
+      sema::TemplateDeductionInfo Info(KeyLoc);
+      return Self.DeduceTemplateArgumentsFromType(
+                 TSTToBeDeduced->getTemplateName().getAsTemplateDecl(), RhsT,
+                 Info) == TemplateDeductionResult::Success;
+    }
+    assert("Expect to see DeducedTemplateSpecializationType!");
----------------
cor3ntin wrote:

that is always true (you probably mean `false && ""`).
But I would remove the `if`, use `cast<DeducedTemplateSpecializationType>(LhsT)` that will assert for you)

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


More information about the cfe-commits mailing list