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"
20#include "clang/AST/ASTContext.h"
21#include "clang/AST/Decl.h"
22#include "clang/Basic/LLVM.h"
23#include "clang/Basic/SourceLocation.h"
24#include "clang/Basic/SourceManager.h"
25#include "clang/Index/IndexDataConsumer.h"
26#include "clang/Index/IndexSymbol.h"
27#include "clang/Sema/CodeCompleteConsumer.h"
28#include "llvm/ADT/DenseMap.h"
29#include "llvm/ADT/DenseSet.h"
30#include "llvm/ADT/SmallVector.h"
31#include "llvm/ADT/StringRef.h"
106 std::function<bool(
const SourceManager &, FileID)>
FileFilter =
nullptr;
114 const Options &Opts,
bool IsMainFileSymbol);
140 ArrayRef<index::SymbolRelation> Relations,
142 index::IndexDataConsumer::ASTNodeInfo
ASTNode)
override;
145 index::SymbolRoleSet Roles,
146 SourceLocation
Loc)
override;
163 bool IsMainFileSymbol);
164 void addDefinition(
const NamedDecl &,
const Symbol &DeclSymbol,
166 void processRelations(
const NamedDecl &ND,
const SymbolID &
ID,
167 ArrayRef<index::SymbolRelation> Relations);
169 std::optional<SymbolLocation> getTokenLocation(SourceLocation TokLoc);
171 std::optional<std::string> getIncludeHeader(
const Symbol &S, FileID);
175 const MacroInfo *MI,
const SourceManager &SM);
182 llvm::DenseMap<SymbolID, FileID> IncludeFiles;
183 void setIncludeLocation(
const Symbol &S, SourceLocation,
184 const include_cleaner::Symbol &Sym);
188 llvm::DenseMap<SymbolID, llvm::SmallVector<include_cleaner::Header>>
192 llvm::DenseSet<FileID> FilesWithObjCConstructs;
195 llvm::DenseSet<const IdentifierInfo *> IndexedMacros;
204 Preprocessor *PP =
nullptr;
205 std::shared_ptr<GlobalCodeCompletionAllocator> CompletionAllocator;
206 std::unique_ptr<CodeCompletionTUInfo> CompletionTUInfo;
211 index::SymbolRoleSet Roles;
212 index::SymbolKind
Kind;
216 void addRef(SymbolID
ID,
const SymbolRef &SR);
218 llvm::DenseSet<SymbolID> ReferencedSymbols;
224 llvm::DenseMap<const Decl *, const Decl *> CanonicalDecls;
226 llvm::DenseMap<FileID, bool> FilesToIndexCache;
229 class HeaderFileURICache;
230 std::unique_ptr<HeaderFileURICache> HeaderFileURIs;
231 llvm::DenseMap<const Decl *, SymbolID> DeclToIDCache;
232 llvm::DenseMap<const MacroInfo *, SymbolID> MacroToIDCache;
const FunctionDecl * Decl
llvm::SmallString< 256U > Name
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.