summaryrefslogtreecommitdiffstats
path: root/clang-tools-extra/clangd/index/SymbolCollector.cpp
diff options
context:
space:
mode:
authorHaojian Wu <hokein@google.com>2019-01-10 09:22:40 +0000
committerHaojian Wu <hokein@google.com>2019-01-10 09:22:40 +0000
commit8f85b9f86718c269d49be4eb2bb73466a95f5347 (patch)
treee907e859e0a0a45d35a517e4ddcc72a8e196f2f7 /clang-tools-extra/clangd/index/SymbolCollector.cpp
parent1c69ab286041992eedb0cc2bc2730f24f107175d (diff)
downloadbcm5719-llvm-8f85b9f86718c269d49be4eb2bb73466a95f5347.tar.gz
bcm5719-llvm-8f85b9f86718c269d49be4eb2bb73466a95f5347.zip
[clangd] Don't store completion info if the symbol is not used for code completion.
Summary: This would save us some memory and disk space: - Dex usage (261 MB vs 266 MB) - Disk (75 MB vs 76 MB) It would save more when we index the main file symbol D55185. Reviewers: ilya-biryukov Reviewed By: ilya-biryukov Subscribers: nridge, ioeric, MaskRay, jkorous, arphaman, kadircet, cfe-commits Differential Revision: https://reviews.llvm.org/D56314 llvm-svn: 350803
Diffstat (limited to 'clang-tools-extra/clangd/index/SymbolCollector.cpp')
-rw-r--r--clang-tools-extra/clangd/index/SymbolCollector.cpp32
1 files changed, 22 insertions, 10 deletions
diff --git a/clang-tools-extra/clangd/index/SymbolCollector.cpp b/clang-tools-extra/clangd/index/SymbolCollector.cpp
index cdc6aa5c01f..23b1776ae20 100644
--- a/clang-tools-extra/clangd/index/SymbolCollector.cpp
+++ b/clang-tools-extra/clangd/index/SymbolCollector.cpp
@@ -530,6 +530,10 @@ const Symbol *SymbolCollector::addDeclaration(const NamedDecl &ND,
getTokenLocation(Loc, SM, Opts, ASTCtx->getLangOpts(), FileURI))
S.CanonicalDeclaration = *DeclLoc;
+ S.Origin = Opts.Origin;
+ if (ND.getAvailability() == AR_Deprecated)
+ S.Flags |= Symbol::Deprecated;
+
// 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.");
@@ -539,13 +543,28 @@ const Symbol *SymbolCollector::addDeclaration(const NamedDecl &ND,
*ASTCtx, *PP, CodeCompletionContext::CCC_Symbol, *CompletionAllocator,
*CompletionTUInfo,
/*IncludeBriefComments*/ false);
- std::string Signature;
- std::string SnippetSuffix;
- getSignature(*CCS, &Signature, &SnippetSuffix);
std::string Documentation =
formatDocumentation(*CCS, getDocComment(Ctx, SymbolCompletion,
/*CommentsFromHeaders=*/true));
+ // For symbols not indexed for completion (class members), we also store their
+ // docs in the index, because Sema doesn't load the docs from the preamble, we
+ // rely on the index to get the docs.
+ // FIXME: this can be optimized by only storing the docs in dynamic index --
+ // dynamic index should index these symbols when Sema completes a member
+ // completion.
+ S.Documentation = Documentation;
+ if (!(S.Flags & Symbol::IndexedForCodeCompletion)) {
+ Symbols.insert(S);
+ return Symbols.find(S.ID);
+ }
+
+ std::string Signature;
+ std::string SnippetSuffix;
+ getSignature(*CCS, &Signature, &SnippetSuffix);
+ S.Signature = Signature;
+ S.CompletionSnippetSuffix = SnippetSuffix;
std::string ReturnType = getReturnType(*CCS);
+ S.ReturnType = ReturnType;
std::string Include;
if (Opts.CollectIncludePath && shouldCollectIncludePath(S.SymInfo.Kind)) {
@@ -555,10 +574,6 @@ const Symbol *SymbolCollector::addDeclaration(const NamedDecl &ND,
QName, SM, SM.getExpansionLoc(ND.getLocation()), Opts))
Include = std::move(*Header);
}
- S.Signature = Signature;
- S.CompletionSnippetSuffix = SnippetSuffix;
- S.Documentation = Documentation;
- S.ReturnType = ReturnType;
if (!Include.empty())
S.IncludeHeaders.emplace_back(Include, 1);
@@ -569,9 +584,6 @@ const Symbol *SymbolCollector::addDeclaration(const NamedDecl &ND,
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);
}
OpenPOWER on IntegriCloud