================
@@ -0,0 +1,184 @@
+//=- 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"
+
+using namespace llvm;
+
+std::string TemplateNameList;
+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, StringRef &TemplateParmList) {
+  auto Alphabetic = [](char c) { return std::isalpha(c); };
----------------
erichkeane wrote:

> @erichkeane Do you have any better idea how to represent this? I could 
> represent as something like
> 
> ```
> def __make_integer_seq : BuiltinTemplate<Template<[Class<"T">, NTTP<"T", 
> "Ints", /*variadic*/true>], "IntSeq">, Class<"T">, NTTP<"T", "N">>;
> ```
> 
> But that's really hard to read IMO.
> 
> @Sirraide With an attribute we'd still have to verify that the parsed 
> template actually represents the template, since users would be able to 
> declare templates with an attribute, so we'd be back at square one AFAICT. It 
> would also mean introducing code into every single translation unit, which 
> would probably increase the startup time of clang.

I REALLY don't want the whole compiler, but something like the above isn't too 
bad IMO.  Perhaps the NTTP recursively takes a type template.  

WHILE that isn't super easy to read, it isn't all that bad, it is pretty much 
the template head.



https://github.com/llvm/llvm-project/pull/123736
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to