[clang] [clang]: implement std::meta::is_type (PR #211653)
Ambrose Leeb via cfe-commits
cfe-commits at lists.llvm.org
Tue Oct 20 13:59:44 PDT 2026
================
@@ -0,0 +1,18 @@
+//===--- BuiltinsMeta.td - Builtins for reflection metafunctions ---*- 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
+//
+//===-------------------------------------------------------------------------===//
+
+// All metafunctions should be consteval.
+class CXXMetaBuiltin<string prototype, list<Attribute> Attrs = []>
+ : LangBuiltin<"CXX_LANG"> {
+ let Prototype = prototype;
+ let Attributes = !listconcat([Consteval], Attrs);
+}
+
+def MetaIsType : CXXMetaBuiltin<"bool(std::meta::info)", [NoThrow]> {
+ let Spellings = ["__builtin_meta_is_type"];
+}
----------------
Sirraide wrote:
```suggestion
def MetaIsType : CXXMetaBuiltin<"is_type", "bool(std::meta::info)", [NoThrow]>;
```
Not sure how fancy we want to be wrt the tablegen code for these, but something like this would also be an option (use `!strconcat` in `CXXMetaBuiltin` to prepend `__builtin_meta_`), just because, realistically, all of these are going to have exactly 1 spelling and it’s going to start w/ `__builtin_meta_`.
The `[NoThrow]` should probably stay where it is because some of the `<meta>` builtins can throw I believe
https://github.com/llvm/llvm-project/pull/211653
More information about the cfe-commits
mailing list