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);
165 void processRelations(
const NamedDecl &ND,
const SymbolID &
ID,
166 ArrayRef<index::SymbolRelation> Relations);
168 std::optional<SymbolLocation> getTokenLocation(SourceLocation TokLoc);
170 std::optional<std::string> getIncludeHeader(
const Symbol &S, FileID);
174 const MacroInfo *MI,
const SourceManager &SM);
181 llvm::DenseMap<SymbolID, FileID> IncludeFiles;
182 void setIncludeLocation(
const Symbol &S, SourceLocation,
183 const include_cleaner::Symbol &Sym);
187 llvm::DenseMap<SymbolID, llvm::SmallVector<include_cleaner::Header>>
191 llvm::DenseSet<FileID> FilesWithObjCConstructs;
194 llvm::DenseSet<const IdentifierInfo *> IndexedMacros;
203 Preprocessor *PP =
nullptr;
204 std::shared_ptr<GlobalCodeCompletionAllocator> CompletionAllocator;
205 std::unique_ptr<CodeCompletionTUInfo> CompletionTUInfo;
210 index::SymbolRoleSet Roles;
214 void addRef(SymbolID
ID,
const SymbolRef &SR);
216 llvm::DenseSet<SymbolID> ReferencedSymbols;
222 llvm::DenseMap<const Decl *, const Decl *> CanonicalDecls;
224 llvm::DenseMap<FileID, bool> FilesToIndexCache;
227 class HeaderFileURICache;
228 std::unique_ptr<HeaderFileURICache> HeaderFileURIs;
229 llvm::DenseMap<const Decl *, SymbolID> DeclToIDCache;
230 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.