[llvm-branch-commits] [clang-tools-extra] 74b3ace - [clangd] Fix case mismatch crash on in CDB on windows after 92dd077af1ff8

Sam McCall via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Wed Dec 23 13:46:52 PST 2020


Author: Sam McCall
Date: 2020-12-23T22:42:45+01:00
New Revision: 74b3acefc7b6355e89bb9b09dc88a5948f65c342

URL: https://github.com/llvm/llvm-project/commit/74b3acefc7b6355e89bb9b09dc88a5948f65c342
DIFF: https://github.com/llvm/llvm-project/commit/74b3acefc7b6355e89bb9b09dc88a5948f65c342.diff

LOG: [clangd] Fix case mismatch crash on in CDB on windows after 92dd077af1ff8

See https://github.com/clangd/clangd/issues/631

Added: 
    

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

Removed: 
    


################################################################################
diff  --git a/clang-tools-extra/clangd/GlobalCompilationDatabase.cpp b/clang-tools-extra/clangd/GlobalCompilationDatabase.cpp
index 41b549cefc7c..86375fa11d3b 100644
--- a/clang-tools-extra/clangd/GlobalCompilationDatabase.cpp
+++ b/clang-tools-extra/clangd/GlobalCompilationDatabase.cpp
@@ -511,11 +511,14 @@ void DirectoryBasedGlobalCompilationDatabase::broadcastCDB(
   // Given that we know that CDBs have been moved/generated, don't trust caches.
   // (This should be rare, so it's OK to add a little latency).
   constexpr auto IgnoreCache = std::chrono::steady_clock::time_point::max();
-  for (DirectoryCache *Dir : getDirectoryCaches(FileAncestors)) {
+  auto DirectoryCaches = getDirectoryCaches(FileAncestors);
+  assert(DirectoryCaches.size() == FileAncestors.size());
+  for (unsigned I = 0; I < DirectoryCaches.size(); ++I) {
     bool ShouldBroadcast = false;
-    if (Dir->get(Opts.TFS, ShouldBroadcast, /*FreshTime=*/IgnoreCache,
-                 /*FreshTimeMissing=*/IgnoreCache))
-      DirectoryHasCDB.find(Dir->Path)->setValue(true);
+    if (DirectoryCaches[I]->get(Opts.TFS, ShouldBroadcast,
+                                /*FreshTime=*/IgnoreCache,
+                                /*FreshTimeMissing=*/IgnoreCache))
+      DirectoryHasCDB.find(FileAncestors[I])->setValue(true);
   }
 
   std::vector<std::string> GovernedFiles;


        


More information about the llvm-branch-commits mailing list