================
@@ -195,6 +213,94 @@ class ErrorReporter {
}
for (const auto &Note : Error.Notes)
reportNote(Note);
+
+ if (SarifWriter)
+ exportSarifResult(Error, Loc);
+ }
+
+ CharSourceRange getNoteRange(const tooling::DiagnosticMessage &Note) {
+ const SourceLocation Loc = getLocation(Note.FilePath, Note.FileOffset);
+ return Loc.isValid() ? getOffsetRange(SourceMgr, Loc) : CharSourceRange();
+ }
+
+ SmallVector<ThreadFlow, 8> createThreadFlows(const ClangTidyError &Error) {
+ SmallVector<ThreadFlow, 8> Flows;
+ Flows.reserve(Error.Notes.size());
+ for (const tooling::DiagnosticMessage &Note : Error.Notes) {
+ Flows.push_back(ThreadFlow::create()
+ .setRange(getNoteRange(Note))
+ .setMessage(Note.Message));
+ }
+ return Flows;
+ }
+
+ void exportSarifResult(const ClangTidyError &Error,
+ const SourceLocation Loc) {
+ if (!SarifWriter)
+ return;
----------------
vbvictor wrote:
assert?
We checked for `!SarifWriter` in
```
if (SarifWriter)
exportSarifResult(Error, Loc);
```
https://github.com/llvm/llvm-project/pull/219182
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits