8 #ifndef LLVM_CLANG_TOOLS_EXTRA_CLANGD_INDEX_SYMBOL_COLLECTOR_H 9 #define LLVM_CLANG_TOOLS_EXTRA_CLANGD_INDEX_SYMBOL_COLLECTOR_H 15 #include "clang/AST/ASTContext.h" 16 #include "clang/AST/Decl.h" 17 #include "clang/Basic/SourceLocation.h" 18 #include "clang/Basic/SourceManager.h" 19 #include "clang/Index/IndexDataConsumer.h" 20 #include "clang/Index/IndexSymbol.h" 21 #include "clang/Sema/CodeCompleteConsumer.h" 22 #include "llvm/ADT/DenseMap.h" 23 #include "llvm/Support/Regex.h" 87 std::function<bool(const SourceManager &, FileID)>
FileFilter =
nullptr;
94 const Options &Opts,
bool IsMainFileSymbol);
99 this->PP = std::move(PP);
104 ArrayRef<index::SymbolRelation> Relations,
106 index::IndexDataConsumer::ASTNodeInfo ASTNode)
override;
109 index::SymbolRoleSet Roles,
110 SourceLocation Loc)
override;
127 bool IsMainFileSymbol);
128 void addDefinition(
const NamedDecl &,
const Symbol &DeclSymbol);
129 void processRelations(
const NamedDecl &ND,
const SymbolID &ID,
130 ArrayRef<index::SymbolRelation> Relations);
132 llvm::Optional<std::string> getIncludeHeader(llvm::StringRef
QName, FileID);
133 bool isSelfContainedHeader(FileID);
135 static bool isDontIncludeMeHeader(llvm::StringRef);
141 llvm::DenseMap<SymbolID, FileID> IncludeFiles;
142 void setIncludeLocation(
const Symbol &S, SourceLocation);
144 llvm::DenseSet<const IdentifierInfo *> IndexedMacros;
153 std::shared_ptr<Preprocessor> PP;
154 std::shared_ptr<GlobalCodeCompletionAllocator> CompletionAllocator;
155 std::unique_ptr<CodeCompletionTUInfo> CompletionTUInfo;
157 using SymbolRef = std::pair<SourceLocation, index::SymbolRoleSet>;
159 llvm::DenseSet<const NamedDecl *> ReferencedDecls;
160 llvm::DenseSet<const IdentifierInfo *> ReferencedMacros;
161 llvm::DenseMap<const NamedDecl *, std::vector<SymbolRef>> DeclRefs;
162 llvm::DenseMap<SymbolID, std::vector<SymbolRef>> MacroRefs;
168 llvm::DenseMap<const Decl *, const Decl *> CanonicalDecls;
170 llvm::DenseMap<FileID, bool> FilesToIndexCache;
171 llvm::DenseMap<FileID, bool> HeaderIsSelfContainedCache;
SourceLocation Loc
'#' location in the include directive
bool handleMacroOccurrence(const IdentifierInfo *Name, const MacroInfo *MI, index::SymbolRoleSet Roles, SourceLocation Loc) override
const FunctionDecl * Decl
bool CollectMacro
Collect macros.
An immutable symbol container that stores a set of symbols.
An efficient structure of storing large set of symbol references in memory.
Collect declarations (symbols) from an AST.
void initialize(ASTContext &Ctx) override
SymbolSlab::Builder is a mutable container that can 'freeze' to SymbolSlab.
Maps a definition location onto an #include file, based on a set of filename rules.
std::string FallbackDir
When symbol paths cannot be resolved to absolute paths (e.g.
bool StoreAllDocumentation
If set to true, SymbolCollector will collect doc for all symbols.
static constexpr llvm::StringLiteral Name
RefKind
Describes the kind of a cross-reference.
SymbolCollector(Options Opts)
void handleMacros(const MainFileMacros &MacroRefsToIndex)
bool shouldIndexFile(FileID FID)
Returns true if we are interested in references and declarations from FID.
RelationSlab::Builder is a mutable container that can 'freeze' to RelationSlab.
bool CollectMainFileSymbols
Collect symbols local to main-files, such as static functions and symbols inside an anonymous namespa...
std::function< bool(const SourceManager &, FileID)> FileFilter
If this is set, only collect symbols/references from a file if FileFilter(SM, FID) is true...
RefSlab::Builder is a mutable container that can 'freeze' to RefSlab.
bool handleDeclOccurrence(const Decl *D, index::SymbolRoleSet Roles, ArrayRef< index::SymbolRelation > Relations, SourceLocation Loc, index::IndexDataConsumer::ASTNodeInfo ASTNode) override
static bool shouldCollectSymbol(const NamedDecl &ND, const ASTContext &ASTCtx, const Options &Opts, bool IsMainFileSymbol)
Returns true is ND should be collected.
The class presents a C++ symbol, e.g.
bool RefsInHeaders
If set to true, SymbolCollector will collect all refs (from main file and included headers); otherwis...
===– Representation.cpp - ClangDoc Representation --------—*- C++ -*-===//
RelationSlab takeRelations()
void setPreprocessor(std::shared_ptr< Preprocessor > PP) override
const CanonicalIncludes * Includes
If set, this is used to map symbol #include path to a potentially different #include path...
RefKind RefFilter
The symbol ref kinds that will be collected.