8#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANGD_INDEX_SYMBOLCOLLECTOR_H
9#define LLVM_CLANG_TOOLS_EXTRA_CLANGD_INDEX_SYMBOLCOLLECTOR_H
12#include "clang-include-cleaner/Record.h"
13#include "clang-include-cleaner/Types.h"
19#include "clang/AST/ASTContext.h"
20#include "clang/AST/Decl.h"
21#include "clang/Basic/SourceLocation.h"
22#include "clang/Basic/SourceManager.h"
23#include "clang/Index/IndexDataConsumer.h"
24#include "clang/Index/IndexSymbol.h"
25#include "clang/Sema/CodeCompleteConsumer.h"
26#include "llvm/ADT/DenseMap.h"
99 std::function<bool(
const SourceManager &, FileID)>
FileFilter =
nullptr;
107 const Options &Opts,
bool IsMainFileSymbol);
133 ArrayRef<index::SymbolRelation> Relations,
135 index::IndexDataConsumer::ASTNodeInfo
ASTNode)
override;
138 index::SymbolRoleSet Roles,
139 SourceLocation
Loc)
override;
156 bool IsMainFileSymbol);
157 void addDefinition(
const NamedDecl &,
const Symbol &DeclSymbol);
158 void processRelations(
const NamedDecl &ND,
const SymbolID &
ID,
159 ArrayRef<index::SymbolRelation> Relations);
161 std::optional<SymbolLocation> getTokenLocation(SourceLocation TokLoc);
163 std::optional<std::string> getIncludeHeader(
const Symbol &S, FileID);
167 const MacroInfo *MI,
const SourceManager &SM);
174 llvm::DenseMap<SymbolID, FileID> IncludeFiles;
175 void setIncludeLocation(
const Symbol &S, SourceLocation,
176 const include_cleaner::Symbol &Sym);
180 llvm::DenseMap<SymbolID, std::optional<include_cleaner::Header>>
184 llvm::DenseSet<FileID> FilesWithObjCConstructs;
187 llvm::DenseSet<const IdentifierInfo *> IndexedMacros;
196 Preprocessor *PP =
nullptr;
197 std::shared_ptr<GlobalCodeCompletionAllocator> CompletionAllocator;
198 std::unique_ptr<CodeCompletionTUInfo> CompletionTUInfo;
203 index::SymbolRoleSet Roles;
207 void addRef(SymbolID
ID,
const SymbolRef &SR);
209 llvm::DenseSet<SymbolID> ReferencedSymbols;
215 llvm::DenseMap<const Decl *, const Decl *> CanonicalDecls;
217 llvm::DenseMap<FileID, bool> FilesToIndexCache;
220 class HeaderFileURICache;
221 std::unique_ptr<HeaderFileURICache> HeaderFileURIs;
222 llvm::DenseMap<const Decl *, SymbolID> DeclToIDCache;
223 llvm::DenseMap<const MacroInfo *, SymbolID> MacroToIDCache;
const FunctionDecl * Decl
RefSlab::Builder is a mutable container that can 'freeze' to RefSlab.
An efficient structure of storing large set of symbol references in memory.
RelationSlab::Builder is a mutable container that can 'freeze' to RelationSlab.
Collect declarations (symbols) from an AST.
bool shouldIndexFile(FileID FID)
Returns true if we are interested in references and declarations from FID.
static bool shouldCollectSymbol(const NamedDecl &ND, const ASTContext &ASTCtx, const Options &Opts, bool IsMainFileSymbol)
Returns true is ND should be collected.
static const Decl * getRefContainer(const Decl *Enclosing, const SymbolCollector::Options &Opts)
void setPreprocessor(Preprocessor &PP)
bool handleDeclOccurrence(const Decl *D, index::SymbolRoleSet Roles, ArrayRef< index::SymbolRelation > Relations, SourceLocation Loc, index::IndexDataConsumer::ASTNodeInfo ASTNode) override
RelationSlab takeRelations()
void handleMacros(const MainFileMacros &MacroRefsToIndex)
void initialize(ASTContext &Ctx) override
bool handleMacroOccurrence(const IdentifierInfo *Name, const MacroInfo *MI, index::SymbolRoleSet Roles, SourceLocation Loc) override
void setPreprocessor(std::shared_ptr< Preprocessor > PP) override
SymbolSlab::Builder is a mutable container that can 'freeze' to SymbolSlab.
An immutable symbol container that stores a set of symbols.
RefKind
Describes the kind of a cross-reference.
===– Representation.cpp - ClangDoc Representation --------—*- C++ -*-===//
Simplified description of a clang AST node.
bool CollectMacro
Collect macros.
std::string FallbackDir
When symbol paths cannot be resolved to absolute paths (e.g.
RefKind RefFilter
The symbol ref kinds that will be collected.
bool CollectMainFileSymbols
Collect symbols local to main-files, such as static functions, symbols inside an anonymous namespace,...
bool StoreAllDocumentation
If set to true, SymbolCollector will collect doc for all symbols.
bool CollectMainFileRefs
Collect references to main-file symbols.
bool RefsInHeaders
If set to true, SymbolCollector will collect all refs (from main file and included headers); otherwis...
bool CollectReserved
Collect symbols with reserved names, like __Vector_base.
const include_cleaner::PragmaIncludes * PragmaIncludes
If set, this is used to map symbol #include path to a potentially different #include path specified b...
std::function< bool(const SourceManager &, FileID)> FileFilter
If this is set, only collect symbols/references from a file if FileFilter(SM, FID) is true.
The class presents a C++ symbol, e.g.