public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
From: Nathan Sidwell <nathan@acm.org>
To: "Martin Liška" <mliska@suse.cz>, "GCC Development" <gcc@gcc.gnu.org>
Cc: Jason Merrill <jason@redhat.com>
Subject: Re: How to easily identify that a FUNCTION_DECL is a lambda
Date: Mon, 16 Jul 2018 14:30:00 -0000	[thread overview]
Message-ID: <86137da9-4229-4cc7-bb17-607f726aefa5@acm.org> (raw)
In-Reply-To: <2bc49528-72cc-46fd-2105-63d292074034@suse.cz>

On 07/16/2018 03:23 AM, Martin Liška wrote:
> Hi.
> 
> For purpose of --coverage I would like to distinguish lambda functions
> among DECL_ARTIFICIAL functions. Currently, cp-tree.h provides macro:
> 
> /* Test if FUNCTION_DECL is a lambda function.  */
> #define LAMBDA_FUNCTION_P(FNDECL)				\
>    (DECL_DECLARES_FUNCTION_P (FNDECL)				\
>     && DECL_OVERLOADED_OPERATOR_P (FNDECL)			\
>     && DECL_OVERLOADED_OPERATOR_IS (FNDECL, CALL_EXPR)		\
>     && LAMBDA_TYPE_P (CP_DECL_CONTEXT (FNDECL)))
> 
> That's FE-specific function that probably should not be called from
> middle-end. Any idea how to distinguish lambdas?

You're going to need a language hook.  Lambda fns are just regular 
member fns outside the front-end.  Make the hook more than 
'lambda_fn_p', so it can extend to other exciting C++ features.  Perhaps 
something like:

enum synthetic_fn_kind {
   sfk_none,
   sfk_cxx_lambda,
};
synthetic_fn_kind (*categorize_artificial_fn) (tree decl);

We'll have to expose the union of FE's such sythetic fns to the middle 
end, but at least not how the FE distinguishes them.

Hm, but isn't this info lost if we're in LTO at this point?  Not sure if 
we'll need to propagate this through the LTO streaming.  I guess that's 
a later bug to handle though.

nathan

-- 
Nathan Sidwell

  reply	other threads:[~2018-07-16 14:30 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-07-16  7:23 Martin Liška
2018-07-16 14:30 ` Nathan Sidwell [this message]
2018-07-16 16:04   ` Richard Biener
2018-07-16 16:09     ` Nathan Sidwell
2018-07-17 11:35       ` Martin Liška
2018-07-17 11:51         ` Richard Biener
2018-07-18  1:46 ` Jason Merrill
2018-07-18  9:03   ` Martin Liška
2018-07-18 12:40     ` Jason Merrill
2018-07-18 13:49       ` Martin Liška
2018-08-01 13:35         ` Martin Liška

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=86137da9-4229-4cc7-bb17-607f726aefa5@acm.org \
    --to=nathan@acm.org \
    --cc=gcc@gcc.gnu.org \
    --cc=jason@redhat.com \
    --cc=mliska@suse.cz \
    /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).