public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Jason Merrill <jason@redhat.com>
To: Patrick Palka <ppalka@redhat.com>
Cc: gcc-patches@gcc.gnu.org
Subject: Re: [PATCH] c++: improve debug_tree for templated types/decls
Date: Thu, 10 Aug 2023 17:04:03 -0400	[thread overview]
Message-ID: <f97a8cc6-d63b-dfd3-7ab7-f687013ae73a@redhat.com> (raw)
In-Reply-To: <bbb8f695-d6f8-8861-714d-c04dd2048478@idea>

On 8/10/23 16:59, Patrick Palka wrote:
> On Tue, 8 Aug 2023, Jason Merrill wrote:
> 
>> On 7/31/23 20:34, Patrick Palka wrote:
>>> Tested on x86_64-pc-linux-gnu, does this look OK for trunk?
>>>
>>> -- >8 --
>>>
>>> gcc/cp/ChangeLog:
>>>
>>> 	* ptree.cc (cxx_print_decl): Check for DECL_LANG_SPECIFIC and
>>> 	TS_DECL_COMMON only when necessary.  Print DECL_TEMPLATE_INFO
>>> 	for all decls that have it, not just VAR_DECL or FUNCTION_DECL.
>>> 	Also print DECL_USE_TEMPLATE.
>>> 	(cxx_print_type): Print TYPE_TEMPLATE_INFO.
>>> 	<case BOUND_TEMPLATE_TEMPLATE_PARM>: Don't print TYPE_TI_ARGS
>>> 	anymore.
>>> 	<case TEMPLATE_TYPE/TEMPLATE_PARM>: Print TEMPLATE_TYPE_PARM_INDEX
>>> 	instead of printing the index, level and original level
>>> 	individually.
>>> ---
>>>    gcc/cp/ptree.cc | 32 +++++++++++++++++---------------
>>>    1 file changed, 17 insertions(+), 15 deletions(-)
>>>
>>> diff --git a/gcc/cp/ptree.cc b/gcc/cp/ptree.cc
>>> index 33af7b81f58..13306fc8762 100644
>>> --- a/gcc/cp/ptree.cc
>>> +++ b/gcc/cp/ptree.cc
>>> @@ -38,10 +38,6 @@ cxx_print_decl (FILE *file, tree node, int indent)
>>>          return;
>>>        }
>>>    -  if (!CODE_CONTAINS_STRUCT (TREE_CODE (node), TS_DECL_COMMON)
>>> -      || !DECL_LANG_SPECIFIC (node))
>>> -    return;
>>> -
>>>      if (TREE_CODE (node) == FUNCTION_DECL)
>>>        {
>>>          int flags = TFF_DECL_SPECIFIERS|TFF_RETURN_TYPE
>>> @@ -106,7 +102,10 @@ cxx_print_decl (FILE *file, tree node, int indent)
>>>          need_indent = false;
>>>        }
>>>    -  if (DECL_EXTERNAL (node) && DECL_NOT_REALLY_EXTERN (node))
>>> +  if (CODE_CONTAINS_STRUCT (TREE_CODE (node), TS_DECL_COMMON)
>>> +      && DECL_LANG_SPECIFIC (node)
>>> +      && DECL_EXTERNAL (node)
>>> +      && DECL_NOT_REALLY_EXTERN (node))
>>>        {
>>>          if (need_indent)
>>>    	indent_to (file, indent + 3);
>>> @@ -115,6 +114,7 @@ cxx_print_decl (FILE *file, tree node, int indent)
>>>        }
>>>        if (TREE_CODE (node) == FUNCTION_DECL
>>> +      && DECL_LANG_SPECIFIC (node)
>>>          && DECL_PENDING_INLINE_INFO (node))
>>>        {
>>>          if (need_indent)
>>> @@ -124,27 +124,29 @@ cxx_print_decl (FILE *file, tree node, int indent)
>>>          need_indent = false;
>>>        }
>>>      -  if (VAR_OR_FUNCTION_DECL_P (node)
>>> +  if (DECL_LANG_SPECIFIC (node)
>>
>> Hmm, won't this crash on a non-COMMON decl?
> 
> Oops yes, I overlooked that DECL_LANG_SPECIFIC requires DECL_COMMON.  So
> we should just move the early exit test down a bit.
> 
>>
>>>          && DECL_TEMPLATE_INFO (node))
> 
> We also need to constrain the kinds of decls that we test
> DECL_TEMPLATE_INFO on according to template_info_decl_check.
> 
> -- >8 --
> 
> Subject: [PATCH] c++: improve debug_tree for templated types/decls
> 
> gcc/cp/ChangeLog:
> 
> 	* ptree.cc (cxx_print_decl): Check for DECL_LANG_SPECIFIC and
> 	TS_DECL_COMMON only when necessary.  Print DECL_TEMPLATE_INFO
> 	for all decls that have it, not just VAR_DECL or FUNCTION_DECL.
> 	Also print DECL_USE_TEMPLATE.
> 	(cxx_print_type): Print TYPE_TEMPLATE_INFO.
> 	<case BOUND_TEMPLATE_TEMPLATE_PARM>: Don't print TYPE_TI_ARGS
> 	anymore.
> 	<case TEMPLATE_TYPE/TEMPLATE_PARM>: Print TEMPLATE_TYPE_PARM_INDEX
> 	instead of printing the index, level and original level
> 	individually.

OK.

Jason


      reply	other threads:[~2023-08-10 21:04 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-08-01  0:34 Patrick Palka
2023-08-08 20:36 ` Jason Merrill
2023-08-10 20:59   ` Patrick Palka
2023-08-10 21:04     ` Jason Merrill [this message]

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=f97a8cc6-d63b-dfd3-7ab7-f687013ae73a@redhat.com \
    --to=jason@redhat.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=ppalka@redhat.com \
    /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).