X-Git-Url: http://git.sourceforge.jp/view?a=blobdiff_plain;f=gcc%2Fpretty-print.c;h=8aa99787c59ab5fe5fa77d34f5498f74ca6a0a10;hb=5d25efc0fd72fef10dbc606561fade95f2c99a88;hp=d531075c933bdc98962fa88c6f61997a18e43242;hpb=27746e01e73b4caa0b4c6237ce6f21c8c5c1eb6c;p=pf3gnuchains%2Fgcc-fork.git diff --git a/gcc/pretty-print.c b/gcc/pretty-print.c index d531075c933..8aa99787c59 100644 --- a/gcc/pretty-print.c +++ b/gcc/pretty-print.c @@ -1,5 +1,6 @@ /* Various declarations for language-independent pretty-print subroutines. - Copyright (C) 2003, 2004, 2005, 2007, 2008 Free Software Foundation, Inc. + Copyright (C) 2003, 2004, 2005, 2007, 2008, 2009, 2010 + Free Software Foundation, Inc. Contributed by Gabriel Dos Reis This file is part of GCC. @@ -19,22 +20,15 @@ along with GCC; see the file COPYING3. If not see . */ #include "config.h" -#undef FLOAT /* This is for hpux. They should change hpux. */ -#undef FFS /* Some systems define this in param.h. */ #include "system.h" #include "coretypes.h" #include "intl.h" #include "pretty-print.h" -#include "tree.h" -#include "ggc.h" #if HAVE_ICONV #include #endif -#define obstack_chunk_alloc xmalloc -#define obstack_chunk_free free - /* A pointer to the formatted diagnostic message. */ #define pp_formatted_text_data(PP) \ ((const char *) obstack_base (pp_base (PP)->buffer->obstack)) @@ -190,9 +184,6 @@ pp_base_indent (pretty_printer *pp) %.*s: a substring the length of which is specified by an argument integer. %Ns: likewise, but length specified as constant in the format string. - %H: location_t. - %J: a decl tree, from which DECL_SOURCE_LOCATION will be recorded. - %K: a statement, from which EXPR_LOCATION and TREE_BLOCK will be recorded. Flag 'q': quote formatted text (must come immediately after '%'). Arguments can be used sequentially, or through %N$ resp. *N$ @@ -235,7 +226,7 @@ pp_base_format (pretty_printer *pp, text_info *text) this point. */ memset (formatters, 0, sizeof formatters); - + for (p = text->format_spec; *p; ) { while (*p != '\0' && *p != '%') @@ -251,7 +242,7 @@ pp_base_format (pretty_printer *pp, text_info *text) { case '\0': gcc_unreachable (); - + case '%': obstack_1grow (&buffer->chunk_obstack, '%'); p++; @@ -368,7 +359,7 @@ pp_base_format (pretty_printer *pp, text_info *text) gcc_assert (chunk < PP_NL_ARGMAX * 2); args[chunk++] = XOBFINISH (&buffer->chunk_obstack, const char *); args[chunk] = 0; - + /* Set output to the argument obstack, and switch line-wrapping and prefixing off. */ buffer->obstack = &buffer->chunk_obstack; @@ -476,51 +467,6 @@ pp_base_format (pretty_printer *pp, text_info *text) (pp, *text->args_ptr, precision, unsigned, "x"); break; - case 'H': - { - location_t *locus = va_arg (*text->args_ptr, location_t *); - gcc_assert (text->locus != NULL); - *text->locus = *locus; - } - break; - - case 'J': - { - tree t = va_arg (*text->args_ptr, tree); - gcc_assert (text->locus != NULL); - *text->locus = DECL_SOURCE_LOCATION (t); - } - break; - - case 'K': - { - tree t = va_arg (*text->args_ptr, tree), block; - gcc_assert (text->locus != NULL); - *text->locus = EXPR_LOCATION (t); - gcc_assert (text->abstract_origin != NULL); - block = TREE_BLOCK (t); - *text->abstract_origin = NULL; - while (block - && TREE_CODE (block) == BLOCK - && BLOCK_ABSTRACT_ORIGIN (block)) - { - tree ao = BLOCK_ABSTRACT_ORIGIN (block); - - while (TREE_CODE (ao) == BLOCK - && BLOCK_ABSTRACT_ORIGIN (ao) - && BLOCK_ABSTRACT_ORIGIN (ao) != ao) - ao = BLOCK_ABSTRACT_ORIGIN (ao); - - if (TREE_CODE (ao) == FUNCTION_DECL) - { - *text->abstract_origin = block; - break; - } - block = BLOCK_SUPERCONTEXT (block); - } - } - break; - case '.': { int n; @@ -719,6 +665,7 @@ pp_construct (pretty_printer *pp, const char *prefix, int maximum_length) pp_line_cutoff (pp) = maximum_length; pp_prefixing_rule (pp) = DIAGNOSTICS_SHOW_PREFIX_ONCE; pp_set_prefix (pp, prefix); + pp_translate_identifiers (pp) = true; } /* Append a string delimited by START and END to the output area of @@ -849,15 +796,6 @@ pp_base_maybe_space (pretty_printer *pp) pp_base (pp)->padding = pp_none; } } - -/* Print the identifier ID to PRETTY-PRINTER. */ - -void -pp_base_tree_identifier (pretty_printer *pp, tree id) -{ - const char *text = identifier_to_locale (IDENTIFIER_POINTER (id)); - pp_append_text (pp, text, text + strlen (text)); -} /* The string starting at P has LEN (at least 1) bytes left; if they start with a valid UTF-8 sequence, return the length of that @@ -915,14 +853,21 @@ decode_utf8_char (const unsigned char *p, size_t len, unsigned int *value) } } +/* Allocator for identifier_to_locale and corresponding function to + free memory. */ + +void *(*identifier_to_locale_alloc) (size_t) = xmalloc; +void (*identifier_to_locale_free) (void *) = free; + /* Given IDENT, an identifier in the internal encoding, return a version of IDENT suitable for diagnostics in the locale character - set: either IDENT itself, or a garbage-collected string converted - to the locale character set and using escape sequences if not - representable in the locale character set or containing control - characters or invalid byte sequences. Existing backslashes in - IDENT are not doubled, so the result may not uniquely specify the - contents of an arbitrary byte sequence identifier. */ + set: either IDENT itself, or a string, allocated using + identifier_to_locale_alloc, converted to the locale character set + and using escape sequences if not representable in the locale + character set or containing control characters or invalid byte + sequences. Existing backslashes in IDENT are not doubled, so the + result may not uniquely specify the contents of an arbitrary byte + sequence identifier. */ const char * identifier_to_locale (const char *ident) @@ -953,7 +898,7 @@ identifier_to_locale (const char *ident) outside printable ASCII. */ if (!valid_printable_utf8) { - char *ret = GGC_NEWVEC (char, 4 * idlen + 1); + char *ret = (char *) identifier_to_locale_alloc (4 * idlen + 1); char *p = ret; for (i = 0; i < idlen; i++) { @@ -996,7 +941,7 @@ identifier_to_locale (const char *ident) size_t outbytesleft = ret_alloc - 1; size_t iconv_ret; - ret = GGC_NEWVEC (char, ret_alloc); + ret = (char *) identifier_to_locale_alloc (ret_alloc); outbuf = ret; if (iconv (cd, 0, 0, 0, 0) == (size_t) -1) @@ -1012,7 +957,7 @@ identifier_to_locale (const char *ident) if (errno == E2BIG) { ret_alloc *= 2; - ggc_free (ret); + identifier_to_locale_free (ret); ret = NULL; continue; } @@ -1033,7 +978,7 @@ identifier_to_locale (const char *ident) if (errno == E2BIG) { ret_alloc *= 2; - ggc_free (ret); + identifier_to_locale_free (ret); ret = NULL; continue; } @@ -1055,7 +1000,7 @@ identifier_to_locale (const char *ident) /* Otherwise, convert non-ASCII characters in IDENT to UCNs. */ { - char *ret = GGC_NEWVEC (char, 10 * idlen + 1); + char *ret = (char *) identifier_to_locale_alloc (10 * idlen + 1); char *p = ret; for (i = 0; i < idlen;) {