15#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANGD_INDEX_FILEINDEX_H
16#define LLVM_CLANG_TOOLS_EXTRA_CLANGD_INDEX_FILEINDEX_H
19#include "clang-include-cleaner/Record.h"
28#include "clang/Lex/Preprocessor.h"
29#include "llvm/ADT/DenseSet.h"
30#include "llvm/ADT/StringMap.h"
31#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);
95 struct RefSlabAndCountReferences {
96 std::shared_ptr<RefSlab> Slab;
97 bool CountReferences =
false;
99 mutable std::mutex Mutex;
102 llvm::StringMap<std::shared_ptr<SymbolSlab>> SymbolsSnapshot;
103 llvm::StringMap<RefSlabAndCountReferences> RefsSnapshot;
104 llvm::StringMap<std::shared_ptr<RelationSlab>> RelationsSnapshot;
117 const include_cleaner::PragmaIncludes &PI);
150 std::mutex UpdateIndexMu;
151 unsigned MainIndexVersion = 0;
152 unsigned PreambleIndexVersion = 0;
155using SlabTuple = std::tuple<SymbolSlab, RefSlab, RelationSlab>;
166 const include_cleaner::PragmaIncludes &PI);
182 std::optional<IndexFileIn>
getShard(llvm::StringRef Uri)
const;
188 llvm::DenseSet<const Symbol *> Symbols;
190 llvm::DenseSet<const Ref *> Refs;
192 llvm::DenseSet<const Relation *> Relations;
200 llvm::StringMap<FileShard> Shards;
202 llvm::DenseMap<const Ref *, SymbolID> RefToSymID;
This manages symbols from files and an in-memory index on all symbols.
void updatePreamble(PathRef Path, llvm::StringRef Version, ASTContext &AST, Preprocessor &PP, const include_cleaner::PragmaIncludes &PI)
Update preamble symbols of file Path with all declarations in AST and macros in PP.
void profile(MemoryTree &MT) const
void updateMain(PathRef Path, ParsedAST &AST)
Update symbols and references from main file Path with indexMainDecls.
A container of slabs associated with a key.
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::unique_ptr< SymbolIndex > buildIndex(IndexType, DuplicateHandling DuplicateHandle=DuplicateHandling::PickOne, size_t *Version=nullptr)
The index keeps the slabs alive.
void profile(MemoryTree &MT) const
Values in a Context are indexed by typed keys.
Stores and provides access to parsed AST.
IndexType
Select between in-memory index implementations, which have tradeoffs.
IndexContents
Describes what data is covered by an index.
std::string Path
A typedef to represent a file path.
SlabTuple indexMainDecls(ParsedAST &AST)
Retrieves symbols and refs of local top level decls in AST (i.e.
std::tuple< SymbolSlab, RefSlab, RelationSlab > SlabTuple
DuplicateHandling
How to handle duplicated symbols across multiple files.
SlabTuple indexHeaderSymbols(llvm::StringRef Version, ASTContext &AST, Preprocessor &PP, const include_cleaner::PragmaIncludes &PI)
Index declarations from AST and macros from PP that are declared in included headers.
llvm::StringMap< IncludeGraphNode > IncludeGraph
llvm::StringRef PathRef
A typedef to represent a ref to file path.
===– Representation.cpp - ClangDoc Representation --------—*- C++ -*-===//
Takes slabs coming from a TU (multiple files) and shards them per declaration location.
std::vector< llvm::StringRef > getAllSources() const
Returns uris for all files that has a shard.
std::optional< IndexFileIn > getShard(llvm::StringRef Uri) const
Generates index shard for the Uri.
A tree that can be used to represent memory usage of nested components while preserving the hierarchy...