Commit 6b67c26e by Gabriel Dos Reis Committed by Gabriel Dos Reis

diagnostic.h: Add documentation.

2001-06-27  Gabriel Dos Reis  <gdr@codesourcery.com>

	* diagnostic.h: Add documentation. Make macros polymorphic.
	* diagnostic.c (ideal_line_wrap_cutoff): Remove
	definition. Replace with diagnostic_line_cutoff.
	(prefixing_policy): Remove. Replace with diagnostic_prefixing_rule.

From-SVN: r43616
parent a8b997e8
2001-06-27 Gabriel Dos Reis <gdr@codesourcery.com>
* diagnostic.h: Add documentation. Make macros polymorphic.
* diagnostic.c (ideal_line_wrap_cutoff): Remove
definition. Replace with diagnostic_line_cutoff.
(prefixing_policy): Remove. Replace with diagnostic_prefixing_rule.
2001-06-27 Joseph S. Myers <jsm28@cam.ac.uk> 2001-06-27 Joseph S. Myers <jsm28@cam.ac.uk>
* doc/c-tree.texi, doc/contrib.texi, doc/cpp.texi, * doc/c-tree.texi, doc/contrib.texi, doc/cpp.texi,
......
...@@ -52,9 +52,7 @@ Boston, MA 02111-1307, USA. */ ...@@ -52,9 +52,7 @@ Boston, MA 02111-1307, USA. */
#define is_starting_newline(BUFFER) (output_text_length (BUFFER) == 0) #define is_starting_newline(BUFFER) (output_text_length (BUFFER) == 0)
#define output_prefix(BUFFER) (BUFFER)->state.prefix #define output_prefix(BUFFER) (BUFFER)->state.prefix
#define line_wrap_cutoff(BUFFER) (BUFFER)->state.maximum_length #define line_wrap_cutoff(BUFFER) (BUFFER)->state.maximum_length
#define ideal_line_wrap_cutoff(BUFFER) (BUFFER)->state.ideal_maximum_length
#define prefix_was_emitted_for(BUFFER) (BUFFER)->state.emitted_prefix_p #define prefix_was_emitted_for(BUFFER) (BUFFER)->state.emitted_prefix_p
#define prefixing_policy(BUFFER) (BUFFER)->state.prefixing_rule
#define output_buffer_ptr_to_format_args(BUFFER) (BUFFER)->state.format_args #define output_buffer_ptr_to_format_args(BUFFER) (BUFFER)->state.format_args
#define diagnostic_args output_buffer_ptr_to_format_args (diagnostic_buffer) #define diagnostic_args output_buffer_ptr_to_format_args (diagnostic_buffer)
...@@ -189,7 +187,7 @@ int ...@@ -189,7 +187,7 @@ int
output_is_line_wrapping (buffer) output_is_line_wrapping (buffer)
output_buffer *buffer; output_buffer *buffer;
{ {
return ideal_line_wrap_cutoff (buffer) > 0; return diagnostic_line_cutoff (buffer) > 0;
} }
/* Return BUFFER's prefix. */ /* Return BUFFER's prefix. */
...@@ -212,19 +210,19 @@ set_real_maximum_length (buffer) ...@@ -212,19 +210,19 @@ set_real_maximum_length (buffer)
we'll emit prefix only once per diagnostic message, it is appropriate we'll emit prefix only once per diagnostic message, it is appropriate
not to increase unncessarily the line-length cut-off. */ not to increase unncessarily the line-length cut-off. */
if (! output_is_line_wrapping (buffer) if (! output_is_line_wrapping (buffer)
|| prefixing_policy (buffer) == DIAGNOSTICS_SHOW_PREFIX_ONCE || diagnostic_prefixing_rule (buffer) == DIAGNOSTICS_SHOW_PREFIX_ONCE
|| prefixing_policy (buffer) == DIAGNOSTICS_SHOW_PREFIX_NEVER) || diagnostic_prefixing_rule (buffer) == DIAGNOSTICS_SHOW_PREFIX_NEVER)
line_wrap_cutoff (buffer) = ideal_line_wrap_cutoff (buffer); line_wrap_cutoff (buffer) = diagnostic_line_cutoff (buffer);
else else
{ {
int prefix_length = int prefix_length =
output_prefix (buffer) ? strlen (output_prefix (buffer)) : 0; output_prefix (buffer) ? strlen (output_prefix (buffer)) : 0;
/* If the prefix is ridiculously too long, output at least /* If the prefix is ridiculously too long, output at least
32 characters. */ 32 characters. */
if (ideal_line_wrap_cutoff (buffer) - prefix_length < 32) if (diagnostic_line_cutoff (buffer) - prefix_length < 32)
line_wrap_cutoff (buffer) = ideal_line_wrap_cutoff (buffer) + 32; line_wrap_cutoff (buffer) = diagnostic_line_cutoff (buffer) + 32;
else else
line_wrap_cutoff (buffer) = ideal_line_wrap_cutoff (buffer); line_wrap_cutoff (buffer) = diagnostic_line_cutoff (buffer);
} }
} }
...@@ -236,7 +234,7 @@ output_set_maximum_length (buffer, length) ...@@ -236,7 +234,7 @@ output_set_maximum_length (buffer, length)
output_buffer *buffer; output_buffer *buffer;
int length; int length;
{ {
ideal_line_wrap_cutoff (buffer) = length; diagnostic_line_cutoff (buffer) = length;
set_real_maximum_length (buffer); set_real_maximum_length (buffer);
} }
...@@ -313,8 +311,8 @@ init_output_buffer (buffer, prefix, maximum_length) ...@@ -313,8 +311,8 @@ init_output_buffer (buffer, prefix, maximum_length)
memset (buffer, 0, sizeof (output_buffer)); memset (buffer, 0, sizeof (output_buffer));
obstack_init (&buffer->obstack); obstack_init (&buffer->obstack);
output_buffer_attached_stream (buffer) = stderr; output_buffer_attached_stream (buffer) = stderr;
ideal_line_wrap_cutoff (buffer) = maximum_length; diagnostic_line_cutoff (buffer) = maximum_length;
prefixing_policy (buffer) = diagnostic_prefixing_rule (global_dc); diagnostic_prefixing_rule (buffer) = diagnostic_prefixing_rule (global_dc);
output_set_prefix (buffer, prefix); output_set_prefix (buffer, prefix);
output_text_length (buffer) = 0; output_text_length (buffer) = 0;
clear_diagnostic_info (buffer); clear_diagnostic_info (buffer);
...@@ -366,7 +364,7 @@ output_emit_prefix (buffer) ...@@ -366,7 +364,7 @@ output_emit_prefix (buffer)
{ {
if (output_prefix (buffer) != NULL) if (output_prefix (buffer) != NULL)
{ {
switch (prefixing_policy (buffer)) switch (diagnostic_prefixing_rule (buffer))
{ {
default: default:
case DIAGNOSTICS_SHOW_PREFIX_NEVER: case DIAGNOSTICS_SHOW_PREFIX_NEVER:
...@@ -1559,7 +1557,7 @@ output_do_verbatim (buffer, msgid, args_ptr) ...@@ -1559,7 +1557,7 @@ output_do_verbatim (buffer, msgid, args_ptr)
os = output_buffer_state (buffer); os = output_buffer_state (buffer);
output_prefix (buffer) = NULL; output_prefix (buffer) = NULL;
prefixing_policy (buffer) = DIAGNOSTICS_SHOW_PREFIX_NEVER; diagnostic_prefixing_rule (buffer) = DIAGNOSTICS_SHOW_PREFIX_NEVER;
output_buffer_text_cursor (buffer) = _(msgid); output_buffer_text_cursor (buffer) = _(msgid);
output_buffer_ptr_to_format_args (buffer) = args_ptr; output_buffer_ptr_to_format_args (buffer) = args_ptr;
output_set_maximum_length (buffer, 0); output_set_maximum_length (buffer, 0);
......
...@@ -76,10 +76,10 @@ typedef struct ...@@ -76,10 +76,10 @@ typedef struct
int indent_skip; int indent_skip;
/* Nonzero if current PREFIX was emitted at least once. */ /* Nonzero if current PREFIX was emitted at least once. */
int emitted_prefix_p; bool emitted_prefix_p;
/* Nonzero means one should emit a newline before outputing anything. */ /* Nonzero means one should emit a newline before outputing anything. */
int need_newline_p; bool need_newline_p;
/* Current prefixing rule. */ /* Current prefixing rule. */
diagnostic_prefixing_rule_t prefixing_rule; diagnostic_prefixing_rule_t prefixing_rule;
...@@ -130,13 +130,30 @@ struct output_buffer ...@@ -130,13 +130,30 @@ struct output_buffer
printer_fn format_decoder; printer_fn format_decoder;
}; };
#define output_buffer_state(BUFFER) (BUFFER)->state /* Current state of the diagnostic_context' output_buffer. This macro
accepts both `diagnostic_context *' and `output_buffer *'. */
#define output_buffer_state(BUFFER) ((output_buffer *)BUFFER)->state
/* The stream attached to the output_buffer, where the formatted
diagnostics will ultimately go. Works only on `output_buffer *'. */
#define output_buffer_attached_stream(BUFFER) (BUFFER)->stream #define output_buffer_attached_stream(BUFFER) (BUFFER)->stream
/* This points to the beginning of the rest of the diagnostic message
to be formatted. Accepts only `output_buffer *'s. */
#define output_buffer_text_cursor(BUFFER) (BUFFER)->state.cursor #define output_buffer_text_cursor(BUFFER) (BUFFER)->state.cursor
#define output_buffer_format_args(BUFFER) *((BUFFER)->state.format_args)
/* The rest of the `variable argument list' not yet processed.
This macro works on both `output_state *' and `output_buffer *'. */
#define output_buffer_format_args(BUFFER) \
*(((output_state *)BUFFER)->format_args)
/* In line-wrapping mode, whether we should start a new line. */
#define output_needs_newline(BUFFER) (BUFFER)->state.need_newline_p #define output_needs_newline(BUFFER) (BUFFER)->state.need_newline_p
#define output_buffer_state(BUFFER) (BUFFER)->state
/* The amount of whitespace to be emitted when starting a new line. */
#define output_indentation(BUFFER) (BUFFER)->state.indent_skip #define output_indentation(BUFFER) (BUFFER)->state.indent_skip
/* A pointer to the formatted diagonstic message. */
#define output_message_text(BUFFER) \ #define output_message_text(BUFFER) \
((const char *) obstack_base (&(BUFFER)->obstack)) ((const char *) obstack_base (&(BUFFER)->obstack))
...@@ -181,39 +198,65 @@ struct diagnostic_context ...@@ -181,39 +198,65 @@ struct diagnostic_context
void *x_data; void *x_data;
}; };
/* The diagnostic message being formatted. */
#define diagnostic_message(DC) (DC)->message #define diagnostic_message(DC) (DC)->message
/* A pointer to the variable argument list used in a call
to a diagonstic routine. */
#define diagnostic_argument_list(DC) (DC)->args_ptr #define diagnostic_argument_list(DC) (DC)->args_ptr
/* The program file to which the diagnostic is referring to. */
#define diagnostic_file_location(DC) (DC)->file #define diagnostic_file_location(DC) (DC)->file
/* The program source line referred to in the diagnostic message. */
#define diagnostic_line_location(DC) (DC)->line #define diagnostic_line_location(DC) (DC)->line
/* Tell whether the diagnostic message is to be treated as a warning. */
#define diagnostic_is_warning(DC) (DC)->warn #define diagnostic_is_warning(DC) (DC)->warn
/* Client supplied function to announce a diagnostic. */
#define diagnostic_starter(DC) (DC)->begin_diagnostic #define diagnostic_starter(DC) (DC)->begin_diagnostic
/* Client supplied function called after a diagnostic message is
displayed. */
#define diagnostic_finalizer(DC) (DC)->end_diagnostic #define diagnostic_finalizer(DC) (DC)->end_diagnostic
/* Extention hook for client. */
#define diagnostic_auxiliary_data(DC) (DC)->x_data #define diagnostic_auxiliary_data(DC) (DC)->x_data
#define diagnostic_format_decoder(DC) (DC)->buffer.format_decoder
#define diagnostic_prefixing_rule(DC) (DC)->buffer.state.prefixing_rule /* Client supplied function used to decode formats. Can operate on both
`output_buffer *' and `diagnostic_context *'. */
#define diagnostic_format_decoder(DC) ((output_buffer *)DC)->format_decoder
/* Prefixing rule used in formatting a diagnostic message. Accepts both
`output_buffer *' and `diagnostic_context *'. */
#define diagnostic_prefixing_rule(DC) \
((output_buffer *)DC)->state.prefixing_rule
/* Maximum characters per line in automatic line wrapping mode. /* Maximum characters per line in automatic line wrapping mode.
Zero means don't wrap lines. */ Zero means don't wrap lines. */
#define diagnostic_line_cutoff(DC) (DC)->buffer.state.ideal_maximum_length #define diagnostic_line_cutoff(DC) \
((output_buffer *)DC)->state.ideal_maximum_length
/* This output buffer is used by front-ends that directly output /* This diagnostic context is used by front-ends that directly output
diagnostic messages without going through `error', `warning', diagnostic messages without going through `error', `warning',
and similar functions. In general, such usage should be and similar functions. */
avoided. This global buffer will go away, once all such usage
has been removed. */
extern output_buffer *diagnostic_buffer;
extern diagnostic_context *global_dc; extern diagnostic_context *global_dc;
#define diagnostic_kind_count(BUFFER, DK) \ /* This will be removed shortly. */
(BUFFER)->state.diagnostic_count[(int) DK] extern output_buffer *diagnostic_buffer;
/* The total count of a KIND of diagnostics meitted so far. */
#define diagnostic_kind_count(DC, DK) \
((output_buffer *)DC)->state.diagnostic_count[(int) DK]
/* The number of errors that have been issued so far. Ideally, these /* The number of errors that have been issued so far. Ideally, these
would take an output_buffer as an argument. */ would take an output_buffer as an argument. */
#define errorcount diagnostic_kind_count (diagnostic_buffer, DK_ERROR) #define errorcount diagnostic_kind_count (global_dc, DK_ERROR)
/* Similarly, but for warnings. */ /* Similarly, but for warnings. */
#define warningcount diagnostic_kind_count (diagnostic_buffer, DK_WARNING) #define warningcount diagnostic_kind_count (global_dc, DK_WARNING)
/* Similarly, but for sorrys. */ /* Similarly, but for sorrys. */
#define sorrycount diagnostic_kind_count (diagnostic_buffer, DK_SORRY) #define sorrycount diagnostic_kind_count (global_dc, DK_SORRY)
/* Returns non-zero if warnings should be emitted. */ /* Returns non-zero if warnings should be emitted. */
#define diagnostic_report_warnings_p() \ #define diagnostic_report_warnings_p() \
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment