| 1 |
/* SARIF output for diagnostics. |
| 2 |
Copyright (C) 2023-2025 Free Software Foundation, Inc. |
| 3 |
Contributed by David Malcolm <[email protected]>. |
| 4 |
|
| 5 |
This file is part of GCC. |
| 6 |
|
| 7 |
GCC is free software; you can redistribute it and/or modify it under |
| 8 |
the terms of the GNU General Public License as published by the Free |
| 9 |
Software Foundation; either version 3, or (at your option) any later |
| 10 |
version. |
| 11 |
|
| 12 |
GCC is distributed in the hope that it will be useful, but WITHOUT ANY |
| 13 |
WARRANTY; without even the implied warranty of MERCHANTABILITY or |
| 14 |
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
| 15 |
for more details. |
| 16 |
|
| 17 |
You should have received a copy of the GNU General Public License |
| 18 |
along with GCC; see the file COPYING3. If not see |
| 19 |
<http://www.gnu.org/licenses/>. */ |
| 20 |
|
| 21 |
#ifndef GCC_DIAGNOSTIC_FORMAT_SARIF_H |
| 22 |
#define GCC_DIAGNOSTIC_FORMAT_SARIF_H |
| 23 |
|
| 24 |
#include "json.h" |
| 25 |
#include "diagnostic-format.h" |
| 26 |
#include "diagnostic-output-file.h" |
| 27 |
|
| 28 |
class logical_location; |
| 29 |
|
| 30 |
enum class sarif_version |
| 31 |
{ |
| 32 |
v2_1_0, |
| 33 |
v2_2_prerelease_2024_08_08, |
| 34 |
|
| 35 |
num_versions |
| 36 |
}; |
| 37 |
|
| 38 |
extern diagnostic_output_file |
| 39 |
diagnostic_output_format_open_sarif_file (diagnostic_context &context, |
| 40 |
line_maps *line_maps, |
| 41 |
const char *base_file_name); |
| 42 |
|
| 43 |
extern void |
| 44 |
diagnostic_output_format_init_sarif_stderr (diagnostic_context &context, |
| 45 |
const line_maps *line_maps, |
| 46 |
const char *main_input_filename_, |
| 47 |
bool formatted, |
| 48 |
enum sarif_version version); |
| 49 |
extern void |
| 50 |
diagnostic_output_format_init_sarif_file (diagnostic_context &context, |
| 51 |
line_maps *line_maps, |
| 52 |
const char *main_input_filename_, |
| 53 |
bool formatted, |
| 54 |
enum sarif_version version, |
| 55 |
const char *base_file_name); |
| 56 |
extern void |
| 57 |
diagnostic_output_format_init_sarif_stream (diagnostic_context &context, |
| 58 |
const line_maps *line_maps, |
| 59 |
const char *main_input_filename_, |
| 60 |
bool formatted, |
| 61 |
enum sarif_version version, |
| 62 |
FILE *stream); |
| 63 |
extern std::unique_ptr<diagnostic_output_format> |
| 64 |
make_sarif_sink (diagnostic_context &context, |
| 65 |
const line_maps &line_maps, |
| 66 |
const char *main_input_filename_, |
| 67 |
enum sarif_version version, |
| 68 |
diagnostic_output_file output_file); |
| 69 |
|
| 70 |
/* Concrete subclass of json::object for SARIF property bags |
| 71 |
(SARIF v2.1.0 section 3.8). */ |
| 72 |
|
| 73 |
class sarif_property_bag : public json::object |
| 74 |
{ |
| 75 |
}; |
| 76 |
|
| 77 |
/* Concrete subclass of json::object for SARIF objects that can |
| 78 |
contain property bags (as per SARIF v2.1.0 section 3.8.1, which has: |
| 79 |
"In addition to those properties that are explicitly documented, every |
| 80 |
object defined in this document MAY contain a property named properties |
| 81 |
whose value is a property bag.") */ |
| 82 |
|
| 83 |
class sarif_object : public json::object |
| 84 |
{ |
| 85 |
public: |
| 86 |
sarif_property_bag &get_or_create_properties (); |
| 87 |
}; |
| 88 |
|
| 89 |
/* Subclass of sarif_object for SARIF "logicalLocation" objects |
| 90 |
(SARIF v2.1.0 section 3.33). */ |
| 91 |
|
| 92 |
class sarif_logical_location : public sarif_object |
| 93 |
{ |
| 94 |
}; |
| 95 |
|
| 96 |
extern std::unique_ptr<sarif_logical_location> |
| 97 |
make_sarif_logical_location_object (const logical_location &logical_loc); |
| 98 |
|
| 99 |
#endif /* ! GCC_DIAGNOSTIC_FORMAT_SARIF_H */ |