[PATCH] D56314: [clangd] Don't store completion info if the symbol is not used for code completion.
Haojian Wu via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Fri Jan 4 05:16:43 PST 2019
hokein created this revision.
Herald added subscribers: cfe-commits, kadircet, arphaman, jkorous, MaskRay, ioeric, ilya-biryukov.
This would save us some memory and disk space:
- Dex usage (269 MB vs 278 MB)
- Disk (73 MB vs 76 MB)
It would save more when we index the main file symbol.
Repository:
rCTE Clang Tools Extra
https://reviews.llvm.org/D56314
Files:
clangd/index/Index.h
clangd/index/SymbolCollector.cpp
unittests/clangd/SymbolCollectorTests.cpp
Index: unittests/clangd/SymbolCollectorTests.cpp
===================================================================
--- unittests/clangd/SymbolCollectorTests.cpp
+++ unittests/clangd/SymbolCollectorTests.cpp
@@ -655,10 +655,18 @@
void Foo::ssf() {}
)";
runSymbolCollector(Header, Main);
- EXPECT_THAT(Symbols,
- UnorderedElementsAre(QName("Foo"), QName("Foo::f"),
- QName("Foo::g"), QName("Foo::sf"),
- QName("Foo::ssf"), QName("Foo::x")));
+ EXPECT_THAT(Symbols, UnorderedElementsAre(
+ QName("Foo"),
+ AllOf(QName("Foo::f"), Doc(""), ReturnType(""),
+ ForCodeCompletion(false)),
+ AllOf(QName("Foo::g"), Doc(""), ReturnType(""),
+ ForCodeCompletion(false)),
+ AllOf(QName("Foo::sf"), Doc(""), ReturnType(""),
+ ForCodeCompletion(false)),
+ AllOf(QName("Foo::ssf"), Doc(""), ReturnType(""),
+ ForCodeCompletion(false)),
+ AllOf(QName("Foo::x"), Doc(""), ReturnType(""),
+ ForCodeCompletion(false))));
}
TEST_F(SymbolCollectorTest, Scopes) {
Index: clangd/index/SymbolCollector.cpp
===================================================================
--- clangd/index/SymbolCollector.cpp
+++ clangd/index/SymbolCollector.cpp
@@ -531,6 +531,18 @@
getTokenLocation(Loc, SM, Opts, ASTCtx->getLangOpts(), FileURI))
S.CanonicalDeclaration = *DeclLoc;
+ S.Origin = Opts.Origin;
+ if (ND.getAvailability() == AR_Deprecated)
+ S.Flags |= Symbol::Deprecated;
+
+ auto Insert = [this](const Symbol& S) {
+ Symbols.insert(S);
+ return Symbols.find(S.ID);
+ };
+
+ if (!(S.Flags & Symbol::IndexedForCodeCompletion))
+ return Insert(S);
+
// Add completion info.
// FIXME: we may want to choose a different redecl, or combine from several.
assert(ASTCtx && PP.get() && "ASTContext and Preprocessor must be set.");
@@ -569,12 +581,7 @@
if (TypeStorage)
S.Type = TypeStorage->raw();
}
-
- S.Origin = Opts.Origin;
- if (ND.getAvailability() == AR_Deprecated)
- S.Flags |= Symbol::Deprecated;
- Symbols.insert(S);
- return Symbols.find(S.ID);
+ return Insert(S);
}
void SymbolCollector::addDefinition(const NamedDecl &ND,
Index: clangd/index/Index.h
===================================================================
--- clangd/index/Index.h
+++ clangd/index/Index.h
@@ -229,6 +229,9 @@
None = 0,
/// Whether or not this symbol is meant to be used for the code completion.
/// See also isIndexedForCodeCompletion().
+ /// Note that we don't store completion information (signature, snippet,
+ /// documentation, type, inclues, etc) if the symbol is not indexed for code
+ /// completion.
IndexedForCodeCompletion = 1 << 0,
/// Indicates if the symbol is deprecated.
Deprecated = 1 << 1,
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D56314.180233.patch
Type: text/x-patch
Size: 3095 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20190104/5f305971/attachment.bin>
More information about the cfe-commits
mailing list