Path: blob/main/contrib/llvm-project/clang/lib/Index/IndexingContext.h
35233 views
//===- IndexingContext.h - Indexing context data ----------------*- C++ -*-===//1//2// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.3// See https://llvm.org/LICENSE.txt for license information.4// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception5//6//===----------------------------------------------------------------------===//78#ifndef LLVM_CLANG_LIB_INDEX_INDEXINGCONTEXT_H9#define LLVM_CLANG_LIB_INDEX_INDEXINGCONTEXT_H1011#include "clang/Basic/IdentifierTable.h"12#include "clang/Basic/LLVM.h"13#include "clang/Index/IndexSymbol.h"14#include "clang/Index/IndexingAction.h"15#include "clang/Lex/MacroInfo.h"16#include "llvm/ADT/ArrayRef.h"1718namespace clang {19class ASTContext;20class Decl;21class DeclGroupRef;22class ImportDecl;23class TagDecl;24class TypeSourceInfo;25class NamedDecl;26class ObjCMethodDecl;27class DeclContext;28class NestedNameSpecifierLoc;29class Stmt;30class Expr;31class TypeLoc;32class SourceLocation;3334namespace index {35class IndexDataConsumer;3637class IndexingContext {38IndexingOptions IndexOpts;39IndexDataConsumer &DataConsumer;40ASTContext *Ctx = nullptr;4142public:43IndexingContext(IndexingOptions IndexOpts, IndexDataConsumer &DataConsumer)44: IndexOpts(IndexOpts), DataConsumer(DataConsumer) {}4546const IndexingOptions &getIndexOpts() const { return IndexOpts; }47IndexDataConsumer &getDataConsumer() { return DataConsumer; }4849void setASTContext(ASTContext &ctx) { Ctx = &ctx; }5051bool shouldIndex(const Decl *D);5253const LangOptions &getLangOpts() const;5455bool shouldSuppressRefs() const {56return false;57}5859bool shouldIndexFunctionLocalSymbols() const;6061bool shouldIndexImplicitInstantiation() const;6263bool shouldIndexParametersInDeclarations() const;6465bool shouldIndexTemplateParameters() const;6667static bool isTemplateImplicitInstantiation(const Decl *D);6869bool handleDecl(const Decl *D, SymbolRoleSet Roles = SymbolRoleSet(),70ArrayRef<SymbolRelation> Relations = std::nullopt);7172bool handleDecl(const Decl *D, SourceLocation Loc,73SymbolRoleSet Roles = SymbolRoleSet(),74ArrayRef<SymbolRelation> Relations = std::nullopt,75const DeclContext *DC = nullptr);7677bool handleReference(const NamedDecl *D, SourceLocation Loc,78const NamedDecl *Parent, const DeclContext *DC,79SymbolRoleSet Roles = SymbolRoleSet(),80ArrayRef<SymbolRelation> Relations = std::nullopt,81const Expr *RefE = nullptr);8283void handleMacroDefined(const IdentifierInfo &Name, SourceLocation Loc,84const MacroInfo &MI);8586void handleMacroUndefined(const IdentifierInfo &Name, SourceLocation Loc,87const MacroInfo &MI);8889void handleMacroReference(const IdentifierInfo &Name, SourceLocation Loc,90const MacroInfo &MD);9192bool importedModule(const ImportDecl *ImportD);9394bool indexDecl(const Decl *D);9596void indexTagDecl(const TagDecl *D,97ArrayRef<SymbolRelation> Relations = std::nullopt);9899void indexTypeSourceInfo(TypeSourceInfo *TInfo, const NamedDecl *Parent,100const DeclContext *DC = nullptr,101bool isBase = false,102bool isIBType = false);103104void indexTypeLoc(TypeLoc TL, const NamedDecl *Parent,105const DeclContext *DC = nullptr,106bool isBase = false,107bool isIBType = false);108109void indexNestedNameSpecifierLoc(NestedNameSpecifierLoc NNS,110const NamedDecl *Parent,111const DeclContext *DC = nullptr);112113bool indexDeclContext(const DeclContext *DC);114115void indexBody(const Stmt *S, const NamedDecl *Parent,116const DeclContext *DC = nullptr);117118bool indexTopLevelDecl(const Decl *D);119bool indexDeclGroupRef(DeclGroupRef DG);120121private:122bool shouldIgnoreIfImplicit(const Decl *D);123124bool shouldIndexMacroOccurrence(bool IsRef, SourceLocation Loc);125126bool handleDeclOccurrence(const Decl *D, SourceLocation Loc,127bool IsRef, const Decl *Parent,128SymbolRoleSet Roles,129ArrayRef<SymbolRelation> Relations,130const Expr *RefE,131const Decl *RefD,132const DeclContext *ContainerDC);133};134135} // end namespace index136} // end namespace clang137138#endif139140141