summaryrefslogtreecommitdiffstats
path: root/clang-tools-extra/unittests/clangd/IndexTests.cpp
diff options
context:
space:
mode:
authorKadir Cetinkaya <kadircet@google.com>2019-03-14 08:35:17 +0000
committerKadir Cetinkaya <kadircet@google.com>2019-03-14 08:35:17 +0000
commitd9c174648ed8219ad86a021bcccf149e860d3ef5 (patch)
tree3c973ab0cfaad5aa8269429fbc1d763e93f4b48d /clang-tools-extra/unittests/clangd/IndexTests.cpp
parentfec503acb667c80a0cbc8e998e2aa8bba99d8743 (diff)
downloadbcm5719-llvm-d9c174648ed8219ad86a021bcccf149e860d3ef5.tar.gz
bcm5719-llvm-d9c174648ed8219ad86a021bcccf149e860d3ef5.zip
[clangd] Store explicit template specializations in index for code navigation purposes
Summary: This introduces ~4k new symbols, and ~10k refs for LLVM. We need that information for providing better code navigation support: - When references for a class template is requested, we should return these specializations as well. - When children of a specialization is requested, we should be able to query for those symbols(instead of just class template) Number of symbols: 378574 -> 382784 Number of refs: 5098857 -> 5110689 Reviewers: hokein, gribozavr Reviewed By: gribozavr Subscribers: nridge, ilya-biryukov, ioeric, MaskRay, jkorous, arphaman, jdoerfert, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D59083 llvm-svn: 356125
Diffstat (limited to 'clang-tools-extra/unittests/clangd/IndexTests.cpp')
-rw-r--r--clang-tools-extra/unittests/clangd/IndexTests.cpp37
1 files changed, 37 insertions, 0 deletions
diff --git a/clang-tools-extra/unittests/clangd/IndexTests.cpp b/clang-tools-extra/unittests/clangd/IndexTests.cpp
index 7d60ede1c38..3a159279733 100644
--- a/clang-tools-extra/unittests/clangd/IndexTests.cpp
+++ b/clang-tools-extra/unittests/clangd/IndexTests.cpp
@@ -13,6 +13,8 @@
#include "index/Index.h"
#include "index/MemIndex.h"
#include "index/Merge.h"
+#include "index/Symbol.h"
+#include "clang/Index/IndexSymbol.h"
#include "gmock/gmock.h"
#include "gtest/gtest.h"
@@ -181,6 +183,41 @@ TEST(MemIndexTest, Lookup) {
EXPECT_THAT(lookup(*I, SymbolID("ns::nonono")), UnorderedElementsAre());
}
+TEST(MemIndexTest, TemplateSpecialization) {
+ SymbolSlab::Builder B;
+
+ Symbol S = symbol("TempSpec");
+ S.ID = SymbolID("0");
+ B.insert(S);
+
+ S = symbol("TempSpec");
+ S.ID = SymbolID("1");
+ S.SymInfo.Properties = static_cast<index::SymbolPropertySet>(
+ index::SymbolProperty::TemplateSpecialization);
+ B.insert(S);
+
+ S = symbol("TempSpec");
+ S.ID = SymbolID("2");
+ S.SymInfo.Properties = static_cast<index::SymbolPropertySet>(
+ index::SymbolProperty::TemplatePartialSpecialization);
+ B.insert(S);
+
+ auto I = MemIndex::build(std::move(B).build(), RefSlab());
+ FuzzyFindRequest Req;
+ Req.Query = "TempSpec";
+ Req.AnyScope = true;
+
+ std::vector<Symbol> Symbols;
+ I->fuzzyFind(Req, [&Symbols](const Symbol &Sym) { Symbols.push_back(Sym); });
+ EXPECT_EQ(Symbols.size(), 1U);
+ EXPECT_FALSE(Symbols.front().SymInfo.Properties &
+ static_cast<index::SymbolPropertySet>(
+ index::SymbolProperty::TemplateSpecialization));
+ EXPECT_FALSE(Symbols.front().SymInfo.Properties &
+ static_cast<index::SymbolPropertySet>(
+ index::SymbolProperty::TemplatePartialSpecialization));
+}
+
TEST(MergeIndexTest, Lookup) {
auto I = MemIndex::build(generateSymbols({"ns::A", "ns::B"}), RefSlab()),
J = MemIndex::build(generateSymbols({"ns::B", "ns::C"}), RefSlab());
OpenPOWER on IntegriCloud