[PATCH] D109701: [clang] Emit SARIF Diagnostics: Create `clang::SarifDocumentWriter` interface
Vaibhav Yenamandra via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Mon Nov 8 14:34:39 PST 2021
vaibhav.y updated this revision to Diff 385634.
vaibhav.y added a comment.
Add `Closed` to signal if document is writable
Introduce a flag `Closed` to `clang::SarifDocumentWriter` that tracks
if the underlying sarif document is accepting results to record. i.e. it
is in the middle of an active run. This flag enforces that every call to
`endRun()` must be followed by a `createRun(...)` if the user wants to
append additional diagnostics
E.g.:
```cpp
// Starts with Closed = true
SarifDocumentWriter writer;
// This sets Closed = false
writer.createRun();
// append diagnostics to the document
...
// end the current run, setting Closed = true
writer.endRun();
// When Closed = true, adding a new result leads to errors
// This is now an error, and requires a call to createRun(...)
writer.appendResult(...)
```
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D109701/new/
https://reviews.llvm.org/D109701
Files:
clang/include/clang/Basic/Sarif.h
clang/include/clang/Basic/SourceLocation.h
clang/lib/Basic/CMakeLists.txt
clang/lib/Basic/Sarif.cpp
clang/lib/Basic/SourceLocation.cpp
clang/unittests/Basic/CMakeLists.txt
clang/unittests/Basic/SarifTest.cpp
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D109701.385634.patch
Type: text/x-patch
Size: 38779 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20211108/24ebd81b/attachment-0001.bin>
More information about the cfe-commits
mailing list