| 1 |
/* Example of GCC SARIF output for an insertion fix-it hint. */ |
| 2 |
|
| 3 |
{"$schema": "https://docs.oasis-open.org/sarif/sarif/v2.1.0/errata01/os/schemas/sarif-schema-2.1.0.json", |
| 4 |
"version": "2.1.0", |
| 5 |
"runs": [{"tool": {"driver": {"name": "GNU C23", |
| 6 |
"fullName": "GNU C23 (GCC) version 15.0.1 20250203 (experimental) (x86_64-pc-linux-gnu)", |
| 7 |
"version": "15.0.1 20250203 (experimental)", |
| 8 |
"informationUri": "https://gcc.gnu.org/gcc-15/", |
| 9 |
"rules": []}}, |
| 10 |
"invocations": [{"executionSuccessful": false, |
| 11 |
"toolExecutionNotifications": []}], |
| 12 |
"artifacts": [{"location": {"uri": "t.c", |
| 13 |
"uriBaseId": "PWD"}, |
| 14 |
"sourceLanguage": "c", |
| 15 |
"contents": {"text": "struct foo {};\n\nfoo *ptr;\n"}, |
| 16 |
"roles": ["analysisTarget"]}], |
| 17 |
"results": [{"ruleId": "error", |
| 18 |
"level": "error", |
| 19 |
"message": {"text": "unknown type name 'foo'; use 'struct' keyword to refer to the type"}, |
| 20 |
"locations": [{"physicalLocation": {"artifactLocation": {"uri": "t.c", |
| 21 |
"uriBaseId": "PWD"}, |
| 22 |
"region": {"startLine": 3, |
| 23 |
"startColumn": 1, |
| 24 |
"endColumn": 4}, |
| 25 |
"contextRegion": {"startLine": 3, |
| 26 |
"snippet": {"text": "foo *ptr;\n"}}}}], |
| 27 |
"fixes": [{"artifactChanges": [{"artifactLocation": {"uri": "t.c", |
| 28 |
"uriBaseId": "PWD"}, |
| 29 |
"replacements": [{"deletedRegion": {"startLine": 3, |
| 30 |
"startColumn": 1, |
| 31 |
"endColumn": 1}, |
| 32 |
"insertedContent": {"text": "struct "}}]}]}]}]}]} |
| 33 |
|
| 34 |
/* { dg-begin-multiline-output "" } |
| 35 |
t.c:3:1: error: unknown type name 'foo'; use 'struct' keyword to refer to the type |
| 36 |
3 | foo *ptr; |
| 37 |
| ^~~ |
| 38 |
| struct |
| 39 |
{ dg-end-multiline-output "" } */ |