summarylogtreecommitdiffstats
path: root/lsp-remove-files-from-cdb.patch
blob: 7a717779b671186a1a91dbeaf8794d94ffea4cdb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
diff --git a/clang-tools-extra/clangd/ClangdLSPServer.cpp b/clang-tools-extra/clangd/ClangdLSPServer.cpp
index a87da252b7a7..0a228df4f0b5 100644
--- a/clang-tools-extra/clangd/ClangdLSPServer.cpp
+++ b/clang-tools-extra/clangd/ClangdLSPServer.cpp
@@ -1385,7 +1385,10 @@ void ClangdLSPServer::applyConfiguration(
                                 std::move(Entry.second.compilationCommand),
                                 /*Output=*/"");
     if (Old != New) {
-      CDB->setCompileCommand(File, std::move(New));
+      if (New.CommandLine.empty() && New.Directory.empty())
+        CDB->setCompileCommand(File, std::nullopt);
+      else
+        CDB->setCompileCommand(File, std::move(New));
       ModifiedFiles.insert(File);
     }
   }