[PATCH] D58291: [clangd] Include textual diagnostic ID as Diagnostic.code.

Jan Korous via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Feb 18 13:34:18 PST 2019


jkorous requested changes to this revision.
jkorous added a comment.
This revision now requires changes to proceed.

Hi Sam, this looks good! 
I found just one small detail.



================
Comment at: clangd/Diagnostics.cpp:281
+    if (auto* Name = getDiagnosticCode(D.ID))
+      Main.code = Name;
     if (Opts.EmbedFixesInDiagnostics) {
----------------
It seems to me that in case `ID` is undefined (hits the default case in `getDiagnosticCode`) we are calling `std::string` non-explicit constructor with `nullptr` which is UB.
How about changing `char* getDiagnosticCode` to `Optional<char*> getDiagnosticCode` or similar to make it less error-prone?


Repository:
  rCTE Clang Tools Extra

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

https://reviews.llvm.org/D58291





More information about the cfe-commits mailing list