aboutsummaryrefslogtreecommitdiff
path: root/clang/lib
diff options
context:
space:
mode:
authorAbraham Corea Diaz <abrahamcd@google.com>2022-07-21 16:50:43 +0000
committerChristopher Di Bella <cjdb@google.com>2022-07-21 16:51:15 +0000
commit119d22310bd622d4b39e9760667b6fa58d15a8c5 (patch)
tree59e34c7ce1c40639717916a22a815a6367d40734 /clang/lib
parent66e01f47e46bcda11c4cbd942c7a7cafad1d38da (diff)
downloadllvm-119d22310bd622d4b39e9760667b6fa58d15a8c5.zip
llvm-119d22310bd622d4b39e9760667b6fa58d15a8c5.tar.gz
llvm-119d22310bd622d4b39e9760667b6fa58d15a8c5.tar.bz2
[clang] Add -fdiagnostics-format=sarif option for future SARIF output
Adds `sarif` option to the existing `-fdiagnostics-format` flag for intended future work with SARIF diagnostics. Currently issues a warning against the use of diagnostics in SARIF mode, then defaults to clang style for diagnostics. Reviewed By: cjdb, denik, aaron.ballman Differential Revision: https://reviews.llvm.org/D129886
Diffstat (limited to 'clang/lib')
-rw-r--r--clang/lib/Driver/ToolChains/Clang.cpp3
-rw-r--r--clang/lib/Frontend/TextDiagnostic.cpp2
2 files changed, 5 insertions, 0 deletions
diff --git a/clang/lib/Driver/ToolChains/Clang.cpp b/clang/lib/Driver/ToolChains/Clang.cpp
index 6337a99..3ad08ad 100644
--- a/clang/lib/Driver/ToolChains/Clang.cpp
+++ b/clang/lib/Driver/ToolChains/Clang.cpp
@@ -4007,6 +4007,9 @@ static void RenderDiagnosticsOptions(const Driver &D, const ArgList &Args,
if (const Arg *A = Args.getLastArg(options::OPT_fdiagnostics_format_EQ)) {
CmdArgs.push_back("-fdiagnostics-format");
CmdArgs.push_back(A->getValue());
+ if (StringRef(A->getValue()) == "sarif" ||
+ StringRef(A->getValue()) == "SARIF")
+ D.Diag(diag::warn_drv_sarif_format_unstable);
}
if (const Arg *A = Args.getLastArg(
diff --git a/clang/lib/Frontend/TextDiagnostic.cpp b/clang/lib/Frontend/TextDiagnostic.cpp
index 6c0ea0c..ab0dbce 100644
--- a/clang/lib/Frontend/TextDiagnostic.cpp
+++ b/clang/lib/Frontend/TextDiagnostic.cpp
@@ -815,6 +815,7 @@ void TextDiagnostic::emitDiagnosticLoc(FullSourceLoc Loc, PresumedLoc PLoc,
emitFilename(PLoc.getFilename(), Loc.getManager());
switch (DiagOpts->getFormat()) {
+ case DiagnosticOptions::SARIF:
case DiagnosticOptions::Clang:
if (DiagOpts->ShowLine)
OS << ':' << LineNo;
@@ -837,6 +838,7 @@ void TextDiagnostic::emitDiagnosticLoc(FullSourceLoc Loc, PresumedLoc PLoc,
OS << ColNo;
}
switch (DiagOpts->getFormat()) {
+ case DiagnosticOptions::SARIF:
case DiagnosticOptions::Clang:
case DiagnosticOptions::Vi: OS << ':'; break;
case DiagnosticOptions::MSVC: