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/IdentifierTable.h"
14 #include "clang/Basic/LLVM.h"
15 #include "clang/Index/IndexSymbol.h"
16 #include "clang/Index/IndexingAction.h"
17 #include "clang/Lex/MacroInfo.h"
18 #include "llvm/ADT/ArrayRef.h"
30 class NestedNameSpecifierLoc;
37 class IndexDataConsumer;
39 class IndexingContext {
40 IndexingOptions IndexOpts;
41 IndexDataConsumer &DataConsumer;
42 ASTContext *Ctx = nullptr;
45 IndexingContext(IndexingOptions IndexOpts, IndexDataConsumer &DataConsumer)
46 : IndexOpts(IndexOpts), DataConsumer(DataConsumer) {}
48 const IndexingOptions &getIndexOpts() const { return IndexOpts; }
49 IndexDataConsumer &getDataConsumer() { return DataConsumer; }
51 void setASTContext(ASTContext &ctx) { Ctx = &ctx; }
53 bool shouldIndex(const Decl *D);
55 const LangOptions &getLangOpts() const;
57 bool shouldSuppressRefs() const {
61 bool shouldIndexFunctionLocalSymbols() const;
63 bool shouldIndexImplicitInstantiation() 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 void handleMacroDefined(const IdentifierInfo &Name, SourceLocation Loc,
86 void handleMacroUndefined(const IdentifierInfo &Name, SourceLocation Loc,
89 void handleMacroReference(const IdentifierInfo &Name, SourceLocation Loc,
92 bool importedModule(const ImportDecl *ImportD);
94 bool indexDecl(const Decl *D);
96 void indexTagDecl(const TagDecl *D,
97 ArrayRef<SymbolRelation> Relations = None);
99 void indexTypeSourceInfo(TypeSourceInfo *TInfo, const NamedDecl *Parent,
100 const DeclContext *DC = nullptr,
102 bool isIBType = false);
104 void indexTypeLoc(TypeLoc TL, const NamedDecl *Parent,
105 const DeclContext *DC = nullptr,
107 bool isIBType = false);
109 void indexNestedNameSpecifierLoc(NestedNameSpecifierLoc NNS,
110 const NamedDecl *Parent,
111 const DeclContext *DC = nullptr);
113 bool indexDeclContext(const DeclContext *DC);
115 void indexBody(const Stmt *S, const NamedDecl *Parent,
116 const DeclContext *DC = nullptr);
118 bool indexTopLevelDecl(const Decl *D);
119 bool indexDeclGroupRef(DeclGroupRef DG);
122 bool shouldIgnoreIfImplicit(const Decl *D);
124 bool handleDeclOccurrence(const Decl *D, SourceLocation Loc,
125 bool IsRef, const Decl *Parent,
127 ArrayRef<SymbolRelation> Relations,
130 const DeclContext *ContainerDC);
133 } // end namespace index
134 } // end namespace clang