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,
184 std::optional<IndexFileIn>
getShard(llvm::StringRef Uri)
const;
190 llvm::DenseSet<const Symbol *>
Symbols;
192 llvm::DenseSet<const Ref *> Refs;
194 llvm::DenseSet<const Relation *> Relations;
202 llvm::StringMap<FileShard> Shards;
204 llvm::DenseMap<const Ref *, SymbolID> RefToSymID;
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.
FileIndex(bool SupportContainedRefs)
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.
FileSymbols(IndexContents IdxContents, bool SupportContainedRefs)
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.
MergedIndex(const SymbolIndex *Dynamic, const SymbolIndex *Static)
Stores and provides access to parsed AST.
FIXME: Skip testing on windows temporarily due to the different escaping code mode.
IndexType
Select between in-memory index implementations, which have tradeoffs.
IndexContents
Describes what data is covered by an index.
SlabTuple indexMainDecls(ParsedAST &AST)
Retrieves symbols and refs of local top level decls in AST (i.e.
DuplicateHandling
How to handle duplicated symbols across multiple files.
SlabTuple indexHeaderSymbols(llvm::StringRef Version, ASTContext &AST, Preprocessor &PP, const include_cleaner::PragmaIncludes &PI, SymbolOrigin Origin)
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.
std::string Path
A typedef to represent a file path.
std::tuple< SymbolSlab, RefSlab, RelationSlab > SlabTuple
===– Representation.cpp - ClangDoc Representation --------—*- C++ -*-===//
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.
FileShardedIndex(IndexFileIn Input)
HintPath is used to convert file URIs stored in symbols into absolute paths.
A tree that can be used to represent memory usage of nested components while preserving the hierarchy...