https://gcc.gnu.org/bugzilla/show_bug.cgi?id=116176
Bug ID: 116176 Summary: SARIF output doesn't yet capture nesting of logical locations Product: gcc Version: unknown Status: UNCONFIRMED Keywords: SARIF Severity: normal Priority: P3 Component: other Assignee: unassigned at gcc dot gnu.org Reporter: dmalcolm at gcc dot gnu.org Target Milestone: --- Consider: namespace ns { class foo { void bar () { return 42; } }; } for which we emit: <source>: In member function 'void ns::foo::bar()': <source>:6:20: error: return-statement with a value, in function returning 'void' [-fpermissive] 6 | return 42; | ^~ Compiler returned: 1 g++ trunk with -fdiagnostics-format=sarif-stderr: https://godbolt.org/z/d6endYsr9 where the result has this logical location: "logicalLocations": [{"name": "bar", "fullyQualifiedName": "ns::foo::bar", "decoratedName": "_ZN2ns3foo3barEv", "kind": "function"}]}]}]}]} SARIF supports capturing the "ancestry" of a logical location via §3.33.8 parentIndex property, and can consolidate logical locations into the run via run.logicalLocations (§3.14.17), allowing a consumer to query e.g. "all results affecting namespace 'ns'". We should capture this ancestry in our SARIF output, and thus in this example emit logical locations for "class ns::foo" and for "namespace ns".