[clang] [Clang] Add BuiltinTemplates.td to generate code for builtin templates (PR #123736)

Erich Keane via cfe-commits cfe-commits at lists.llvm.org
Wed Feb 19 09:53:33 PST 2025


================
@@ -0,0 +1,46 @@
+//===--- BuiltinTemplates.td - Clang builtin template aliases ---*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+class TemplateArg<string name> {
+  string Name = name;
+}
+
+class Template<list<TemplateArg> args, string name> : TemplateArg<name> {
+  list<TemplateArg> Args = args;
+}
+
+class Class<string name, bit is_variadic = 0> : TemplateArg<name> {
+  bit IsVariadic = is_variadic;
+}
+
+class NTTP<string type_name, string name, bit is_variadic = 0> : TemplateArg<name> {
+  string TypeName = type_name;
+  bit IsVariadic = is_variadic;
+}
+
+class BuiltinNTTP<string type_name> : TemplateArg<""> {
+  string TypeName = type_name;
+}
+
+def SizeT : BuiltinNTTP<"size_t"> {}
+
+class BuiltinTemplate<list<TemplateArg> template_head> {
+  list<TemplateArg> TemplateHead = template_head;
+}
+
+def __make_integer_seq : BuiltinTemplate<
+  [Template<[Class<"T">, NTTP<"T", "Ints", /*is_variadic=*/1>], "IntSeq">, Class<"T">, NTTP<"T", "N">]>;
----------------
erichkeane wrote:

I realize I asked you to remove the 'string' version here, but if we could include it as a comment (particularly as these are the FIRST and are effectively documenting the format), it would be helpful.


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


More information about the cfe-commits mailing list