Go to the documentation of this file.
15 #ifndef LLVM_CLANG_TOOLS_EXTRA_CLANGD_INDEX_FILEINDEX_H
16 #define LLVM_CLANG_TOOLS_EXTRA_CLANGD_INDEX_FILEINDEX_H
28 #include "clang/Lex/Preprocessor.h"
29 #include "clang/Tooling/CompilationDatabase.h"
30 #include "llvm/ADT/DenseSet.h"
31 #include "llvm/ADT/Optional.h"
32 #include "llvm/ADT/StringMap.h"
33 #include "llvm/ADT/StringRef.h"
78 std::unique_ptr<RefSlab>
Refs,
79 std::unique_ptr<RelationSlab> Relations,
bool CountReferences);
85 std::unique_ptr<SymbolIndex>
88 size_t *Version =
nullptr);
91 struct RefSlabAndCountReferences {
92 std::shared_ptr<RefSlab> Slab;
93 bool CountReferences =
false;
95 mutable std::mutex Mutex;
98 llvm::StringMap<std::shared_ptr<SymbolSlab>> SymbolsSnapshot;
99 llvm::StringMap<RefSlabAndCountReferences> RefsSnapshot;
100 llvm::StringMap<std::shared_ptr<RelationSlab>> RelatiosSnapshot;
112 std::shared_ptr<Preprocessor>
PP,
145 std::mutex UpdateIndexMu;
146 unsigned MainIndexVersion = 0;
147 unsigned PreambleIndexVersion = 0;
150 using SlabTuple = std::tuple<SymbolSlab, RefSlab, RelationSlab>;
160 std::shared_ptr<Preprocessor>
PP,
177 llvm::Optional<IndexFileIn>
getShard(llvm::StringRef Uri)
const;
183 llvm::DenseSet<const Symbol *>
Symbols;
185 llvm::DenseSet<const Ref *>
Refs;
187 llvm::DenseSet<const Relation *> Relations;
195 llvm::StringMap<FileShard> Shards;
197 llvm::DenseMap<const Ref *, SymbolID> RefToSymID;
203 #endif // LLVM_CLANG_TOOLS_EXTRA_CLANGD_INDEX_FILEINDEX_H
IndexType
Select between in-memory index implementations, which have tradeoffs.
std::string Path
A typedef to represent a file path.
FileIndex(bool UseDex=true)
FileShardedIndex(IndexFileIn Input)
HintPath is used to convert file URIs stored in symbols into absolute paths.
This manages symbols from files and an in-memory index on all symbols.
A container of slabs associated with a key.
DuplicateHandling
How to handle duplicated symbols across multiple files.
llvm::Optional< IndexFileIn > getShard(llvm::StringRef Uri) const
Generates index shard for the Uri.
Maps a definition location onto an #include file, based on a set of filename rules.
void update(llvm::StringRef Key, std::unique_ptr< SymbolSlab > Symbols, std::unique_ptr< RefSlab > Refs, std::unique_ptr< RelationSlab > Relations, bool CountReferences)
Updates all slabs associated with the Key.
std::tuple< SymbolSlab, RefSlab, RelationSlab > SlabTuple
SlabTuple indexHeaderSymbols(llvm::StringRef Version, ASTContext &AST, std::shared_ptr< Preprocessor > PP, const CanonicalIncludes &Includes)
Index declarations from AST and macros from PP that are declared in included headers.
Values in a Context are indexed by typed keys.
void updateMain(PathRef Path, ParsedAST &AST)
Update symbols and references from main file Path with indexMainDecls.
std::vector< llvm::StringRef > getAllSources() const
Returns uris for all files that has a shard.
llvm::StringRef PathRef
A typedef to represent a ref to file path.
Takes slabs coming from a TU (multiple files) and shards them per declaration location.
===– Representation.cpp - ClangDoc Representation --------—*- C++ -*-===//
llvm::StringMap< IncludeGraphNode > IncludeGraph
std::unique_ptr< SymbolIndex > buildIndex(IndexType, DuplicateHandling DuplicateHandle=DuplicateHandling::PickOne, size_t *Version=nullptr)
The index keeps the slabs alive.
Stores and provides access to parsed AST.
void updatePreamble(PathRef Path, llvm::StringRef Version, ASTContext &AST, std::shared_ptr< Preprocessor > PP, const CanonicalIncludes &Includes)
Update preamble symbols of file Path with all declarations in AST and macros in PP.
SlabTuple indexMainDecls(ParsedAST &AST)
Retrieves symbols and refs of local top level decls in AST (i.e.