[clang] [clang-tools-extra] [llvm] [Clang] Add __builtin_type_pack_dedup template to deduplicate types in template arguments (PR #106730)

Matheus Izvekov via cfe-commits cfe-commits at lists.llvm.org
Tue Sep 17 21:00:02 PDT 2024


================
@@ -3158,6 +3161,33 @@ checkBuiltinTemplateIdType(Sema &SemaRef, BuiltinTemplateDecl *BTD,
     int64_t N = Index.getExtValue();
     return Ts.getPackAsArray()[N].getAsType();
   }
+  case BTK__type_pack_dedup: {
+    assert(Converted.size() == 2 && "__builtin_type_pack_dedup should be given "
+                                    "a template and a parameter pack");
+    TemplateArgument Template = Converted[0];
+    TemplateArgument Ts = Converted[1];
+    if (Template.isDependent() || Ts.isDependent())
----------------
mizvekov wrote:

I think the only reason we would need to hold off on building the template specialization would be if Ts contains an unexpanded pack, otherwise we are good to go, subsequent substitutions will produce the correct type list anyway.

This would also reduce the size of the argument list.

Be aware that holding this specialization will make this builtin appear in mangling, so I'd avoid doing that unless necessary.

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


More information about the cfe-commits mailing list