[PATCH] D52274: [clangd] Collect and store expected types in the index
Ilya Biryukov via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Mon Nov 26 07:30:45 PST 2018
ilya-biryukov updated this revision to Diff 175254.
ilya-biryukov added a comment.
- Remove unused #include
Repository:
rCTE Clang Tools Extra
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D52274/new/
https://reviews.llvm.org/D52274
Files:
clangd/index/Index.h
clangd/index/Serialization.cpp
clangd/index/SymbolCollector.cpp
clangd/index/YAMLSerialization.cpp
Index: clangd/index/YAMLSerialization.cpp
===================================================================
--- clangd/index/YAMLSerialization.cpp
+++ clangd/index/YAMLSerialization.cpp
@@ -197,6 +197,7 @@
IO.mapOptional("CompletionSnippetSuffix", Sym.CompletionSnippetSuffix);
IO.mapOptional("Documentation", Sym.Documentation);
IO.mapOptional("ReturnType", Sym.ReturnType);
+ IO.mapOptional("Type", Sym.Type);
IO.mapOptional("IncludeHeaders", Sym.IncludeHeaders);
}
};
Index: clangd/index/SymbolCollector.cpp
===================================================================
--- clangd/index/SymbolCollector.cpp
+++ clangd/index/SymbolCollector.cpp
@@ -587,6 +587,11 @@
if (!Include.empty())
S.IncludeHeaders.emplace_back(Include, 1);
+ if (S.Flags & Symbol::IndexedForCodeCompletion) {
+ if (auto T = OpaqueType::fromCompletionResult(*ASTCtx, SymbolCompletion))
+ S.Type = T->raw();
+ }
+
S.Origin = Opts.Origin;
if (ND.getAvailability() == AR_Deprecated)
S.Flags |= Symbol::Deprecated;
Index: clangd/index/Serialization.cpp
===================================================================
--- clangd/index/Serialization.cpp
+++ clangd/index/Serialization.cpp
@@ -264,6 +264,7 @@
writeVar(Strings.index(Sym.CompletionSnippetSuffix), OS);
writeVar(Strings.index(Sym.Documentation), OS);
writeVar(Strings.index(Sym.ReturnType), OS);
+ writeVar(Strings.index(Sym.Type), OS);
auto WriteInclude = [&](const Symbol::IncludeHeaderWithReferences &Include) {
writeVar(Strings.index(Include.IncludeHeader), OS);
@@ -290,6 +291,7 @@
Sym.CompletionSnippetSuffix = Data.consumeString(Strings);
Sym.Documentation = Data.consumeString(Strings);
Sym.ReturnType = Data.consumeString(Strings);
+ Sym.Type = Data.consumeString(Strings);
Sym.IncludeHeaders.resize(Data.consumeVar());
for (auto &I : Sym.IncludeHeaders) {
I.IncludeHeader = Data.consumeString(Strings);
@@ -339,7 +341,7 @@
// The current versioning scheme is simple - non-current versions are rejected.
// If you make a breaking change, bump this version number to invalidate stored
// data. Later we may want to support some backward compatibility.
-constexpr static uint32_t Version = 7;
+constexpr static uint32_t Version = 8;
Expected<IndexFileIn> readRIFF(StringRef Data) {
auto RIFF = riff::readFile(Data);
Index: clangd/index/Index.h
===================================================================
--- clangd/index/Index.h
+++ clangd/index/Index.h
@@ -10,6 +10,7 @@
#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANGD_INDEX_INDEX_H
#define LLVM_CLANG_TOOLS_EXTRA_CLANGD_INDEX_INDEX_H
+#include "ExpectedTypes.h"
#include "clang/Index/IndexSymbol.h"
#include "clang/Lex/Lexer.h"
#include "llvm/ADT/DenseMap.h"
@@ -242,6 +243,10 @@
/// e.g. return type of a function, or type of a variable.
llvm::StringRef ReturnType;
+ /// Raw representation of the OpaqueType of the symbol, used for scoring
+ /// purposes.
+ llvm::StringRef Type;
+
struct IncludeHeaderWithReferences {
IncludeHeaderWithReferences() = default;
@@ -300,6 +305,7 @@
CB(S.CompletionSnippetSuffix);
CB(S.Documentation);
CB(S.ReturnType);
+ CB(S.Type);
auto RawCharPointerCB = [&CB](const char *&P) {
llvm::StringRef S(P);
CB(S);
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D52274.175254.patch
Type: text/x-patch
Size: 3304 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20181126/eaf289d5/attachment-0001.bin>
More information about the cfe-commits
mailing list