From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by sourceware.org (Postfix) with ESMTPS id 873C83858D33 for ; Tue, 28 Feb 2023 15:50:28 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 873C83858D33 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1677599428; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=mDuKfdS4OAN/G6UFNSvWrTubN9ooPmkMy+in5fBAbg8=; b=Bw0SXDNClvVJBtUBMM0Zo+JEtCztjEVpwzej+4jxSHd2zNxhalP+3Qt4vkShEaGECzAPQm RgQf5zVnOkSOvpXDjnKnE+0SjwubnYkygeefeatbCGx8c+gMmhi3qaysGUp0hf12b13Om8 ahO8DO0b0YREEI61G5TfhbXD6ZsvINQ= Received: from mail-ed1-f72.google.com (mail-ed1-f72.google.com [209.85.208.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-134-zgQDJCA2Pc-1dVKoFfqchg-1; Tue, 28 Feb 2023 10:50:26 -0500 X-MC-Unique: zgQDJCA2Pc-1dVKoFfqchg-1 Received: by mail-ed1-f72.google.com with SMTP id h13-20020a0564020e8d00b004a26ef05c34so14548011eda.16 for ; Tue, 28 Feb 2023 07:50:26 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=mDuKfdS4OAN/G6UFNSvWrTubN9ooPmkMy+in5fBAbg8=; b=n8HAc3iSaflpZnk2SneFJQRcpVX5SP48Qz0UW442amQH8cnCxvoFv3sMSSQBoQKu8E B3M7ex3XkUPt5QNj6mxJj4yfIJKFvBXoVyPpM4Tf6Ue12d/BhaSUhZS4QNxIqstm5rkb YMw82/paLWRRDKwvRJxpZRIJwMulgQ4Vu0+RnUwYYAz6lZjDP7wdjnc5jibr6H1QywvQ PGzgkDCgqyxV1P81sznf6LUOOn47AB3ze0mRNifrskuwcEIW7lTsqvOsd3vewmCQLzDl vRsUBDmI29rISbmG00/lTG+2bNKKAauy7soZtvjArURDLUDrssI9HCmTjJjQ4Dwt24AN JpGw== X-Gm-Message-State: AO0yUKXTOiu3+PQXZWIEi7DrgmXmWKzutBaKz8NZ2a49UwCsoEViVIMU pGxgnTyPQv6/TmoUpQk+jCpfL4kUCTh1YMzdWSWTvqXJlSIf1vpiFGPMZhfWBCYKjNnrNnFWhiB 9Ewe8QtXvAkdlIw5RuEBWKic= X-Received: by 2002:a50:baab:0:b0:4ab:1c64:a9ed with SMTP id x40-20020a50baab000000b004ab1c64a9edmr2099323ede.2.1677599425760; Tue, 28 Feb 2023 07:50:25 -0800 (PST) X-Google-Smtp-Source: AK7set/88BmCqYX4t3PqXk70JhHfowJBlGv7oCkHUSbsmFbgTyURO9jq0BQk/wvEmCKNEbiD58Fn0QnUuKjCtlvDf84= X-Received: by 2002:a50:baab:0:b0:4ab:1c64:a9ed with SMTP id x40-20020a50baab000000b004ab1c64a9edmr2099314ede.2.1677599425463; Tue, 28 Feb 2023 07:50:25 -0800 (PST) MIME-Version: 1.0 References: In-Reply-To: From: Patrick Palka Date: Tue, 28 Feb 2023 10:50:14 -0500 Message-ID: Subject: Re: [GSoC][C++: Compiler Built-in Traits]: Example Impls & Small Patches To: Ken Matsui Cc: gcc@gcc.gnu.org X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-6.8 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,KAM_SHORT,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_NONE,TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: Hi Ken, On Mon, Feb 27, 2023 at 5:02=E2=80=AFPM Ken Matsui via Gcc 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=3Dgcc.git;a=3Dcommitdiff;h=3D9ca147154074a0de548= 138b4e73477e94903a855 https://gcc.gnu.org/git/?p=3Dgcc.git;a=3Dcommitdiff;h=3D6ddbbbffbb5759a6c1d= 56c191364a6bd021f733e 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=3Dgcc.git;a=3Dblob;f=3Dgcc/cp/cp-trait.def [2]: https://gcc.gnu.org/git/?p=3Dgcc.git;a=3Dblob;f=3Dgcc/cp/semantics.cc;= h=3D79b7cc72f212cef780a3eea65af2b883bb4ec3c8;hb=3DHEAD#l12102 [3]: https://gcc.gnu.org/git/?p=3Dgcc.git;a=3Dblob;f=3Dlibstdc%2B%2B-v3/inc= lude/std/type_traits;h=3D2bd607a8b8ff52aba6fd205ab1af2bc4b92f78d0;hb=3DHEAD= #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