Commit Graph

9526 Commits

Author SHA1 Message Date
Jakub Jelinek
967b4e8235 Introduce METAFN_KIND_SHIFT and METAFN_KIND_MASK, use it and rewrite
process_metafunction start to use a loop for all 3 arguments.
Update copyright years.
2026-01-14 11:01:10 -05:00
Marek Polacek
39c4c97dbf Rework consteval-only type cheking
Introduce check_consteval_only_fn and call it in grokfndecl
and instantiate_body.  Also make std::meta::exception special
member functions consteval.

I couldn't use check_consteval_only_fn in tsubst_function_decl
due to too many failures in libstdc++.
2026-01-14 11:01:02 -05:00
Jakub Jelinek
6ed71bbf5d Tweaks from libstdc++-v3 reflection patch review. 2026-01-14 11:00:43 -05:00
Marek Polacek
a717febf18 Make std::meta::exception::what consteval
This enables implementing CWG 3115.
2026-01-14 11:00:37 -05:00
Jakub Jelinek
c3909532fd Implement the reflection part of P3920R0. 2026-01-14 11:00:34 -05:00
Marek Polacek
c47ed8c687 <meta>: remove unused include 2026-01-14 11:00:34 -05:00
Jakub Jelinek
03f2de2798 Bump feature test macros to their C++26 current values now that all metafns are implemented. 2026-01-14 11:00:26 -05:00
Jakub Jelinek
d5547474e4 Implement std::meta::alignment_of. 2026-01-14 10:58:54 -05:00
Jakub Jelinek
3eeb2c125b Implement std::meta::is_override. 2026-01-14 10:58:53 -05:00
mlevine55
6638989aec committing on behalf of the author Alex Yesmanchyk <ayesmanchyk@bloomberg.net>: implement std::meta::is_virtual with pr feedback
Signed-off-by: mlevine55 <mlevine55@bloomberg.net>
2026-01-14 10:58:51 -05:00
mlevine55
31dd30614f Committing on behalf of the author Valentyn Yukhymenko <vyuhimenko@bloomberg.net>: implement std::meta::is_final with pr comments accounted for
Signed-off-by: mlevine55 <mlevine55@bloomberg.net>
2026-01-14 10:58:51 -05:00
mlevine55
712752ce51 Committing on behalf of the author Alex Yesmanchyk <ayesmanchyk@bloomberg.net>: implement std::meta::is_pure_virtual with pr comment feedback included
Signed-off-by: mlevine55 <mlevine55@bloomberg.net>
2026-01-14 10:58:50 -05:00
Jakub Jelinek
27abab15b1 Implement std::define_static_{string,array,object}. 2026-01-14 10:58:50 -05:00
Marek Polacek
094deb4fef Implement std::meta::extract
Sorry it took so long...
2026-01-14 10:58:49 -05:00
mlevine55
4ca1672070 committing on behalf of the author Valentyn Yukhymenko <vyuhimenko@bloomberg.net>:implement std::meta::is_public/private/protected including pr feedback
Signed-off-by: mlevine55 <mlevine55@bloomberg.net>
2026-01-14 10:58:49 -05:00
Jakub Jelinek
bc831c8c41 Fix up std::meta::exception constructors and what() method.
So that the ctors convert UTF-8 what to exec charset or vice versa
and what() is non-constant if UTF-8 to exec charset conversion failed.
This uses two helper meta functions (static private members of
std::meta::exception) which piggyback on reflect_constant_string.

Furthermore, translate compiler thrown std::meta::exception strings
to exec charset.
2026-01-14 10:58:48 -05:00
Jakub Jelinek
7f23cad230 Implement std::meta::{is_{,nothrow_}swappable_{,with_}type,unwrap_ref{erence,_decay}}.
Furthermore, add two helper functions to simplify implementation of
various metafunctions which need to instantiate library type value
or type traits.
2026-01-14 10:58:47 -05:00
Jakub Jelinek
2627511ea9 Add <meta> to <bits/stdc++.h> and std.cc.
Note, I think module.cc will need some limited work for REFLECT_EXPR
and/or META_TYPE.  Plus maybe because members_of relies on DECL_UIDs
for what has been declared earlier vs. later for both namespaces
(where nothing actually guarantees order, so not a big deal) and
in classes (where the standard guarantees it), so maybe we'll need
to make sure to stream the class content in DECL_UID order.
2026-01-14 10:58:47 -05:00
Jakub Jelinek
7ce3ec6bd8 Implement std::meta::{,u8}display_string_of.
The printing of TEMPLATE_DECLs looks awful, not sure how to improve it though.
2026-01-14 10:58:46 -05:00
Jakub Jelinek
d2569258b0 Implement std::meta::{{bases,subobjects}_of,has_inaccessible_{bases,subobjects}}. 2026-01-14 10:58:46 -05:00
Marek Polacek
82732e7d22 Implement std::meta::constant_of
Unfortunately this needed other changes.  I need to have a function to
check if a splice-expression is valid so I had to factor out some code
out to check_splice_expr.  Then I realized pt.cc needs to know in which
context the original SPLICE_EXPR was found so that needed two new flags.

compare_reflections has a new hack, but this should be fixed rather soon
on trunk and then the hack can go after a rebase.

I discovered a new ICE, fixed, and tested in crash13.C.

Annotations are to be done, but it should be easy.
2026-01-14 10:58:46 -05:00
Jakub Jelinek
8cc8c8143b Initial implementation of std::meta::{,{,non}static_data_}members_of and std::meta::has_inaccessible_nonstatic_data_members.
Doesn't handle yet https://eel.is/c++draft/meta.reflection#member.queries-3.5.2
nor does it test https://eel.is/c++draft/meta.reflection#member.queries-3.4
undeduced placeholder type, the namespace queries definitely need better
testsuite coverage.
Doesn't handle yet the underlying variables of tuple using namespace
scope structured bindings, doesn't have any tests for structured bindings,
guess structured binding packs need to be tested too.
And for members_of (^^::, access_context::current ()) I guess we need to
decide if e.g. __builtin_ etc. prefixed builtins or anticipated normal identifier
builtins should appear or not.
2026-01-14 10:58:45 -05:00
Jakub Jelinek
aa912b4d99 Implement std::meta::is_accessible.
There is a TODO, don't know how to check for
https://eel.is/c++draft/meta.reflection#access.queries-3.3.1
but when via wasn't used, that doesn't apply, DESIGNATING-CLS is
in that case always the PARENT-CLS and I think that should be always
satisfied.

Plus, there is one ICE somewhere deep in the accessible handling for the
static_assert (is_accessible (N::rb, N::ctx));
case, and disagreement with clang branch on
  static_assert (is_accessible (D::rG, ctx));
  static_assert (is_accessible (D::rH, ctx));
  static_assert (is_accessible (D::rH1, ctx));
and
  static_assert (is_accessible (D::rh, ctx));
  static_assert (is_accessible (D::rk, ctx));
in thud and
static_assert (!is_accessible (N::rb, gctx));
static_assert (!is_accessible (N::rc, gctx));
and
static_assert (!is_accessible (N::rb, O::ctx));
static_assert (!is_accessible (N::rc, O::ctx));
at global ns.  I have no idea what is right or wrong in these
cases, though I'd say at least from global ns N::rb and N::rc shouldn't
be accessible (yes, parent class in that case is the anonymous union,
but still).
2026-01-14 10:58:45 -05:00
Marek Polacek
8b2214a30b Implement std::meta::object_of
At least the basic tests pass.  More involved may not.
2026-01-14 10:58:45 -05:00
Jakub Jelinek
09f2c4896f Implement std::meta::access_context. 2026-01-14 10:58:44 -05:00
Marek Polacek
f935277389 Implement std::meta::is_implicit_lifetime_type 2026-01-14 10:58:43 -05:00
Marek Polacek
38bfe3710c Implement std::meta::is_value 2026-01-14 10:58:43 -05:00
Jakub Jelinek
6e08ee6249 Implement std::meta::reflect_constant_array.
Like for reflect_constant_string, proxy iterators are currently
unsupported.
2026-01-14 10:58:43 -05:00
Jakub Jelinek
12e6993a11 Implement std::meta::reflect_constant_string.
Except for now it doesn't handle proxy iterators, so requires
same_as<remove_cvref_t<ranges::range_reference_t<_R>>, ranges::range_value_t<_R>>.
2026-01-14 10:58:42 -05:00
Marek Polacek
f43f775665 Implement std::meta::is_[lr]value_reference_qualified 2026-01-14 10:58:42 -05:00
Jakub Jelinek
de6e115a20 Implement std::meta::{is_{,nothrow_}invocable_r_type,common_{type,reference},invoke_result}. 2026-01-14 10:58:41 -05:00
Marek Polacek
a70c3c4229 Implement std::meta::variant_{size,alternative} 2026-01-14 10:58:41 -05:00
Jakub Jelinek
6032d7391c Implement std::meta::define_aggregate.
Also, fix up type_of for bit-fields.  And add some tests to data_member_spec1
for invalid identifiers.
2026-01-14 10:58:41 -05:00
Marek Polacek
8778cf887e Implement std::meta::tuple_{size,element} 2026-01-14 10:58:41 -05:00
Jakub Jelinek
edb051f3ba Implement std::meta::{data_member_spec,is_data_member_spec}. 2026-01-14 10:58:40 -05:00
mlevine55
4b67ad0feb committing on behalf of the author Valentyn Yukhymenko: implement std::meta::is_explicit
Signed-off-by: mlevine55 <mlevine55@bloomberg.net>
2026-01-14 10:58:40 -05:00
mlevine55
ef269b4b68 committing on behalf of Valentyn Yukhymenko: implement std::meta::is_noexcept
Signed-off-by: mlevine55 <mlevine55@bloomberg.net>
2026-01-14 10:58:40 -05:00
Marek Polacek
30c9c82d19 Implement std::meta::has_{static,thread,automatic}_storage_duration 2026-01-14 10:58:40 -05:00
Jakub Jelinek
0cfabb2f15 Implement std::{can_,}substitute. 2026-01-14 10:58:39 -05:00
Marek Polacek
5a8b2a4ba0 Implement std::meta::reflect_object
But there still are several TODOs.  It also turned out that
reflect_constant is flawed.  Test to come.
2026-01-14 10:58:39 -05:00
Jakub Jelinek
ab12ae0594 Implement std::meta::is_{{conversion,operator}_function,literal_operator,constructor}_template.
Still no idea how to test is_conversion_function_template and
is_constructor_template.

Also, unsure if is_constructor is not incorrect (i.e. whether it
should only return true for FUNCTION_DECLs and not TEMPLATE_DECLs).
2026-01-14 10:58:39 -05:00
Jakub Jelinek
c80c5aba39 Implement std::meta::{,u8}identifier_of. 2026-01-14 10:58:38 -05:00
Jakub Jelinek
371aa870b9 Implement std::meta::has_default_argument. 2026-01-14 10:58:38 -05:00
Jakub Jelinek
e1c0c5766c Implement std::meta::is_{{,trivially_,nothrow_}constructible,{,trivially_}invocable}_type. 2026-01-14 10:58:38 -05:00
Jakub Jelinek
1e263810d0 Fix ordering of one block of meta functions vs. the standard [meta.syn]. 2026-01-14 10:58:37 -05:00
Jakub Jelinek
ec7e1ec7c1 Implement std::meta::{is_{deleted,defaulted,user_{provided,declared},bit_field,{mutable,class,namespace,nonstatic_data,static}_member},has_default_member_initializer}. 2026-01-14 10:58:37 -05:00
Jakub Jelinek
47d8a6a527 Implement std::meta::{remove_cvref,decay,underlying_type,type_order}. 2026-01-14 10:58:37 -05:00
Jakub Jelinek
11b5f10af4 Implement std::meta::{rank,extent}. 2026-01-14 10:58:37 -05:00
Jakub Jelinek
fc93d49236 Implement std::meta::{is_{,trivially_,nothrow_}{{default,copy,move}_constructible,{,copy_,move_}assignable,destructible}_type,is_nothrow_relocatable_type,has_{virtual_destructor,unique_object_representations},reference_{constructs,converts}_from_temporary}. 2026-01-14 10:58:36 -05:00
Jakub Jelinek
2b44dcdc8f Implement std::meta::is_explicit_object_parameter. 2026-01-14 10:58:36 -05:00