[PATCH] D52274: [clangd] Collect and store expected types in the index

Ilya Biryukov via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Nov 23 03:13:56 PST 2018


ilya-biryukov updated this revision to Diff 175104.
ilya-biryukov added a comment.

- Remove another accidental change


Repository:
  rCTE Clang Tools Extra

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
@@ -198,6 +198,7 @@
     IO.mapOptional("Documentation", Sym.Documentation);
     IO.mapOptional("ReturnType", Sym.ReturnType);
     IO.mapOptional("IncludeHeaders", Sym.IncludeHeaders);
+    IO.mapOptional("Type", Sym.Type);
   }
 };
 
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);
 
+  llvm::Optional<OpaqueType> Type;
+  if (S.Flags & Symbol::IndexedForCodeCompletion)
+    Type = OpaqueType::fromCompletionResult(*ASTCtx, SymbolCompletion);
+  S.Type = Type ? Type->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
@@ -272,6 +272,7 @@
   writeVar(Sym.IncludeHeaders.size(), OS);
   for (const auto &Include : Sym.IncludeHeaders)
     WriteInclude(Include);
+  writeVar(Strings.index(Sym.Type), OS);
 }
 
 Symbol readSymbol(Reader &Data, ArrayRef<StringRef> Strings) {
@@ -295,6 +296,7 @@
     I.IncludeHeader = Data.consumeString(Strings);
     I.References = Data.consumeVar();
   }
+  Sym.Type = Data.consumeString(Strings);
   return Sym;
 }
 
Index: clangd/index/Index.h
===================================================================
--- clangd/index/Index.h
+++ clangd/index/Index.h
@@ -10,12 +10,14 @@
 #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"
 #include "llvm/ADT/DenseSet.h"
 #include "llvm/ADT/Hashing.h"
 #include "llvm/ADT/Optional.h"
+#include "llvm/ADT/STLExtras.h"
 #include "llvm/ADT/SmallVector.h"
 #include "llvm/ADT/StringExtras.h"
 #include "llvm/ADT/StringRef.h"
@@ -278,6 +280,9 @@
     ImplementationDetail = 1 << 2,
   };
 
+  /// Type of the symbol, used for scoring purposes.
+  llvm::StringRef Type;
+
   SymbolFlag Flags = SymbolFlag::None;
   /// FIXME: also add deprecation message and fixit?
 };
@@ -311,6 +316,7 @@
 
   for (auto &Include : S.IncludeHeaders)
     CB(Include.IncludeHeader);
+  CB(S.Type);
 }
 
 // Computes query-independent quality score for a Symbol.


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D52274.175104.patch
Type: text/x-patch
Size: 2671 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20181123/a358f21d/attachment.bin>


More information about the cfe-commits mailing list