[PATCH] D104056: [clangd][nfc] Show more information in logs when compiler instance prepare fails

Aleksandr Platonov via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Jun 30 13:59:16 PDT 2021


This revision was automatically updated to reflect the committed changes.
Closed by commit rGa62579fc008e: [clangd][nfc] Show more information in logs when compiler instance prepare fails (authored by ArcsinX).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D104056

Files:
  clang-tools-extra/clangd/ParsedAST.cpp
  clang-tools-extra/clangd/Preamble.cpp


Index: clang-tools-extra/clangd/Preamble.cpp
===================================================================
--- clang-tools-extra/clangd/Preamble.cpp
+++ clang-tools-extra/clangd/Preamble.cpp
@@ -390,8 +390,8 @@
         SerializedDeclsCollector.takeMacros(), std::move(StatCache),
         SerializedDeclsCollector.takeCanonicalIncludes());
   } else {
-    elog("Could not build a preamble for file {0} version {1}", FileName,
-         Inputs.Version);
+    elog("Could not build a preamble for file {0} version {1}: {2}", FileName,
+         Inputs.Version, BuiltPreamble.getError().message());
     return nullptr;
   }
 }
Index: clang-tools-extra/clangd/ParsedAST.cpp
===================================================================
--- clang-tools-extra/clangd/ParsedAST.cpp
+++ clang-tools-extra/clangd/ParsedAST.cpp
@@ -289,8 +289,15 @@
       std::move(CI), PreamblePCH,
       llvm::MemoryBuffer::getMemBufferCopy(Inputs.Contents, Filename), VFS,
       ASTDiags);
-  if (!Clang)
+  if (!Clang) {
+    // The last diagnostic contains information about the reason of this
+    // failure.
+    std::vector<Diag> Diags(ASTDiags.take());
+    elog("Failed to prepare a compiler instance: {0}",
+         !Diags.empty() ? static_cast<DiagBase &>(Diags.back()).Message
+                        : "unknown error");
     return None;
+  }
 
   auto Action = std::make_unique<ClangdFrontendAction>();
   const FrontendInputFile &MainInput = Clang->getFrontendOpts().Inputs[0];


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D104056.355676.patch
Type: text/x-patch
Size: 1488 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20210630/0f62c908/attachment-0001.bin>


More information about the cfe-commits mailing list