context->tabstop = 8;
context->escape_format = DIAGNOSTICS_ESCAPE_FORMAT_UNICODE;
context->edit_context_ptr = NULL;
- context->diagnostic_group_nesting_depth = 0;
- context->diagnostic_group_emission_count = 0;
+ context->m_diagnostic_groups.m_nesting_depth = 0;
+ context->m_diagnostic_groups.m_emission_count = 0;
context->m_output_format = new diagnostic_text_output_format (*context);
context->set_locations_cb = nullptr;
context->ice_handler_cb = NULL;
++diagnostic_kind_count (context, diagnostic->kind);
/* Is this the initial diagnostic within the stack of groups? */
- if (context->diagnostic_group_emission_count == 0)
+ if (context->m_diagnostic_groups.m_emission_count == 0)
context->m_output_format->on_begin_group ();
- context->diagnostic_group_emission_count++;
+ context->m_diagnostic_groups.m_emission_count++;
pp_format (context->printer, &diagnostic->message);
context->m_output_format->on_begin_diagnostic (diagnostic);
internal_error ("in %s, at %s:%d", function, trim_filename (file), line);
}
+/* struct diagnostic_context. */
+
+void
+diagnostic_context::begin_group ()
+{
+ m_diagnostic_groups.m_nesting_depth++;
+}
+
+void
+diagnostic_context::end_group ()
+{
+ if (--m_diagnostic_groups.m_nesting_depth == 0)
+ {
+ /* Handle the case where we've popped the final diagnostic group.
+ If any diagnostics were emitted, give the context a chance
+ to do something. */
+ if (m_diagnostic_groups.m_emission_count > 0)
+ m_output_format->on_end_group ();
+ m_diagnostic_groups.m_emission_count = 0;
+ }
+}
+
/* class auto_diagnostic_group. */
/* Constructor: "push" this group into global_dc. */
auto_diagnostic_group::auto_diagnostic_group ()
{
- global_dc->diagnostic_group_nesting_depth++;
+ global_dc->begin_group ();
}
/* Destructor: "pop" this group from global_dc. */
auto_diagnostic_group::~auto_diagnostic_group ()
{
- if (--global_dc->diagnostic_group_nesting_depth == 0)
- {
- /* Handle the case where we've popped the final diagnostic group.
- If any diagnostics were emitted, give the context a chance
- to do something. */
- if (global_dc->diagnostic_group_emission_count > 0)
- global_dc->m_output_format->on_end_group ();
- global_dc->diagnostic_group_emission_count = 0;
- }
+ global_dc->end_group ();
}
/* class diagnostic_text_output_format : public diagnostic_output_format. */
the context of a diagnostic message. */
struct diagnostic_context
{
+public:
+ void begin_group ();
+ void end_group ();
+
+public:
+
/* Where most of the diagnostic formatting work is done. */
pretty_printer *printer;
applied, for generating patches. */
edit_context *edit_context_ptr;
- /* How many diagnostic_group instances are currently alive. */
- int diagnostic_group_nesting_depth;
+ /* Fields relating to diagnostic groups. */
+ struct {
+ /* How many diagnostic_group instances are currently alive. */
+ int m_nesting_depth;
- /* How many diagnostics have been emitted since the bottommost
- diagnostic_group was pushed. */
- int diagnostic_group_emission_count;
+ /* How many diagnostics have been emitted since the bottommost
+ diagnostic_group was pushed. */
+ int m_emission_count;
+ } m_diagnostic_groups;
/* How to output diagnostics (text vs a structured format such as JSON).
Must be non-NULL; owned by context. */