[clang-tools-extra] 00b9cef - [clangd] Log diagnostics if we failed to create a preamble.

Sam McCall via cfe-commits cfe-commits at lists.llvm.org
Thu Dec 1 04:25:31 PST 2022


Author: Sam McCall
Date: 2022-12-01T13:25:15+01:00
New Revision: 00b9cefacbdf0ac764576c52fad6177aea2ed6b8

URL: https://github.com/llvm/llvm-project/commit/00b9cefacbdf0ac764576c52fad6177aea2ed6b8
DIFF: https://github.com/llvm/llvm-project/commit/00b9cefacbdf0ac764576c52fad6177aea2ed6b8.diff

LOG: [clangd] Log diagnostics if we failed to create a preamble.

Really we want these to be shown to the client, but the path to do so involves
storing them in

Bandaid for https://github.com/clangd/clangd/issues/1408
See https://github.com/clangd/clangd/issues/1399 for motivation

Differential Revision: https://reviews.llvm.org/D139088

Added: 
    

Modified: 
    clang-tools-extra/clangd/Preamble.cpp

Removed: 
    


################################################################################
diff  --git a/clang-tools-extra/clangd/Preamble.cpp b/clang-tools-extra/clangd/Preamble.cpp
index 337f71bed9bae..d2b91894f11b4 100644
--- a/clang-tools-extra/clangd/Preamble.cpp
+++ b/clang-tools-extra/clangd/Preamble.cpp
@@ -571,6 +571,12 @@ buildPreamble(PathRef FileName, CompilerInvocation CI,
 
   elog("Could not build a preamble for file {0} version {1}: {2}", FileName,
        Inputs.Version, BuiltPreamble.getError().message());
+  for (const Diag &D : PreambleDiagnostics.take()) {
+    if (D.Severity < DiagnosticsEngine::Error)
+      continue;
+    // Not an ideal way to show errors, but better than nothing!
+    elog("  error: {0}", D.Message);
+  }
   return nullptr;
 }
 


        


More information about the cfe-commits mailing list