diff --git a/.gitignore b/.gitignore --- a/.gitignore +++ b/.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 diff --git a/clang-tools-extra/clangd/index/Background.h b/clang-tools-extra/clangd/index/Background.h --- a/clang-tools-extra/clangd/index/Background.h +++ b/clang-tools-extra/clangd/index/Background.h @@ -56,7 +56,7 @@ using Factory = llvm::unique_function; // 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( diff --git a/clang-tools-extra/clangd/index/BackgroundIndexStorage.cpp b/clang-tools-extra/clangd/index/BackgroundIndexStorage.cpp --- a/clang-tools-extra/clangd/index/BackgroundIndexStorage.cpp +++ b/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) diff --git a/clang-tools-extra/clangd/test/background-index.test b/clang-tools-extra/clangd/test/background-index.test --- a/clang-tools-extra/clangd/test/background-index.test +++ b/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 diff --git a/llvm/.gitignore b/llvm/.gitignore --- a/llvm/.gitignore +++ b/llvm/.gitignore @@ -59,8 +59,6 @@ # VS2017 and VSCode config files. .vscode .vs -# clangd index -.clangd #==============================================================================# # Files created in tree by the Go bindings.