diff options
author | Kadir Cetinkaya <kadircet@google.com> | 2018-11-15 10:34:47 +0000 |
---|---|---|
committer | Kadir Cetinkaya <kadircet@google.com> | 2018-11-15 10:34:47 +0000 |
commit | 5a9b92ca757260d102f15997596a4fae1c1bc421 (patch) | |
tree | 13f537874355696919ae7cb8d580392a295273d5 /clang-tools-extra/unittests | |
parent | bd2441c8874ccd26c5ff2d606f3458bdbf2dc936 (diff) | |
download | bcm5719-llvm-5a9b92ca757260d102f15997596a4fae1c1bc421.tar.gz bcm5719-llvm-5a9b92ca757260d102f15997596a4fae1c1bc421.zip |
Revert "Introduce shard storage to auto-index."
This reverts commit 6dd1f24aead10a8d375d0311001987198d26e900.
llvm-svn: 346945
Diffstat (limited to 'clang-tools-extra/unittests')
-rw-r--r-- | clang-tools-extra/unittests/clangd/BackgroundIndexTests.cpp | 74 |
1 files changed, 0 insertions, 74 deletions
diff --git a/clang-tools-extra/unittests/clangd/BackgroundIndexTests.cpp b/clang-tools-extra/unittests/clangd/BackgroundIndexTests.cpp index c79184d9220..c6f401d2740 100644 --- a/clang-tools-extra/unittests/clangd/BackgroundIndexTests.cpp +++ b/clang-tools-extra/unittests/clangd/BackgroundIndexTests.cpp @@ -78,79 +78,5 @@ TEST(BackgroundIndexTest, IndexTwoFiles) { FileURI("unittest:///root/B.cc")})); } -TEST(BackgroundIndexTest, ShardStorageTest) { - class MemoryShardStorage : public ShardStorage { - mutable std::mutex StorageMu; - llvm::StringMap<std::string> &Storage; - size_t& CacheHits; - - public: - MemoryShardStorage(llvm::StringMap<std::string> &Storage, size_t &CacheHits) - : Storage(Storage), CacheHits(CacheHits) {} - - bool storeShard(llvm::StringRef ShardIdentifier, IndexFileOut Shard) const { - std::lock_guard<std::mutex> Lock(StorageMu); - std::string &str = Storage[ShardIdentifier]; - llvm::raw_string_ostream OS(str); - OS << Shard; - OS.flush(); - return true; - } - llvm::Expected<IndexFileIn> retrieveShard(llvm::StringRef ShardIdentifier, - FileDigest Hash) const { - std::lock_guard<std::mutex> Lock(StorageMu); - if (Storage.find(ShardIdentifier) == Storage.end()) - return llvm::make_error<llvm::StringError>( - "Shard not found.", llvm::inconvertibleErrorCode()); - auto IndexFile = readIndexFile(Storage[ShardIdentifier]); - if(!IndexFile) - return IndexFile; - CacheHits++; - return IndexFile; - } - bool initialize(llvm::StringRef Directory) { return true; } - }; - MockFSProvider FS; - FS.Files[testPath("root/A.h")] = R"cpp( - void common(); - void f_b(); - class A_CC {}; - )cpp"; - FS.Files[testPath("root/A.cc")] = - "#include \"A.h\"\nvoid g() { (void)common; }"; - llvm::StringMap<std::string> Storage; - size_t CacheHits = 0; - tooling::CompileCommand Cmd; - Cmd.Filename = testPath("root/A.cc"); - Cmd.Directory = testPath("root"); - Cmd.CommandLine = {"clang++", testPath("root/A.cc")}; - { - BackgroundIndex Idx( - Context::empty(), "", FS, /*URISchemes=*/{"unittest"}, - /*IndexShardStorage=*/ - llvm::make_unique<MemoryShardStorage>(Storage, CacheHits)); - Idx.enqueue(testPath("root"), Cmd); - Idx.blockUntilIdleForTest(); - } - EXPECT_EQ(CacheHits, 0U); - EXPECT_EQ(Storage.size(), 2U); - EXPECT_NE(Storage.find(testPath("root/A.h")), Storage.end()); - EXPECT_NE(Storage.find(testPath("root/A.cc")), Storage.end()); - - { - BackgroundIndex Idx( - Context::empty(), "", FS, /*URISchemes=*/{"unittest"}, - /*IndexShardStorage=*/ - llvm::make_unique<MemoryShardStorage>(Storage, CacheHits)); - Idx.enqueue(testPath("root"), Cmd); - Idx.blockUntilIdleForTest(); - } - EXPECT_EQ(CacheHits, 1U); - EXPECT_EQ(Storage.size(), 2U); - EXPECT_NE(Storage.find(testPath("root/A.h")), Storage.end()); - EXPECT_NE(Storage.find(testPath("root/A.cc")), Storage.end()); - // B_CC is dropped as we don't collect symbols from A.h in this compilation. -} - } // namespace clangd } // namespace clang |