diff options
author | Andrea Ornstein <andrea.ornstein@st.com> | 2008-04-23 10:01:32 +0000 |
---|---|---|
committer | Andrea Ornstein <andrea.ornstein@st.com> | 2008-04-23 10:01:32 +0000 |
commit | 406a1ec3d983afa3b50b0d7a95dccbea9942118c (patch) | |
tree | 074badedb20f00af5662a9c1d5f631b4cc24e8b7 | |
parent | 85f38a00f8f25b363e4727a66a37e7d42662274e (diff) |
print also DECL_ATTRIBUTES of methods in pretty-print
patch from Piotr Lesnicki
git-svn-id: https://gcc.gnu.org/svn/gcc/branches/st/cli@134587 138bc75d-0d04-0410-961f-82ee72b054a4
-rw-r--r-- | gcc/diagnostic.h | 1 | ||||
-rw-r--r-- | gcc/tree-cfg.c | 4 | ||||
-rw-r--r-- | gcc/tree-pretty-print.c | 63 |
3 files changed, 68 insertions, 0 deletions
diff --git a/gcc/diagnostic.h b/gcc/diagnostic.h index 94e5f32eb26..8b1f3f1ddaa 100644 --- a/gcc/diagnostic.h +++ b/gcc/diagnostic.h @@ -212,6 +212,7 @@ extern void print_generic_stmt (FILE *, tree, int); extern void print_generic_stmt_indented (FILE *, tree, int, int); extern void print_generic_expr (FILE *, tree, int); extern void print_generic_decl (FILE *, tree, int); +extern void print_generic_attributes (FILE *, tree, int); extern void debug_generic_expr (tree); extern void debug_generic_stmt (tree); diff --git a/gcc/tree-cfg.c b/gcc/tree-cfg.c index 26a5ac9c06f..2d0eb24457f 100644 --- a/gcc/tree-cfg.c +++ b/gcc/tree-cfg.c @@ -5672,6 +5672,10 @@ dump_function_to_file (tree fn, FILE *file, int flags) tree chain; struct function *saved_cfun; + + print_generic_attributes(file, DECL_ATTRIBUTES(fn), dump_flags); + fprintf(file, "\n"); + fprintf (file, "%s (", lang_hooks.decl_printable_name (fn, 2)); arg = DECL_ARGUMENTS (fn); diff --git a/gcc/tree-pretty-print.c b/gcc/tree-pretty-print.c index 77ecb95385d..635012af143 100644 --- a/gcc/tree-pretty-print.c +++ b/gcc/tree-pretty-print.c @@ -2086,6 +2086,9 @@ dump_generic_node (pretty_printer *buffer, tree node, int spc, int flags, NIY; } + + + if (is_stmt && is_expr) pp_semicolon (buffer); @@ -2097,6 +2100,60 @@ dump_generic_node (pretty_printer *buffer, tree node, int spc, int flags, return spc; } + +/* Print out an expression-list; E is expected to be a TREE_LIST. */ + +static void +print_expression_list (pretty_printer *pp, tree e,int spc, int flags) +{ + for (; e != NULL_TREE; e = TREE_CHAIN (e)) + { + dump_generic_node (pp, TREE_VALUE (e), spc, flags, false); + if (TREE_CHAIN (e)) + pp_separate_with (pp, ','); + } +} + + +/* print attributes */ + +static void +print_attributes (pretty_printer *pp, tree attributes, int spc, int flags) +{ + if (attributes == NULL_TREE) + return; + + pp_identifier (pp, "__attribute__"); + pp_left_paren (pp); + pp_left_paren (pp); + for (; attributes != NULL_TREE; attributes = TREE_CHAIN (attributes)) + { + pp_tree_identifier (pp, TREE_PURPOSE (attributes)); + if (TREE_VALUE (attributes)) + { + pp_left_paren (pp); + print_expression_list (pp, TREE_VALUE (attributes), spc, flags); + pp_right_paren (pp); + } + if (TREE_CHAIN (attributes)) + pp_separate_with (pp, ','); + } + pp_right_paren (pp); + pp_right_paren (pp); +} + +void +print_generic_attributes(FILE *file, tree attributes, int flags) +{ + maybe_init_pretty_print(file); + print_attributes(&buffer, attributes, flags, true); + + if (!(flags & TDF_DIAGNOSTIC)) + pp_write_text_to_stream (&buffer); + +} + + /* Print the declaration of a variable. */ static void @@ -2153,6 +2210,12 @@ print_declaration (pretty_printer *buffer, tree t, int spc, int flags) /* Print variable's name. */ pp_space (buffer); dump_generic_node (buffer, t, spc, flags, false); + + if (DECL_ATTRIBUTES (t)) + { + pp_space(buffer); + print_attributes(buffer, DECL_ATTRIBUTES(t), spc, flags); + } } if (TREE_CODE (t) == VAR_DECL && DECL_HARD_REGISTER (t)) |