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 269F43858D28 for ; Tue, 1 Aug 2023 00:35:08 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 269F43858D28 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=1690850106; 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; bh=twJRq2gnKEvULBewng4g3j67Ctm23SylION8UfbQCHs=; b=ZIlqh+NESk0SR+CPTkYXGHoxSwNKari2k6MZZzUNEdbHqd3WMd1Hk0mYnmlI9yiORIWyOp OD4V7sXXmL0MPRjh0LSSdMylUegpqQeXO4u0NlMexEmbZGpYS5NT/dIjYPz07zSVFn3bzy pHKzWxdCdXM0uNg7NktDNG4dtZ3AnRo= Received: from mail-qt1-f199.google.com (mail-qt1-f199.google.com [209.85.160.199]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-370-VsIHxRiWP4SBQL-_ECjoXQ-1; Mon, 31 Jul 2023 20:35:05 -0400 X-MC-Unique: VsIHxRiWP4SBQL-_ECjoXQ-1 Received: by mail-qt1-f199.google.com with SMTP id d75a77b69052e-4053d10ee39so48072591cf.1 for ; Mon, 31 Jul 2023 17:35:05 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1690850105; x=1691454905; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=twJRq2gnKEvULBewng4g3j67Ctm23SylION8UfbQCHs=; b=fx6kfAAdfVzNKNtx6CLahgCI3iBU5bg9Su5IifVaFTOXNk74DiJ4P21bXGSglPQmhM FZjGT74kcpADErlCNBdu7Lhl5PGoGuLvWT6BdW9pi2dw1HvjGX68IfmHe//CepkkmTZj vJUtS5h5no0rbJTAoWkA0pmVlszUdBkNIkjdh3qRs/3tOnIKIldxwdl3LQUU+/DPxJBO PlBaFCsFTDQHFqxflOGPpYefmEDIIdQLpKbMi8W9BjXm/0kF6iUkp5LdZcvp0AXznnXe 6oTnxyf16U3hhr3YJoN9YPw5GNMoaNwqc3xF7KX2Vz5V3ZbZM1ShxkACA8kkDDoBjgwW 9Tpw== X-Gm-Message-State: ABy/qLbwOQptg3/2p2O75hJjxaiJYU8/XaLkrNYQfBAYFE8X40rUYfJh 6Q7mJ6sRmZi65kJkBuDm8wSG30vMAfZ72ZFuPZcEX2ukn47vMFX974Kzv9cmpLUxNh5xDxixA7U U4sBVvaMbwkUoe1yX4/tIDefxi/WM/zkPR/JD7mO2cGpWh+c2SCLVyC6nugTmbRlctucFE2tFm+ 4= X-Received: by 2002:a05:622a:104:b0:402:36dd:20f6 with SMTP id u4-20020a05622a010400b0040236dd20f6mr13558850qtw.53.1690850104765; Mon, 31 Jul 2023 17:35:04 -0700 (PDT) X-Google-Smtp-Source: APBJJlFStN1KvzOzaj1YGJSJAlNFf/HLOwZAqyFggvip7zizMCI6zabNT2L4Q7yXf3J4+ydzN41LxA== X-Received: by 2002:a05:622a:104:b0:402:36dd:20f6 with SMTP id u4-20020a05622a010400b0040236dd20f6mr13558829qtw.53.1690850104433; Mon, 31 Jul 2023 17:35:04 -0700 (PDT) Received: from localhost.localdomain (ool-457670bb.dyn.optonline.net. [69.118.112.187]) by smtp.gmail.com with ESMTPSA id y2-20020ac83e82000000b003f6ac526568sm4027641qtf.39.2023.07.31.17.35.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 31 Jul 2023 17:35:04 -0700 (PDT) From: Patrick Palka To: gcc-patches@gcc.gnu.org Cc: jason@redhat.com, Patrick Palka Subject: [PATCH] c++: improve debug_tree for templated types/decls Date: Mon, 31 Jul 2023 20:34:56 -0400 Message-ID: <20230801003456.994217-1-ppalka@redhat.com> X-Mailer: git-send-email 2.41.0.478.gee48e70a82 MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset="US-ASCII"; x-default=true X-Spam-Status: No, score=-13.7 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H4,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE,TXREP,T_SCC_BODY_TEXT_LINE 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: 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. : Don't print TYPE_TI_ARGS anymore. : 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) && DECL_TEMPLATE_INFO (node)) - print_node (file, "template-info", DECL_TEMPLATE_INFO (node), - indent + 4); + { + print_node (file, "template-info", DECL_TEMPLATE_INFO (node), + indent + 4); + indent_to (file, indent + 3); + fprintf (file, " use_template=%d", DECL_USE_TEMPLATE (node)); + } } void cxx_print_type (FILE *file, tree node, int indent) { + if (TYPE_LANG_SPECIFIC (node) + && TYPE_TEMPLATE_INFO (node)) + print_node (file, "template-info", TYPE_TEMPLATE_INFO (node), indent + 4); + switch (TREE_CODE (node)) { case BOUND_TEMPLATE_TEMPLATE_PARM: - print_node (file, "args", TYPE_TI_ARGS (node), indent + 4); - gcc_fallthrough (); - case TEMPLATE_TYPE_PARM: case TEMPLATE_TEMPLATE_PARM: - indent_to (file, indent + 3); - fprintf (file, "index %d level %d orig_level %d", - TEMPLATE_TYPE_IDX (node), TEMPLATE_TYPE_LEVEL (node), - TEMPLATE_TYPE_ORIG_LEVEL (node)); + print_node (file, "tpi", TEMPLATE_TYPE_PARM_INDEX (node), indent + 4); return; case FUNCTION_TYPE: -- 2.41.0.478.gee48e70a82