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);
94 bool SupportContainedRefs;
96 struct RefSlabAndCountReferences {
97 std::shared_ptr<RefSlab> Slab;
98 bool CountReferences =
false;
100 mutable std::mutex Mutex;
103 llvm::StringMap<std::shared_ptr<SymbolSlab>> SymbolsSnapshot;
104 llvm::StringMap<RefSlabAndCountReferences> RefsSnapshot;
105 llvm::StringMap<std::shared_ptr<RelationSlab>> RelationsSnapshot;
118 const include_cleaner::PragmaIncludes &PI);
151 std::mutex UpdateIndexMu;
152 unsigned MainIndexVersion = 0;
153 unsigned PreambleIndexVersion = 0;
156using SlabTuple = std::tuple<SymbolSlab, RefSlab, RelationSlab>;
167 const include_cleaner::PragmaIncludes &PI);
183 std::optional<IndexFileIn>
getShard(llvm::StringRef Uri)
const;
189 llvm::DenseSet<const Symbol *> Symbols;
191 llvm::DenseSet<const Ref *> Refs;
193 llvm::DenseSet<const Relation *> Relations;
201 llvm::StringMap<FileShard> Shards;
203 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...