[PATCH] D52776: [OptRemarks] Add library for parsing optimization remarks

Francis Visoiu Mistrih via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Oct 8 05:21:53 PDT 2018


thegameg added inline comments.


================
Comment at: lib/OptRemarks/OptRemarksParser.cpp:91-92
+  static void HandleDiagnostic(const SMDiagnostic &Diag, void *Ctx) {
+    auto *Parser = static_cast<RemarkParser *>(Ctx);
+    Diag.print(/*ProgName=*/nullptr, Parser->ErrorStream, /*ShowColors*/ false,
+               /*ShowKindLabels*/ true);
----------------
paquette wrote:
> Is `Parser` (and I guess `Ctx`) guaranteed to not be a `nullptr`? If not, I can see `Parser->ErrorStream` causing some issues.
I added an assert. It should never be null since it's passed around by the `SourceMgr`. It's set by doing:

```
SM.setDiagHandler(RemarkParser::HandleDiagnostic, this);
```

previously.


https://reviews.llvm.org/D52776





More information about the llvm-commits mailing list