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 shouldIndex(const Decl *D);
53 const LangOptions &getLangOpts() const;
55 bool shouldSuppressRefs() const {
59 bool shouldIndexFunctionLocalSymbols() const;
61 bool shouldIndexImplicitTemplateInsts() const {
65 static bool isTemplateImplicitInstantiation(const Decl *D);
67 bool handleDecl(const Decl *D, SymbolRoleSet Roles = SymbolRoleSet(),
68 ArrayRef<SymbolRelation> Relations = None);
70 bool handleDecl(const Decl *D, SourceLocation Loc,
71 SymbolRoleSet Roles = SymbolRoleSet(),
72 ArrayRef<SymbolRelation> Relations = None,
73 const DeclContext *DC = nullptr);
75 bool handleReference(const NamedDecl *D, SourceLocation Loc,
76 const NamedDecl *Parent,
77 const DeclContext *DC,
78 SymbolRoleSet Roles = SymbolRoleSet(),
79 ArrayRef<SymbolRelation> Relations = None,
80 const Expr *RefE = nullptr,
81 const Decl *RefD = nullptr);
83 bool importedModule(const ImportDecl *ImportD);
85 bool indexDecl(const Decl *D);
87 void indexTagDecl(const TagDecl *D,
88 ArrayRef<SymbolRelation> Relations = None);
90 void indexTypeSourceInfo(TypeSourceInfo *TInfo, const NamedDecl *Parent,
91 const DeclContext *DC = nullptr,
93 bool isIBType = false);
95 void indexTypeLoc(TypeLoc TL, const NamedDecl *Parent,
96 const DeclContext *DC = nullptr,
98 bool isIBType = false);
100 void indexNestedNameSpecifierLoc(NestedNameSpecifierLoc NNS,
101 const NamedDecl *Parent,
102 const DeclContext *DC = nullptr);
104 bool indexDeclContext(const DeclContext *DC);
106 void indexBody(const Stmt *S, const NamedDecl *Parent,
107 const DeclContext *DC = nullptr);
109 bool indexTopLevelDecl(const Decl *D);
110 bool indexDeclGroupRef(DeclGroupRef DG);
113 bool shouldIgnoreIfImplicit(const Decl *D);
115 bool handleDeclOccurrence(const Decl *D, SourceLocation Loc,
116 bool IsRef, const Decl *Parent,
118 ArrayRef<SymbolRelation> Relations,
121 const DeclContext *ContainerDC);
124 } // end namespace index
125 } // end namespace clang