]> git.ipfire.org Git - thirdparty/gcc.git/commit
sarif-replay: improve error for unescaped braces in messages (§3.11.5)
authorDavid Malcolm <dmalcolm@redhat.com>
Thu, 20 Feb 2025 22:10:53 +0000 (17:10 -0500)
committerDavid Malcolm <dmalcolm@redhat.com>
Thu, 20 Feb 2025 22:10:53 +0000 (17:10 -0500)
commit5a30a3aba065f6e683bc429da44437676662e113
tree7f0eb2ac25b00369f37262460c6961188c3c6f41
parent25fa8d6dc30ace6493fd9e861c13ee3282aa02c0
sarif-replay: improve error for unescaped braces in messages (§3.11.5)

Spotted via https://github.com/llvm/llvm-project/issues/128024

gcc/ChangeLog:
* libsarifreplay.cc
(sarif_replayer::make_plain_text_within_result_message): Capture
which json::string was used.  When reporting on unescaped "{" or
"}" in SARIF message strings, use that string rather than the
message object, and refer the user to §3.11.5 ("Messages with
placeholders") rather than §3.11.11 ("arguments").  Ideally we'd
place the error at the precise character, but that can't be done
without reworking json-parsing.cc's lexer::lex_string, which is
too invasive for stage 4.
(sarif_replayer::get_plain_text_from_mfms): Capture which
json::string was used.
(sarif_replayer::lookup_plain_text_within_result_message):
Likewise.

gcc/testsuite/ChangeLog:
* sarif-replay.dg/2.1.0-invalid/3.11.11-malformed-placeholder.sarif:
Rename to...
* sarif-replay.dg/2.1.0-invalid/3.11.5-unescaped-braces.sarif:
...this.  Update expected subsection in error message, and
expected underline in quoted JSON.

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
gcc/libsarifreplay.cc
gcc/testsuite/sarif-replay.dg/2.1.0-invalid/3.11.5-unescaped-braces.sarif [moved from gcc/testsuite/sarif-replay.dg/2.1.0-invalid/3.11.11-malformed-placeholder.sarif with 84% similarity]