[PATCH] D131632: [clang] Enable output of SARIF diagnostics

Christopher Di Bella via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Aug 23 15:45:23 PDT 2022


cjdb added inline comments.


================
Comment at: clang/include/clang/Frontend/SARIFDiagnosticPrinter.h:41
+  void setPrefix(llvm::StringRef Value) {
+    Prefix = std::move(Value);
+  }
----------------
We don't need to move a StringRef.


================
Comment at: clang/lib/Frontend/SARIFDiagnosticPrinter.cpp:43
+  assert(hasSarifWriter() && "Writer not set!");
+  SARIFDiag.reset(new SARIFDiagnostic(*OS, LO, &*DiagOpts, &*Writer));
+  // Initialize the SARIF object.
----------------
cjdb wrote:
> Please replace with `make_unique`.
This won't work because `.get()` only returns an observer, so the object will be deleted when this statement completes. We'll need to do
```
SARIFDiag = std::make_unique<SARIFDiagnostic>(*OS, LO, &*DiagOpts, &*Writer);
```


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D131632/new/

https://reviews.llvm.org/D131632



More information about the cfe-commits mailing list