public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
From: Patrick Palka <ppalka@redhat.com>
To: Ken Matsui <kmatsui@cs.washington.edu>
Cc: gcc@gcc.gnu.org
Subject: Re: [GSoC][C++: Compiler Built-in Traits]: Example Impls & Small Patches
Date: Tue, 28 Feb 2023 10:50:14 -0500	[thread overview]
Message-ID: <CAMOnLZZ8OD4d5J5hHuAKbqp4e+g0DurW3x9y9owy8VZnSB3cHA@mail.gmail.com> (raw)
In-Reply-To: <CAML+3pXEyT_heXwaAH0wOg=b4QsMEZc1+qDZbsEP_9=we5Pi3A@mail.gmail.com>

Hi Ken,

On Mon, Feb 27, 2023 at 5:02 PM Ken Matsui via Gcc <gcc@gcc.gnu.org> wrote:
>
> Hi,
>
> My name is Ken Matsui. I am highly interested in contributing to the
> project idea, "C++: Implement compiler built-in traits for the
> standard library traits." To understand how to implement those traits,
> could you please give me some example implementations of the compiler
> built-in traits, as well as some recommended traits to get started
> with making small patches?

Awesome, thanks for your interest in this project, and welcome!

Most of the existing built-in traits are tabulated in
gcc/cp/cp-trait.def, and their logic is defined in finish_trait_type
or finish_trait_expr in gcc/cp/semantics.cc[2], and then the traits
are conditionally used in the standard type trait definitions in
libstdc++, e.g. std::remove_cv[3].

Take a look at the following commits that define (and add tests for)
the built-in traits __remove_cv, __remove_reference and __remove_cvref
and subsequently use them in libstdc++. Note that this first commit
predates the new gcc/cp/cp-trait.def file which streamlined much of
the boilerplate of adding a new built-in trait.  In the new approach
(that you would be using), only the semantics.cc change (which defines
their logic) would be needed, alongside additions to cp-trait.def to
declare each trait.
https://gcc.gnu.org/git/?p=gcc.git;a=commitdiff;h=9ca147154074a0de548138b4e73477e94903a855
https://gcc.gnu.org/git/?p=gcc.git;a=commitdiff;h=6ddbbbffbb5759a6c1d56c191364a6bd021f733e

To get started, I'd recommend implementing bulit-in traits for
std::remove_pointer, std::add_pointer and std::is_reference[4].  Let
me know if you have any questions :)

[1]: https://gcc.gnu.org/git/?p=gcc.git;a=blob;f=gcc/cp/cp-trait.def
[2]: https://gcc.gnu.org/git/?p=gcc.git;a=blob;f=gcc/cp/semantics.cc;h=79b7cc72f212cef780a3eea65af2b883bb4ec3c8;hb=HEAD#l12102
[3]: https://gcc.gnu.org/git/?p=gcc.git;a=blob;f=libstdc%2B%2B-v3/include/std/type_traits;h=2bd607a8b8ff52aba6fd205ab1af2bc4b92f78d0;hb=HEAD#l1539
[4]: As specified in https://en.cppreference.com/w/cpp/header/type_traits

>
> Also, I would appreciate receiving the contact information for the
> project mentor, Patrick Palka.
>
> Sincerely,
> Ken Matsui


  reply	other threads:[~2023-02-28 15:50 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-02-27 22:01 Ken Matsui
2023-02-28 15:50 ` Patrick Palka [this message]
  -- strict thread matches above, loose matches on Subject: below --
2023-02-24 16:00 Ken Matsui

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAMOnLZZ8OD4d5J5hHuAKbqp4e+g0DurW3x9y9owy8VZnSB3cHA@mail.gmail.com \
    --to=ppalka@redhat.com \
    --cc=gcc@gcc.gnu.org \
    --cc=kmatsui@cs.washington.edu \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).