@@ -48,7 +48,7 @@ class sarif_invocation : public sarif_object
48
48
{}
49
49
50
50
void add_notification_for_ice (diagnostic_context *context,
51
- diagnostic_info * diagnostic,
51
+ const diagnostic_info & diagnostic,
52
52
sarif_builder *builder);
53
53
void prepare_to_flush (diagnostic_context *context);
54
54
@@ -67,7 +67,7 @@ class sarif_result : public sarif_object
67
67
68
68
void
69
69
on_nested_diagnostic (diagnostic_context *context,
70
- diagnostic_info * diagnostic,
70
+ const diagnostic_info & diagnostic,
71
71
diagnostic_t orig_diag_kind,
72
72
sarif_builder *builder);
73
73
void on_diagram (diagnostic_context *context,
@@ -90,7 +90,7 @@ class sarif_ice_notification : public sarif_object
90
90
{
91
91
public:
92
92
sarif_ice_notification (diagnostic_context *context,
93
- diagnostic_info * diagnostic,
93
+ const diagnostic_info & diagnostic,
94
94
sarif_builder *builder);
95
95
};
96
96
@@ -159,15 +159,16 @@ class sarif_builder
159
159
public:
160
160
sarif_builder (diagnostic_context *context);
161
161
162
- void end_diagnostic (diagnostic_context *context, diagnostic_info *diagnostic,
162
+ void end_diagnostic (diagnostic_context *context,
163
+ const diagnostic_info &diagnostic,
163
164
diagnostic_t orig_diag_kind);
164
165
void emit_diagram (diagnostic_context *context,
165
166
const diagnostic_diagram &diagram);
166
167
void end_group ();
167
168
168
169
void flush_to_file (FILE *outf);
169
170
170
- json::array *make_locations_arr (diagnostic_info * diagnostic);
171
+ json::array *make_locations_arr (const diagnostic_info & diagnostic);
171
172
json::object *make_location_object (const rich_location &rich_loc,
172
173
const logical_location *logical_loc);
173
174
json::object *make_message_object (const char *msg) const ;
@@ -177,7 +178,7 @@ class sarif_builder
177
178
178
179
private:
179
180
sarif_result *make_result_object (diagnostic_context *context,
180
- diagnostic_info * diagnostic,
181
+ const diagnostic_info & diagnostic,
181
182
diagnostic_t orig_diag_kind);
182
183
void set_any_logical_locs_arr (json::object *location_obj,
183
184
const logical_location *logical_loc);
@@ -208,7 +209,7 @@ class sarif_builder
208
209
json::object *make_tool_component_reference_object_for_cwe () const ;
209
210
json::object *
210
211
make_reporting_descriptor_object_for_warning (diagnostic_context *context,
211
- diagnostic_info * diagnostic,
212
+ const diagnostic_info & diagnostic,
212
213
diagnostic_t orig_diag_kind,
213
214
const char *option_text);
214
215
json::object *make_reporting_descriptor_object_for_cwe_id (int cwe_id) const ;
@@ -275,7 +276,7 @@ sarif_object::get_or_create_properties ()
275
276
276
277
void
277
278
sarif_invocation::add_notification_for_ice (diagnostic_context *context,
278
- diagnostic_info * diagnostic,
279
+ const diagnostic_info & diagnostic,
279
280
sarif_builder *builder)
280
281
{
281
282
m_success = false ;
@@ -310,15 +311,15 @@ sarif_invocation::prepare_to_flush (diagnostic_context *context)
310
311
311
312
void
312
313
sarif_result::on_nested_diagnostic (diagnostic_context *context,
313
- diagnostic_info * diagnostic,
314
+ const diagnostic_info & diagnostic,
314
315
diagnostic_t /* orig_diag_kind*/ ,
315
316
sarif_builder *builder)
316
317
{
317
318
/* We don't yet generate meaningful logical locations for notes;
318
319
sometimes these will related to current_function_decl, but
319
320
often they won't. */
320
321
json::object *location_obj
321
- = builder->make_location_object (*diagnostic-> richloc , NULL );
322
+ = builder->make_location_object (*diagnostic. richloc , NULL );
322
323
json::object *message_obj
323
324
= builder->make_message_object (pp_formatted_text (context->printer ));
324
325
pp_clear_output_area (context->printer );
@@ -366,7 +367,7 @@ sarif_result::add_related_location (json::object *location_obj)
366
367
DIAGNOSTIC is an internal compiler error. */
367
368
368
369
sarif_ice_notification::sarif_ice_notification (diagnostic_context *context,
369
- diagnostic_info * diagnostic,
370
+ const diagnostic_info & diagnostic,
370
371
sarif_builder *builder)
371
372
{
372
373
/* "locations" property (SARIF v2.1.0 section 3.58.4). */
@@ -416,10 +417,10 @@ sarif_builder::sarif_builder (diagnostic_context *context)
416
417
417
418
void
418
419
sarif_builder::end_diagnostic (diagnostic_context *context,
419
- diagnostic_info * diagnostic,
420
+ const diagnostic_info & diagnostic,
420
421
diagnostic_t orig_diag_kind)
421
422
{
422
- if (diagnostic-> kind == DK_ICE || diagnostic-> kind == DK_ICE_NOBT)
423
+ if (diagnostic. kind == DK_ICE || diagnostic. kind == DK_ICE_NOBT)
423
424
{
424
425
m_invocation_obj->add_notification_for_ice (context, diagnostic, this );
425
426
return ;
@@ -528,16 +529,16 @@ make_rule_id_for_diagnostic_kind (diagnostic_t diag_kind)
528
529
529
530
sarif_result *
530
531
sarif_builder::make_result_object (diagnostic_context *context,
531
- diagnostic_info * diagnostic,
532
+ const diagnostic_info & diagnostic,
532
533
diagnostic_t orig_diag_kind)
533
534
{
534
535
sarif_result *result_obj = new sarif_result ();
535
536
536
537
/* "ruleId" property (SARIF v2.1.0 section 3.27.5). */
537
538
/* Ideally we'd have an option_name for these. */
538
539
if (char *option_text
539
- = context->make_option_name (diagnostic-> option_index ,
540
- orig_diag_kind, diagnostic-> kind ))
540
+ = context->make_option_name (diagnostic. option_index ,
541
+ orig_diag_kind, diagnostic. kind ))
541
542
{
542
543
/* Lazily create reportingDescriptor objects for and add to m_rules_arr.
543
544
Set ruleId referencing them. */
@@ -569,10 +570,10 @@ sarif_builder::make_result_object (diagnostic_context *context,
569
570
free (rule_id);
570
571
}
571
572
572
- if (diagnostic-> metadata )
573
+ if (diagnostic. metadata )
573
574
{
574
575
/* "taxa" property (SARIF v2.1.0 section 3.27.8). */
575
- if (int cwe_id = diagnostic-> metadata ->get_cwe ())
576
+ if (int cwe_id = diagnostic. metadata ->get_cwe ())
576
577
{
577
578
json::array *taxa_arr = new json::array ();
578
579
json::object *cwe_id_obj
@@ -581,11 +582,11 @@ sarif_builder::make_result_object (diagnostic_context *context,
581
582
result_obj->set (" taxa" , taxa_arr);
582
583
}
583
584
584
- diagnostic-> metadata ->maybe_add_sarif_properties (*result_obj);
585
+ diagnostic. metadata ->maybe_add_sarif_properties (*result_obj);
585
586
}
586
587
587
588
/* "level" property (SARIF v2.1.0 section 3.27.10). */
588
- if (const char *sarif_level = maybe_get_sarif_level (diagnostic-> kind ))
589
+ if (const char *sarif_level = maybe_get_sarif_level (diagnostic. kind ))
589
590
result_obj->set_string (" level" , sarif_level);
590
591
591
592
/* "message" property (SARIF v2.1.0 section 3.27.11). */
@@ -599,7 +600,7 @@ sarif_builder::make_result_object (diagnostic_context *context,
599
600
result_obj->set (" locations" , locations_arr);
600
601
601
602
/* "codeFlows" property (SARIF v2.1.0 section 3.27.18). */
602
- if (const diagnostic_path *path = diagnostic-> richloc ->get_path ())
603
+ if (const diagnostic_path *path = diagnostic. richloc ->get_path ())
603
604
{
604
605
json::array *code_flows_arr = new json::array ();
605
606
json::object *code_flow_obj = make_code_flow_object (*path);
@@ -612,7 +613,7 @@ sarif_builder::make_result_object (diagnostic_context *context,
612
613
group. */
613
614
614
615
/* "fixes" property (SARIF v2.1.0 section 3.27.30). */
615
- const rich_location *richloc = diagnostic-> richloc ;
616
+ const rich_location *richloc = diagnostic. richloc ;
616
617
if (richloc->get_num_fixit_hints ())
617
618
{
618
619
json::array *fix_arr = new json::array ();
@@ -630,7 +631,7 @@ sarif_builder::make_result_object (diagnostic_context *context,
630
631
json::object *
631
632
sarif_builder::
632
633
make_reporting_descriptor_object_for_warning (diagnostic_context *context,
633
- diagnostic_info * diagnostic,
634
+ const diagnostic_info & diagnostic,
634
635
diagnostic_t /* orig_diag_kind*/ ,
635
636
const char *option_text)
636
637
{
@@ -643,7 +644,7 @@ make_reporting_descriptor_object_for_warning (diagnostic_context *context,
643
644
it seems redundant compared to "id". */
644
645
645
646
/* "helpUri" property (SARIF v2.1.0 section 3.49.12). */
646
- if (char *option_url = context->make_option_url (diagnostic-> option_index ))
647
+ if (char *option_url = context->make_option_url (diagnostic. option_index ))
647
648
{
648
649
reporting_desc->set_string (" helpUri" , option_url);
649
650
free (option_url);
@@ -725,15 +726,15 @@ make_tool_component_reference_object_for_cwe () const
725
726
- a "notification" object (SARIF v2.1.0 section 3.58.4). */
726
727
727
728
json::array *
728
- sarif_builder::make_locations_arr (diagnostic_info * diagnostic)
729
+ sarif_builder::make_locations_arr (const diagnostic_info & diagnostic)
729
730
{
730
731
json::array *locations_arr = new json::array ();
731
732
const logical_location *logical_loc = NULL ;
732
733
if (auto client_data_hooks = m_context->get_client_data_hooks ())
733
734
logical_loc = client_data_hooks->get_current_logical_location ();
734
735
735
736
json::object *location_obj
736
- = make_location_object (*diagnostic-> richloc , logical_loc);
737
+ = make_location_object (*diagnostic. richloc , logical_loc);
737
738
locations_arr->append (location_obj);
738
739
return locations_arr;
739
740
}
@@ -1704,12 +1705,12 @@ class sarif_output_format : public diagnostic_output_format
1704
1705
m_builder.end_group ();
1705
1706
}
1706
1707
void
1707
- on_begin_diagnostic (diagnostic_info * ) final override
1708
+ on_begin_diagnostic (const diagnostic_info & ) final override
1708
1709
{
1709
1710
/* No-op, */
1710
1711
}
1711
1712
void
1712
- on_end_diagnostic (diagnostic_info * diagnostic,
1713
+ on_end_diagnostic (const diagnostic_info & diagnostic,
1713
1714
diagnostic_t orig_diag_kind) final override
1714
1715
{
1715
1716
m_builder.end_diagnostic (&m_context, diagnostic, orig_diag_kind);
0 commit comments