C++ Logo

sg15

Advanced search

Re: SARIF for C++ Error Messages

From: Gabriel Dos Reis <gdr_at_[hidden]>
Date: Tue, 26 Jul 2022 16:44:24 +0000
+1 to having the SARIF working group extend for nesting level capability.

-- Gaby

From: SG15 <sg15-bounces_at_[hidden]> On Behalf Of Sy Brand via SG15
Sent: Tuesday, July 26, 2022 8:21 AM
To: 'Jonathan Wakely' <cxx_at_[hidden]>; 'ISO C++ Tooling Study Group' <sg15_at_[hidden]>
Cc: tartanllama_at_[hidden]
Subject: Re: [SG15] SARIF for C++ Error Messages

I agree that nesting of the diagnostics is an important feature. This is perhaps something we could take to the SARIF group as an area for extension and see if they have plans in the area and if there's room for collaboration?

Sy

From: Jonathan Wakely <cxx_at_[hidden]<mailto:cxx_at_[hidden]>>
Sent: marted́ 26 luglio 2022 15:15
To: ISO C++ Tooling Study Group <sg15_at_[hidden]<mailto:sg15_at_[hidden]>>
Cc: tartanllama_at_[hidden]<mailto:tartanllama_at_[hidden]>
Subject: Re: [SG15] SARIF for C++ Error Messages



On Tue, 26 Jul 2022 at 02:37, Sy Brand via SG15 <sg15_at_[hidden]<mailto:sg15_at_[hidden]>> wrote:
As discussed in the call about P2429<https://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Fwww.open-std.org%2Fjtc1%2Fsc22%2Fwg21%2Fdocs%2Fpapers%2F2022%2Fp2429r0.pdf&data=05%7C01%7Cgdr%40microsoft.com%7Cb745d14c2ad643fec44b08da6f1a76aa%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C637944457446426592%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=JVuTQUBrRWkTqKKBYTbraHa93vyF17pSj4ykHoKr%2B6A%3D&reserved=0>, some of us are going to look into SARIF<https://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Fsarifweb.azurewebsites.net%2F&data=05%7C01%7Cgdr%40microsoft.com%7Cb745d14c2ad643fec44b08da6f1a76aa%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C637944457446426592%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=PPeG3xS92M%2Fh7qKmKJJm9gyK%2BCL02AJhx8hJs59%2FFVI%3D&reserved=0> as a common target for C++ compiler error messages.

I'm going to ask the folks we have looking at SARIF to give their thoughts, please do send your own if you have experience with the format, or invite relevant colleagues with relevant expertise.

GCC trunk supports SARIF as output for diagnostics:
https://gcc.gnu.org/pipermail/gcc-patches/2022-June/596138.html<https://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgcc.gnu.org%2Fpipermail%2Fgcc-patches%2F2022-June%2F596138.html&data=05%7C01%7Cgdr%40microsoft.com%7Cb745d14c2ad643fec44b08da6f1a76aa%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C637944457446426592%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=v2hRu%2Bpqj6%2BHSO9X%2F5CaKn7G2QtwFopTanZLQvyG7Xg%3D&reserved=0>
https://github.com/oasis-tcs/sarif-spec/issues/531<https://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Foasis-tcs%2Fsarif-spec%2Fissues%2F531&data=05%7C01%7Cgdr%40microsoft.com%7Cb745d14c2ad643fec44b08da6f1a76aa%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C637944457446426592%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=ZBmYDFRkDVcw3nhTYmFHvBcxW8EmbxLD%2BSPdz%2FE7X5o%3D&reserved=0>
(The second link has some comments on SARIF from my colleague who implemented this in GCC.)

One issue he mentioned in the implementation is that SARIF doesn't support arbitrary nesting:

+/* Handle secondary diagnostics that occur within a diagnostic group.

+ The closest SARIF seems to have to nested diagnostics is the

+ "relatedLocations" property of result objects (SARIF v2.1.0 section 3.27.22),

+ so we lazily set this property and populate the array if and when

+ secondary diagnostics occur (such as notes to a warning). */

+
I'm already unhappy with GCC's one-level nesting, which prevents using two nesting levels for:

error: no matching call for f(x)
note: candidate f(int, int)
note: <reason candidate isn't viable>

Ideally I want the candidates nested under the error, and the reasons for failure nested under the candidates.





Received on 2022-07-26 16:44:27