6 Commits

Author SHA1 Message Date
James Y Knight
31aebdd891
Include LLVM_VERSION_SUFFIX in the Clang version string. (#74469)
This causes current mainline to now report "18.0.0git" instead of
"18.0.0".

Fixes #53825
2023-12-05 12:20:12 -05:00
Aaron Ballman
0647f4a77a Drop a path component from the sarif diagnostics test; NFC
The test currently expects to be run in a directory named 'clang' but
that's not valid for our release tarballs. We don't actually care what
base directory the test is run from, so this removes the path component
entirely.
2023-01-24 15:37:53 -05:00
Vaibhav Yenamandra
7b6fe711b2 Refactor StaticAnalyzer to use clang::SarifDocumentWriter
Refactor StaticAnalyzer to use clang::SarifDocumentWriter for
serializing sarif diagnostics.

Uses clang::SarifDocumentWriter to generate SARIF output in the
StaticAnalyzer.

Various bugfixes are also made to clang::SarifDocumentWriter.

Summary of changes:

clang/lib/Basic/Sarif.cpp:
  * Fix bug in adjustColumnPos introduced from prev move, it now uses
    FullSourceLoc::getDecomposedExpansionLoc which provides the correct
    location (in the presence of macros) instead of
    FullSourceLoc::getDecomposedLoc.
  * Fix createTextRegion so that it handles caret ranges correctly,
    this should bring it to parity with the previous implementation.

clang/test/Analysis/diagnostics/Inputs/expected-sarif:
  * Update the schema URL to the offical website
  * Add the emitted defaultConfiguration sections to all rules
  * Annotate results with the "level" property

clang/lib/StaticAnalyzer/Core/SarifDiagnostics.cpp:
  * Update SarifDiagnostics class to hold a clang::SarifDocumentWriter
    that it uses to convert diagnostics to SARIF.
2022-11-17 14:47:02 -05:00
Yabin Cui
4e6b071509 Fix clang version check in SARIF diagnostics test
This is to allow future clang versions and use of LLVM_VERSION_PATCH.

Differential Revision: https://reviews.llvm.org/D135896
2022-10-13 15:16:58 -04:00
Aaron Ballman
b345be177d Make this test slightly less fragile; NFC
The rule IDs are not stable, so this uses a regex for the rule ids
instead of concrete values. It also moves the CHECK lines below the
code so that it's easier to modify the test in the future. It also
breaks the CHECK lines into multiple lines to improve the performance
of the test and aid in debugging failures. Finally, it adds a comment
to the top of the test explaining that things are still rather fragile.
2022-08-29 09:41:23 -04:00
Abraham Corea Diaz
82e893c47c [clang] Enable output of SARIF diagnostics
Enables Clang to emit diagnostics in SARIF format when
`-fdiagnostics-format=sarif`. Adds a new DiagnosticConsumer named
SARIFDiagnosticPrinter and a new DiagnosticRenderer named SARIFDiagnostic
to constuct and emit a SARIF object containing the run's basic diagnostic info.

Reviewed By: cjdb, denik, aaron.ballman

Differential Revision: https://reviews.llvm.org/D131632
2022-08-26 18:49:29 +00:00