[13/16] Add debug_omp_expr
Commit Message
The C and C++ front-ends use a TREE_LIST as a 3-tuple representing an
OpenMP array section, which tends to crash debug_generic_expr if one
wants to print such an expression in the debugger. This little helper
function works around that.
We might want to adjust the representation of array sections to use the
soon-to-be-introduced OMP_ARRAY_SECTION tree code throughout instead,
at which point this patch will no longer be necessary.
OK?
Thanks,
Julian
2021-11-15 Julian Brown <julian@codesourcery.com>
gcc/
* tree-pretty-print.c (print_omp_expr, debug_omp_expr): New functions.
* tree-pretty-print.h (debug_omp_expr): Add prototype.
---
gcc/tree-pretty-print.c | 31 +++++++++++++++++++++++++++++++
gcc/tree-pretty-print.h | 1 +
2 files changed, 32 insertions(+)
@@ -103,6 +103,37 @@ debug_generic_stmt (tree t)
fprintf (stderr, "\n");
}
+static void
+print_omp_expr (tree t)
+{
+ if (TREE_CODE (t) == TREE_LIST)
+ {
+ tree low = TREE_PURPOSE (t);
+ tree len = TREE_VALUE (t);
+ tree base = TREE_CHAIN (t);
+ if (TREE_CODE (base) == TREE_LIST)
+ print_omp_expr (base);
+ else
+ print_generic_expr (stderr, base, TDF_VOPS|TDF_MEMSYMS);
+ fprintf (stderr, "[");
+ if (low)
+ print_generic_expr (stderr, low, TDF_VOPS|TDF_MEMSYMS);
+ fprintf (stderr, ":");
+ if (len)
+ print_generic_expr (stderr, len, TDF_VOPS|TDF_MEMSYMS);
+ fprintf (stderr, "]");
+ }
+ else
+ print_generic_expr (stderr, t, TDF_VOPS|TDF_MEMSYMS);
+}
+
+DEBUG_FUNCTION void
+debug_omp_expr (tree t)
+{
+ print_omp_expr (t);
+ fprintf (stderr, "\n");
+}
+
/* Debugging function to print out a chain of trees . */
DEBUG_FUNCTION void
@@ -33,6 +33,7 @@ along with GCC; see the file COPYING3. If not see
extern void debug_generic_expr (tree);
extern void debug_generic_stmt (tree);
+extern void debug_omp_expr (tree);
extern void debug_tree_chain (tree);
extern void print_generic_decl (FILE *, tree, dump_flags_t);
extern void print_generic_stmt (FILE *, tree, dump_flags_t = TDF_NONE);