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

Nikolas Klauser via cfe-commits cfe-commits at lists.llvm.org
Thu Feb 20 00:12:37 PST 2025


================
@@ -0,0 +1,162 @@
+//=- ClangBuiltinsEmitter.cpp - Generate Clang builtin templates-*- 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
+//
+//===----------------------------------------------------------------------===//
+//
+// This tablegen backend emits Clang's builtin templates.
+//
+//===----------------------------------------------------------------------===//
+
+#include "TableGenBackends.h"
+#include "llvm/TableGen/Error.h"
+#include "llvm/TableGen/TableGenBackend.h"
+
+#include <sstream>
+
+using namespace llvm;
+
+static std::string TemplateNameList;
+static std::string CreateBuiltinTemplateParameterList;
+
+namespace {
+struct ParserState {
+  size_t UniqueCounter = 0;
+  size_t CurrentDepth = 0;
+  bool EmittedSizeTInfo = false;
+};
+
+std::pair<std::string, std::string>
+ParseTemplateParameterList(ParserState &PS,
+                           ArrayRef<const Record *> TemplateArgs) {
+  std::vector<std::string> Params;
+  std::unordered_map<std::string, std::string> TemplateNameToParmName;
----------------
philnik777 wrote:

I'm really not familiar with the LLVM containers, so I don't know. Does it make much of a difference for a tablegen emitter?

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


More information about the cfe-commits mailing list