https://gcc.gnu.org/bugzilla/show_bug.cgi?id=116392

            Bug ID: 116392
           Summary: RFE: capture inlining information in SARIF output
           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: ---

Similar to RFE 116300 (which is for macro expansions), our textual output can
report inlining information for middle-end warnings, but our SARIF output
doesn't yet capture that.

AFAIK SARIF doesn't yet have a way of expressing this, but it could probably be
done via a new kind of location relationship.

An example can be seen in gcc/testsuite/gcc.dg/Wnonnull.c in our testsuite:
  https://godbolt.org/z/3o1ehYf7b
which has e.g.:

In function 'my_strcpy',
    inlined from 'my_strcpy' at <source>:20:1,
    inlined from 'test' at <source>:40:5:
<source>:27:7: warning: argument 2 null where non-null expected [-Wnonnull]
   27 |       memcpy (dst, src, size - 1);  /* { dg-warning "argument 2 null
where non-null expected" } */
      |       ^~~~~~~~~~~~~~~~~~~~~~~~~~~
<source>: In function 'test':
<source>:7:14: note: in a call to function 'memcpy' declared 'nonnull'
    7 | extern void *memcpy (void *__restrict __dest, const void *__restrict
__src,
      |              ^~~~~~

SARIF output for the same is here:
  https://godbolt.org/z/9W5M7Gd31

where the SARIF corresponding to the above currently has just:

{"ruleId": "-Wnonnull",
 "level": "warning",
 "message": {"text": "argument 2 null where non-null expected"},
 "locations": [{"physicalLocation": {"artifactLocation": {"uri": "<source>"},
                                     "region": {"startLine": 27,
                                                "startColumn": 7,
                                                "endColumn": 34},
                                     "contextRegion": {"startLine": 27,
                                                       "snippet": {"text": "   
  memcpy (dst, src, size - 1);  /* { dg-warning \"argument 2 null where
non-null expected\" } */\n"}}},
                "logicalLocations": [{"name": "test",
                                      "fullyQualifiedName": "test",
                                      "decoratedName": "test",
                                      "kind": "function"}]}],
 "relatedLocations": [{"physicalLocation": {"artifactLocation": {"uri":
"<source>"},
                                            "region": {"startLine": 7,
                                                       "startColumn": 14,
                                                       "endColumn": 20},
                                            "contextRegion": {"startLine": 7,
                                                              "snippet":
{"text": "extern void *memcpy (void *__restrict __dest, const void *__restrict
__src,\n"}}},
                       "message": {"text": "in a call to function 'memcpy'
declared 'nonnull'"}}]}]}]}

which is missing all that inlining info.

Reply via email to