[llvm-branch-commits] [clang-tools-extra] 0cbbf06 - [clangd] Log a message when gRPC support is off, but remote-index is configured

Tom Stellard via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Thu Apr 29 23:49:58 PDT 2021


Author: Kadir Cetinkaya
Date: 2021-04-29T23:49:03-07:00
New Revision: 0cbbf06b625605fff83d89b17c2187c7ccfcecd5

URL: https://github.com/llvm/llvm-project/commit/0cbbf06b625605fff83d89b17c2187c7ccfcecd5
DIFF: https://github.com/llvm/llvm-project/commit/0cbbf06b625605fff83d89b17c2187c7ccfcecd5.diff

LOG: [clangd] Log a message when gRPC support is off, but remote-index is configured

Before this change clangd would emit a diagnostic whenever remote-index
was configured but binary didn't have grpc support.

This can be annoying when projects are configuring remote-index through their
configs but developers have a clangd binary without the support.

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

(cherry picked from commit b9b708eef8cb7bcb073361283cd573beb04992a9)

Added: 
    

Modified: 
    clang-tools-extra/clangd/ConfigCompile.cpp
    clang-tools-extra/clangd/unittests/ConfigCompileTests.cpp

Removed: 
    


################################################################################
diff  --git a/clang-tools-extra/clangd/ConfigCompile.cpp b/clang-tools-extra/clangd/ConfigCompile.cpp
index dadc578c3a81d..b4f0d61868863 100644
--- a/clang-tools-extra/clangd/ConfigCompile.cpp
+++ b/clang-tools-extra/clangd/ConfigCompile.cpp
@@ -321,8 +321,9 @@ struct FragmentCompiler {
                llvm::SMRange BlockRange) {
 #ifndef CLANGD_ENABLE_REMOTE
     if (External.Server) {
-      diag(Error, "Clangd isn't compiled with remote index support, ignoring "
-                  "Server." External.Server->Range);
+      elog("Clangd isn't compiled with remote index support, ignoring Server: "
+           "{0}",
+           *External.Server);
       External.Server.reset();
     }
 #endif

diff  --git a/clang-tools-extra/clangd/unittests/ConfigCompileTests.cpp b/clang-tools-extra/clangd/unittests/ConfigCompileTests.cpp
index d9aa171f31029..4961d3474fd9a 100644
--- a/clang-tools-extra/clangd/unittests/ConfigCompileTests.cpp
+++ b/clang-tools-extra/clangd/unittests/ConfigCompileTests.cpp
@@ -324,15 +324,15 @@ TEST_F(ConfigCompileTests, ExternalBlockWarnOnMultipleSource) {
   External.Server.emplace("");
   Frag.Index.External = std::move(External);
   compileAndApply();
-  llvm::StringLiteral ExpectedDiag =
 #ifdef CLANGD_ENABLE_REMOTE
-      "Exactly one of File or Server must be set.";
+  EXPECT_THAT(
+      Diags.Diagnostics,
+      Contains(AllOf(DiagMessage("Exactly one of File or Server must be set."),
+                     DiagKind(llvm::SourceMgr::DK_Error))));
 #else
-      "Clangd isn't compiled with remote index support, ignoring Server.";
+  ASSERT_TRUE(Conf.Index.External.hasValue());
+  EXPECT_EQ(Conf.Index.External->Kind, Config::ExternalIndexSpec::File);
 #endif
-  EXPECT_THAT(Diags.Diagnostics,
-              Contains(AllOf(DiagMessage(ExpectedDiag),
-                             DiagKind(llvm::SourceMgr::DK_Error))));
 }
 
 TEST_F(ConfigCompileTests, ExternalBlockErrOnNoSource) {


        


More information about the llvm-branch-commits mailing list