8 #ifndef LLVM_CLANG_TOOLS_EXTRA_CLANGD_INDEX_SYMBOL_COLLECTOR_H 9 #define LLVM_CLANG_TOOLS_EXTRA_CLANGD_INDEX_SYMBOL_COLLECTOR_H 14 #include "clang/AST/ASTContext.h" 15 #include "clang/AST/Decl.h" 16 #include "clang/Basic/SourceLocation.h" 17 #include "clang/Basic/SourceManager.h" 18 #include "clang/Index/IndexDataConsumer.h" 19 #include "clang/Index/IndexSymbol.h" 20 #include "clang/Sema/CodeCompleteConsumer.h" 21 #include "llvm/ADT/DenseMap.h" 22 #include "llvm/Support/Regex.h" 86 std::function<bool(const SourceManager &, FileID)>
FileFilter =
nullptr;
93 const Options &Opts,
bool IsMainFileSymbol);
98 this->PP = std::move(PP);
103 ArrayRef<index::SymbolRelation> Relations,
105 index::IndexDataConsumer::ASTNodeInfo ASTNode)
override;
108 index::SymbolRoleSet Roles,
109 SourceLocation Loc)
override;
124 bool IsMainFileSymbol);
125 void addDefinition(
const NamedDecl &,
const Symbol &DeclSymbol);
126 void processRelations(
const NamedDecl &ND,
const SymbolID &ID,
127 ArrayRef<index::SymbolRelation> Relations);
129 llvm::Optional<std::string> getIncludeHeader(llvm::StringRef
QName, FileID);
130 bool isSelfContainedHeader(FileID);
132 static bool isDontIncludeMeHeader(llvm::StringRef);
138 llvm::DenseMap<SymbolID, FileID> IncludeFiles;
139 void setIncludeLocation(
const Symbol &S, SourceLocation);
141 llvm::DenseSet<const IdentifierInfo *> IndexedMacros;
150 std::shared_ptr<Preprocessor> PP;
151 std::shared_ptr<GlobalCodeCompletionAllocator> CompletionAllocator;
152 std::unique_ptr<CodeCompletionTUInfo> CompletionTUInfo;
154 using DeclRef = std::pair<SourceLocation, index::SymbolRoleSet>;
156 llvm::DenseSet<const NamedDecl *> ReferencedDecls;
157 llvm::DenseSet<const IdentifierInfo *> ReferencedMacros;
158 llvm::DenseMap<const NamedDecl *, std::vector<DeclRef>> DeclRefs;
164 llvm::DenseMap<const Decl *, const Decl *> CanonicalDecls;
166 llvm::DenseMap<FileID, bool> FilesToIndexCache;
167 llvm::DenseMap<FileID, bool> HeaderIsSelfContainedCache;
SourceLocation Loc
'#' location in the include directive
bool handleMacroOccurence(const IdentifierInfo *Name, const MacroInfo *MI, index::SymbolRoleSet Roles, SourceLocation Loc) override
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 handleDeclOccurence(const Decl *D, index::SymbolRoleSet Roles, ArrayRef< index::SymbolRelation > Relations, SourceLocation Loc, index::IndexDataConsumer::ASTNodeInfo ASTNode) override
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)
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.
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.