[PATCH] D42803: [clangd] Log dropped diagnostics.
Ilya Biryukov via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Thu Feb 1 08:53:00 PST 2018
ilya-biryukov created this revision.
ilya-biryukov added reviewers: hokein, ioeric, sammccall.
Herald added subscribers: jkorous-apple, klimek.
clangd drops diagnostics coming outside the main file, but it is still
useful to see that something went wrong in the logs.
Repository:
rCTE Clang Tools Extra
https://reviews.llvm.org/D42803
Files:
clangd/ClangdUnit.cpp
Index: clangd/ClangdUnit.cpp
===================================================================
--- clangd/ClangdUnit.cpp
+++ clangd/ClangdUnit.cpp
@@ -178,15 +178,18 @@
llvm::Optional<DiagWithFixIts> toClangdDiag(const clang::Diagnostic &D,
DiagnosticsEngine::Level Level,
const LangOptions &LangOpts) {
+ SmallString<64> Message;
+ D.FormatDiagnostic(Message);
+
if (!D.hasSourceManager() || !D.getLocation().isValid() ||
- !D.getSourceManager().isInMainFile(D.getLocation()))
+ !D.getSourceManager().isInMainFile(D.getLocation())) {
+ log("Ignored diagnostic outside main file: " + Twine(Message));
return llvm::None;
+ }
DiagWithFixIts Result;
Result.Diag.range = diagnosticRange(D, LangOpts);
Result.Diag.severity = getSeverity(Level);
- SmallString<64> Message;
- D.FormatDiagnostic(Message);
Result.Diag.message = Message.str();
for (const FixItHint &Fix : D.getFixItHints())
Result.FixIts.push_back(toTextEdit(Fix, D.getSourceManager(), LangOpts));
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D42803.132408.patch
Type: text/x-patch
Size: 1097 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20180201/2be46eaf/attachment.bin>
More information about the cfe-commits
mailing list