Thanks for review. New version in attachment.

On 2025-01-14 19:03, Marek Polacek wrote:
On Mon, Jan 13, 2025 at 11:03:54PM +0100, anetczuk wrote:
Raw dump of lang tree was missing information about virtual method call.
Please resend the patch as an attachment, it's not applicable as-is.
The information is provided in "tok" field of obj_type_ref.

gcc/ChangeLog:

* tree-dump.cc (dequeue_and_dump): Handle OBJ_TYPE_REF.

gcc/testsuite/ChangeLog:

* g++.dg/lang-dump-1.C: New test.

---

gcc/testsuite/g++.dg/lang-dump-1.C | 22 ++++++++++++++++++++++

gcc/tree-dump.cc | 7 +++++++

2 files changed, 29 insertions(+)

create mode 100644 gcc/testsuite/g++.dg/lang-dump-1.C

diff --git a/gcc/testsuite/g++.dg/lang-dump-1.C
b/gcc/testsuite/g++.dg/lang-dump-1.C

new file mode 100644

index 00000000000..cc467aee0f0

--- /dev/null

+++ b/gcc/testsuite/g++.dg/lang-dump-1.C
This should go to g++.dg/diagnostic/.
@@ -0,0 +1,22 @@

+/* { dg-do compile } */
Please use // here.
Otherwise the patch looks okay.

+// { dg-additional-options "-fdump-lang-raw" }

+// Check if dump file contains OBJ_TYPE_REF with additional fields
(information about called virtual method).

+

+class VExample {

+public:

+ virtual void methodV1() {}

+ virtual void methodV2() {}

+};

+

+void funcA() {

+ VExample objA;

+ VExample *ptrA = &objA;

+

+ ptrA->methodV2();

+ ptrA->methodV1();

+}

+

+// { dg-final { scan-lang-dump-times {obj_type_ref[^\n]*type:} 2 raw } }

+// { dg-final { scan-lang-dump-times {obj_type_ref[^\n]*expr:} 2 raw } }

+// { dg-final { scan-lang-dump-times {obj_type_ref[^\n]*obj :} 2 raw } }

+// { dg-final { scan-lang-dump-times {obj_type_ref[^\n]*\n[^\n]*tok :} 2
raw } }

diff --git a/gcc/tree-dump.cc b/gcc/tree-dump.cc

index c234d1ccaf3..bec36b41ea5 100644

--- a/gcc/tree-dump.cc

+++ b/gcc/tree-dump.cc

@@ -697,6 +697,13 @@ dequeue_and_dump (dump_info_p di)

dump_child ("op: ", OMP_CLAUSE_OPERAND (t, i));

}

break;

+

+ case OBJ_TYPE_REF:

+ dump_child ("expr", OBJ_TYPE_REF_EXPR (t));

+ dump_child ("obj", OBJ_TYPE_REF_OBJECT (t));

+ dump_child ("tok", OBJ_TYPE_REF_TOKEN (t));

+ break;

+

default:

/* There are no additional fields to print. */

break;

--

2.43.0

Marek

From 3008f34d16f441ba5ae8c3938d27d8715246995e Mon Sep 17 00:00:00 2001
From: anetczuk <anetc...@o2.pl>
Date: Mon, 13 Jan 2025 20:27:04 +0100
Subject: [PATCH] c++: dump-lang-raw with obj_type_ref fields

Raw dump of lang tree was missing information about virtual method call.
The information is provided in "tok" field of obj_type_ref.

gcc/ChangeLog:

	* tree-dump.cc (dequeue_and_dump): Handle OBJ_TYPE_REF.

gcc/testsuite/ChangeLog:

	* g++.dg/diagnostic/lang-dump-1.C: New test.
---
 gcc/testsuite/g++.dg/diagnostic/lang-dump-1.C | 22 +++++++++++++++++++
 gcc/tree-dump.cc                              |  7 ++++++
 2 files changed, 29 insertions(+)
 create mode 100644 gcc/testsuite/g++.dg/diagnostic/lang-dump-1.C

diff --git a/gcc/testsuite/g++.dg/diagnostic/lang-dump-1.C b/gcc/testsuite/g++.dg/diagnostic/lang-dump-1.C
new file mode 100644
index 00000000000..41768949f12
--- /dev/null
+++ b/gcc/testsuite/g++.dg/diagnostic/lang-dump-1.C
@@ -0,0 +1,22 @@
+// { dg-do compile }
+// { dg-additional-options "-fdump-lang-raw" }
+// Check if dump file contains OBJ_TYPE_REF with additional fields (information about called virtual method).
+
+class VExample {
+public:
+    virtual void methodV1() {}
+    virtual void methodV2() {}
+};
+
+void funcA() {
+    VExample objA;
+    VExample *ptrA = &objA;
+
+    ptrA->methodV2();
+    ptrA->methodV1();
+}
+
+// { dg-final { scan-lang-dump-times {obj_type_ref[^\n]*type:} 2 raw } }
+// { dg-final { scan-lang-dump-times {obj_type_ref[^\n]*expr:} 2 raw } }
+// { dg-final { scan-lang-dump-times {obj_type_ref[^\n]*obj :} 2 raw } }
+// { dg-final { scan-lang-dump-times {obj_type_ref[^\n]*\n[^\n]*tok :} 2 raw } }
diff --git a/gcc/tree-dump.cc b/gcc/tree-dump.cc
index c234d1ccaf3..bec36b41ea5 100644
--- a/gcc/tree-dump.cc
+++ b/gcc/tree-dump.cc
@@ -697,6 +697,13 @@ dequeue_and_dump (dump_info_p di)
 	  dump_child ("op: ", OMP_CLAUSE_OPERAND (t, i));
       }
       break;
+
+    case OBJ_TYPE_REF:
+      dump_child ("expr", OBJ_TYPE_REF_EXPR (t));
+      dump_child ("obj", OBJ_TYPE_REF_OBJECT (t));
+      dump_child ("tok", OBJ_TYPE_REF_TOKEN (t));
+      break;
+
     default:
       /* There are no additional fields to print.  */
       break;
-- 
2.43.0

Reply via email to