1 //===- IndexingContext.h - Indexing context data ----------------*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 #ifndef LLVM_CLANG_LIB_INDEX_INDEXINGCONTEXT_H
11 #define LLVM_CLANG_LIB_INDEX_INDEXINGCONTEXT_H
13 #include "clang/Basic/LLVM.h"
14 #include "clang/Index/IndexSymbol.h"
15 #include "clang/Index/IndexingAction.h"
16 #include "llvm/ADT/ArrayRef.h"
28 class NestedNameSpecifierLoc;
35 class IndexDataConsumer;
37 class IndexingContext {
38 IndexingOptions IndexOpts;
39 IndexDataConsumer &DataConsumer;
40 ASTContext *Ctx = nullptr;
43 IndexingContext(IndexingOptions IndexOpts, IndexDataConsumer &DataConsumer)
44 : IndexOpts(IndexOpts), DataConsumer(DataConsumer) {}
46 const IndexingOptions &getIndexOpts() const { return IndexOpts; }
47 IndexDataConsumer &getDataConsumer() { return DataConsumer; }
49 void setASTContext(ASTContext &ctx) { Ctx = &ctx; }
51 bool shouldSuppressRefs() const {
55 bool shouldIndexFunctionLocalSymbols() const;
57 bool shouldIndexImplicitTemplateInsts() const {
61 static bool isFunctionLocalDecl(const Decl *D);
62 static bool isTemplateImplicitInstantiation(const Decl *D);
64 bool handleDecl(const Decl *D, SymbolRoleSet Roles = SymbolRoleSet(),
65 ArrayRef<SymbolRelation> Relations = None);
67 bool handleDecl(const Decl *D, SourceLocation Loc,
68 SymbolRoleSet Roles = SymbolRoleSet(),
69 ArrayRef<SymbolRelation> Relations = None,
70 const DeclContext *DC = nullptr);
72 bool handleReference(const NamedDecl *D, SourceLocation Loc,
73 const NamedDecl *Parent,
74 const DeclContext *DC,
76 ArrayRef<SymbolRelation> Relations = None,
77 const Expr *RefE = nullptr,
78 const Decl *RefD = nullptr);
80 bool importedModule(const ImportDecl *ImportD);
82 bool indexDecl(const Decl *D);
84 void indexTagDecl(const TagDecl *D);
86 void indexTypeSourceInfo(TypeSourceInfo *TInfo, const NamedDecl *Parent,
87 const DeclContext *DC = nullptr,
90 void indexTypeLoc(TypeLoc TL, const NamedDecl *Parent,
91 const DeclContext *DC = nullptr,
94 void indexNestedNameSpecifierLoc(NestedNameSpecifierLoc NNS,
95 const NamedDecl *Parent,
96 const DeclContext *DC = nullptr);
98 bool indexDeclContext(const DeclContext *DC);
100 void indexBody(const Stmt *S, const NamedDecl *Parent,
101 const DeclContext *DC = nullptr);
103 bool indexTopLevelDecl(const Decl *D);
104 bool indexDeclGroupRef(DeclGroupRef DG);
107 bool shouldIgnoreIfImplicit(const Decl *D);
109 bool handleDeclOccurrence(const Decl *D, SourceLocation Loc,
110 bool IsRef, const Decl *Parent,
112 ArrayRef<SymbolRelation> Relations,
115 const DeclContext *ContainerDC);
118 } // end namespace index
119 } // end namespace clang