sammccall created this revision.
sammccall added reviewers: kadircet, hokein.
Herald added subscribers: llvm-commits, cfe-commits, usaxena95, arphaman, 
omtcyfz, jkorous, MaskRay, ilya-biryukov.
Herald added projects: clang, LLVM.

This was well-intentioned, but it turns out `.clangd` is the best
filename for the clangd config file (matching .clang-format and .clang-tidy).
And of course we can't have both .clangd/index and .clangd...

So lacking better ideas, back to .clangd-index we go.
The monorepo gitignore is updated to reflect the new best-practice:

  ignore .clangd/ (with trailing slash) matching index files from clangd 9/10
  ignore .clangd-index/ matching index files from clangd <=8 and 11+.

The entries from llvm-project/llvm gitignore are removed (obsolete).

This reverts commit 2754942cbaef0b72c178e34247611521382c361c.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D83099

Files:
  .gitignore
  clang-tools-extra/clangd/index/Background.h
  clang-tools-extra/clangd/index/BackgroundIndexStorage.cpp
  clang-tools-extra/clangd/test/background-index.test
  llvm/.gitignore

Index: llvm/.gitignore
===================================================================
--- llvm/.gitignore
+++ llvm/.gitignore
@@ -59,8 +59,6 @@
 # VS2017 and VSCode config files.
 .vscode
 .vs
-# clangd index
-.clangd
 
 #==============================================================================#
 # Files created in tree by the Go bindings.
Index: clang-tools-extra/clangd/test/background-index.test
===================================================================
--- clang-tools-extra/clangd/test/background-index.test
+++ clang-tools-extra/clangd/test/background-index.test
@@ -15,8 +15,8 @@
 # RUN: clangd -background-index -lit-test < %t/definition.jsonrpc | FileCheck %t/definition.jsonrpc --check-prefixes=CHECK,BUILD
 
 # Test that the index is writing files in the expected location.
-# RUN: ls %t/.clangd/index/foo.cpp.*.idx
-# RUN: ls %t/sub_dir/.clangd/index/foo.h.*.idx
+# RUN: ls %t/.clangd-index/foo.cpp.*.idx
+# RUN: ls %t/sub_dir/.clangd-index/foo.h.*.idx
 
 # Test the index is read from disk: delete code and restart clangd.
 # RUN: rm %t/foo.cpp
Index: clang-tools-extra/clangd/index/BackgroundIndexStorage.cpp
===================================================================
--- clang-tools-extra/clangd/index/BackgroundIndexStorage.cpp
+++ clang-tools-extra/clangd/index/BackgroundIndexStorage.cpp
@@ -44,7 +44,7 @@
   // Creates `DiskShardRoot` and any parents during construction.
   DiskBackedIndexStorage(llvm::StringRef Directory) : DiskShardRoot(Directory) {
     std::error_code OK;
-    std::error_code EC = llvm::sys::fs::create_directories(DiskShardRoot);
+    std::error_code EC = llvm::sys::fs::create_directory(DiskShardRoot);
     if (EC != OK) {
       elog("Failed to create directory {0} for index storage: {1}",
            DiskShardRoot, EC.message());
@@ -95,8 +95,8 @@
 };
 
 // Creates and owns IndexStorages for multiple CDBs.
-// When a CDB root is found, shards are stored in $ROOT/.clangd/index.
-// When no root is found, the fallback path is ~/.cache/clangd/index.
+// When a CDB root is found, shards are stored in $ROOT/.clangd-index.
+// When no root is found, the fallback path is ~/.cache/clangd-index.
 class DiskBackedIndexStorageManager {
 public:
   DiskBackedIndexStorageManager(
@@ -105,7 +105,7 @@
         GetProjectInfo(std::move(GetProjectInfo)) {
     llvm::SmallString<128> FallbackDir;
     if (llvm::sys::path::cache_directory(FallbackDir))
-      llvm::sys::path::append(FallbackDir, "clangd", "index");
+      llvm::sys::path::append(FallbackDir, "clangd-index");
     this->FallbackDir = FallbackDir.str().str();
   }
 
@@ -115,7 +115,7 @@
     llvm::SmallString<128> StorageDir(FallbackDir);
     if (auto PI = GetProjectInfo(File)) {
       StorageDir = PI->SourceRoot;
-      llvm::sys::path::append(StorageDir, ".clangd", "index");
+      llvm::sys::path::append(StorageDir, ".clangd-index");
     }
     auto &IndexStorage = IndexStorageMap[StorageDir];
     if (!IndexStorage)
Index: clang-tools-extra/clangd/index/Background.h
===================================================================
--- clang-tools-extra/clangd/index/Background.h
+++ clang-tools-extra/clangd/index/Background.h
@@ -56,7 +56,7 @@
   using Factory = llvm::unique_function<BackgroundIndexStorage *(PathRef)>;
 
   // Creates an Index Storage that saves shards into disk. Index storage uses
-  // CDBDirectory + ".clangd/index/" as the folder to save shards. CDBDirectory
+  // CDBDirectory + ".clangd-index/" as the folder to save shards. CDBDirectory
   // is the first directory containing a CDB in parent directories of a file, or
   // user's home directory if none was found, e.g. standard library headers.
   static Factory createDiskBackedStorageFactory(
Index: .gitignore
===================================================================
--- .gitignore
+++ .gitignore
@@ -54,9 +54,10 @@
 .vscode
 .vs
 # clangd index
-.clangd
+.clangd-index/
+.clangd/
 # static analyzer regression testing project files
 /clang/utils/analyzer/projects/*/CachedSource
 /clang/utils/analyzer/projects/*/PatchedSource
 /clang/utils/analyzer/projects/*/ScanBuildResults
-/clang/utils/analyzer/projects/*/RefScanBuildResults
\ No newline at end of file
+/clang/utils/analyzer/projects/*/RefScanBuildResults
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to