summarylogtreecommitdiffstats
path: root/lsp-remove-files-from-cdb.patch
blob: 650f900d4fee7fda17ebc0ba91f465d920f6a660 (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 05dd313d0a0d..24bf2b503de3 100644
--- a/clang-tools-extra/clangd/ClangdLSPServer.cpp
+++ b/clang-tools-extra/clangd/ClangdLSPServer.cpp
@@ -1424,7 +1424,10 @@ void ClangdLSPServer::applyConfiguration(
         tooling::CompileCommand(std::move(Command.workingDirectory), File,
                                 std::move(Command.compilationCommand),
                                 /*Output=*/"");
-    if (CDB->setCompileCommand(File, std::move(Cmd))) {
+    if (Cmd.CommandLine.empty() && Cmd.Directory.empty()) {
+      if (CDB->setCompileCommand(File, std::nullopt))
+        ModifiedFiles.insert(File);
+    } else if (CDB->setCompileCommand(File, std::move(Cmd))) {
       ModifiedFiles.insert(File);
     }
   }