/* Various declarations for language-independent diagnostics subroutines.
- Copyright (C) 2000-2016 Free Software Foundation, Inc.
+ Copyright (C) 2000-2017 Free Software Foundation, Inc.
Contributed by Gabriel Dos Reis <gdr@codesourcery.com>
This file is part of GCC.
typedef diagnostic_starter_fn diagnostic_finalizer_fn;
+class edit_context;
+
/* This data structure bundles altogether any information relevant to
the context of a diagnostic message. */
struct diagnostic_context
int caret_max_width;
/* Character used for caret diagnostics. */
- char caret_chars[rich_location::MAX_RANGES];
+ char caret_chars[rich_location::STATICALLY_ALLOCATED_RANGES];
/* True if we should print the command line option which controls
each diagnostic, if known. */
bool dc_warn_system_headers;
/* Maximum number of errors to report. */
- unsigned int max_errors;
+ int max_errors;
/* This function is called before any message is printed out. It is
responsible for preparing message prefix and such. For example, it
/* Used to detect when the input file stack has changed since last
described. */
- const struct line_map *last_module;
+ const line_map_ordinary *last_module;
int lock;
/* Usable by plugins; if true, print a debugging ruler above the
source output. */
bool show_ruler_p;
+
+ /* If true, print fixits in machine-parseable form after the
+ rest of the diagnostic. */
+ bool parseable_fixits_p;
+
+ /* If non-NULL, an edit_context to which fix-it hints should be
+ applied, for generating patches. */
+ edit_context *edit_context_ptr;
};
static inline void
/* Same as output_prefixing_rule. Works on 'diagnostic_context *'. */
#define diagnostic_prefixing_rule(DC) ((DC)->printer->wrapping.rule)
-/* Maximum characters per line in automatic line wrapping mode.
- Zero means don't wrap lines. */
-#define diagnostic_line_cutoff(DC) ((DC)->printer->wrapping.line_cutoff)
-
-#define diagnostic_flush_buffer(DC) pp_flush ((DC)->printer)
-
-/* True if the last module or file in which a diagnostic was reported is
- different from the current one. */
-#define diagnostic_last_module_changed(DC, MAP) \
- ((DC)->last_module != MAP)
-
-/* Remember the current module or file as being the last one in which we
- report a diagnostic. */
-#define diagnostic_set_last_module(DC, MAP) \
- (DC)->last_module = MAP
-
/* Raise SIGABRT on any diagnostic of severity DK_ERROR or higher. */
#define diagnostic_abort_on_error(DC) \
(DC)->abort_on_error = true
(!(DC)->dc_inhibit_warnings \
&& !(in_system_header_at (LOC) && !(DC)->dc_warn_system_headers))
-#define report_diagnostic(D) diagnostic_report_diagnostic (global_dc, D)
-
/* Override the option index to be used for reporting a
diagnostic. */
-#define diagnostic_override_option_index(DI, OPTIDX) \
- ((DI)->option_index = (OPTIDX))
+
+static inline void
+diagnostic_override_option_index (diagnostic_info *info, int optidx)
+{
+ info->option_index = optidx;
+}
/* Diagnostic related functions. */
extern void diagnostic_initialize (diagnostic_context *, int);
extern void diagnostic_color_init (diagnostic_context *, int value = -1);
extern void diagnostic_finish (diagnostic_context *);
extern void diagnostic_report_current_module (diagnostic_context *, location_t);
-extern void diagnostic_show_locus (diagnostic_context *, const diagnostic_info *);
+extern void diagnostic_show_locus (diagnostic_context *,
+ rich_location *richloc,
+ diagnostic_t diagnostic_kind);
/* Force diagnostics controlled by OPTIDX to be kind KIND. */
extern diagnostic_t diagnostic_classify_diagnostic (diagnostic_context *,
void default_diagnostic_finalizer (diagnostic_context *, diagnostic_info *);
void diagnostic_set_caret_max_width (diagnostic_context *context, int value);
void diagnostic_action_after_output (diagnostic_context *, diagnostic_t);
+void diagnostic_check_max_errors (diagnostic_context *, bool flush = false);
void diagnostic_file_cache_fini (void);
/* This is somehow the right-side margin of a caret line, that is, we
print at least these many characters after the position pointed at
by the caret. */
-#define CARET_LINE_MARGIN 10
+const int CARET_LINE_MARGIN = 10;
/* Return true if the two locations can be represented within the same
caret line. This is used to build a prefix and also to determine