summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSam McCall <sam.mccall@gmail.com>2019-07-09 23:05:20 +0000
committerSam McCall <sam.mccall@gmail.com>2019-07-09 23:05:20 +0000
commit9145f265b0e836f5def43d8fd6bb03978360af96 (patch)
tree3e5cc4bc071d0c27632b80c5865f84facd83ca14
parent3f1a34546cf3f8ca245cd2ce5b8189287b44be2b (diff)
downloadbcm5719-llvm-9145f265b0e836f5def43d8fd6bb03978360af96.tar.gz
bcm5719-llvm-9145f265b0e836f5def43d8fd6bb03978360af96.zip
[clangd] fix assert in test after r365531.
Unverified because CMake/ninja seems to be broken... llvm-svn: 365576
-rw-r--r--clang-tools-extra/clangd/unittests/BackgroundIndexTests.cpp19
1 files changed, 12 insertions, 7 deletions
diff --git a/clang-tools-extra/clangd/unittests/BackgroundIndexTests.cpp b/clang-tools-extra/clangd/unittests/BackgroundIndexTests.cpp
index b2383cd2738..388b4b2b3fd 100644
--- a/clang-tools-extra/clangd/unittests/BackgroundIndexTests.cpp
+++ b/clang-tools-extra/clangd/unittests/BackgroundIndexTests.cpp
@@ -10,6 +10,7 @@
#include "llvm/Support/Threading.h"
#include "gmock/gmock.h"
#include "gtest/gtest.h"
+#include <deque>
#include <thread>
using ::testing::_;
@@ -581,27 +582,31 @@ protected:
// Perform Action and determine whether it rebuilt the index or not.
bool checkRebuild(std::function<void()> Action) {
- // Update reference count so we can tell if the index updates.
- ++TestSymbol.References;
+ // Update name so we can tell if the index updates.
+ VersionStorage.push_back("Sym" + std::to_string(++VersionCounter));
+ TestSymbol.Name = VersionStorage.back();
SymbolSlab::Builder SB;
SB.insert(TestSymbol);
Source.update("", llvm::make_unique<SymbolSlab>(std::move(SB).build()),
nullptr, nullptr, false);
// Now maybe update the index.
Action();
- // Now query the index to get the reference count.
- unsigned ReadReferences = 0;
+ // Now query the index to get the name count.
+ std::string ReadName;
LookupRequest Req;
Req.IDs.insert(TestSymbol.ID);
- Target.lookup(Req, [&](const Symbol &S) { ReadReferences = S.References; });
- // The index was rebuild if the reference count is up to date.
- return ReadReferences == TestSymbol.References;
+ Target.lookup(Req, [&](const Symbol &S) { ReadName = S.Name; });
+ // The index was rebuild if the name is up to date.
+ return ReadName == VersionStorage.back();
}
Symbol TestSymbol;
FileSymbols Source;
SwapIndex Target;
BackgroundIndexRebuilder Rebuilder;
+
+ unsigned VersionCounter = 0;
+ std::deque<std::string> VersionStorage;
};
TEST_F(BackgroundIndexRebuilderTest, IndexingTUs) {
OpenPOWER on IntegriCloud