clang  14.0.0git
IndexDataConsumer.h
Go to the documentation of this file.
1 //===--- IndexDataConsumer.h - Abstract index data consumer -----*- C++ -*-===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 
9 #ifndef LLVM_CLANG_INDEX_INDEXDATACONSUMER_H
10 #define LLVM_CLANG_INDEX_INDEXDATACONSUMER_H
11 
13 #include "clang/Lex/Preprocessor.h"
14 
15 namespace clang {
16  class ASTContext;
17  class DeclContext;
18  class Expr;
19  class FileID;
20  class IdentifierInfo;
21  class ImportDecl;
22  class MacroInfo;
23 
24 namespace index {
25 
27 public:
28  struct ASTNodeInfo {
29  const Expr *OrigE;
30  const Decl *OrigD;
31  const Decl *Parent;
33  };
34 
35  virtual ~IndexDataConsumer() = default;
36 
37  virtual void initialize(ASTContext &Ctx) {}
38 
39  virtual void setPreprocessor(std::shared_ptr<Preprocessor> PP) {}
40 
41  /// \returns true to continue indexing, or false to abort.
42  virtual bool handleDeclOccurrence(const Decl *D, SymbolRoleSet Roles,
43  ArrayRef<SymbolRelation> Relations,
44  SourceLocation Loc, ASTNodeInfo ASTNode) {
45  return true;
46  }
47 
48  /// \returns true to continue indexing, or false to abort.
49  virtual bool handleMacroOccurrence(const IdentifierInfo *Name,
50  const MacroInfo *MI, SymbolRoleSet Roles,
51  SourceLocation Loc) {
52  return true;
53  }
54 
55  /// \returns true to continue indexing, or false to abort.
56  ///
57  /// This will be called for each module reference in an import decl.
58  /// For "@import MyMod.SubMod", there will be a call for 'MyMod' with the
59  /// 'reference' role, and a call for 'SubMod' with the 'declaration' role.
60  virtual bool handleModuleOccurrence(const ImportDecl *ImportD,
61  const Module *Mod, SymbolRoleSet Roles,
62  SourceLocation Loc) {
63  return true;
64  }
65 
66  virtual void finish() {}
67 };
68 
69 } // namespace index
70 } // namespace clang
71 
72 #endif
clang::index::IndexDataConsumer::ASTNodeInfo
Definition: IndexDataConsumer.h:28
clang::index::IndexDataConsumer::ASTNodeInfo::Parent
const Decl * Parent
Definition: IndexDataConsumer.h:31
clang::DeclContext
DeclContext - This is used only as base class of specific decl types that can act as declaration cont...
Definition: DeclBase.h:1347
clang::SourceLocation
Encodes a location in the source.
Definition: SourceLocation.h:88
clang::index::IndexDataConsumer::~IndexDataConsumer
virtual ~IndexDataConsumer()=default
clang::index::IndexDataConsumer::setPreprocessor
virtual void setPreprocessor(std::shared_ptr< Preprocessor > PP)
Definition: IndexDataConsumer.h:39
clang::index::IndexDataConsumer
Definition: IndexDataConsumer.h:26
clang::MacroInfo
Encapsulates the data about a macro definition (e.g.
Definition: MacroInfo.h:39
Preprocessor.h
clang::Module
Describes a module or submodule.
Definition: Module.h:96
clang::ImportDecl
Describes a module import declaration, which makes the contents of the named module visible in the cu...
Definition: Decl.h:4447
clang::index::IndexDataConsumer::handleModuleOccurrence
virtual bool handleModuleOccurrence(const ImportDecl *ImportD, const Module *Mod, SymbolRoleSet Roles, SourceLocation Loc)
Definition: IndexDataConsumer.h:60
clang::ASTContext
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
Definition: ASTContext.h:211
clang::index::IndexDataConsumer::ASTNodeInfo::ContainerDC
const DeclContext * ContainerDC
Definition: IndexDataConsumer.h:32
clang::index::IndexDataConsumer::initialize
virtual void initialize(ASTContext &Ctx)
Definition: IndexDataConsumer.h:37
clang::index::IndexDataConsumer::handleMacroOccurrence
virtual bool handleMacroOccurrence(const IdentifierInfo *Name, const MacroInfo *MI, SymbolRoleSet Roles, SourceLocation Loc)
Definition: IndexDataConsumer.h:49
clang::index::IndexDataConsumer::ASTNodeInfo::OrigE
const Expr * OrigE
Definition: IndexDataConsumer.h:29
llvm::ArrayRef
Definition: LLVM.h:34
clang::Decl
Decl - This represents one declaration (or definition), e.g.
Definition: DeclBase.h:89
IndexSymbol.h
clang::IdentifierInfo
One of these records is kept for each identifier that is lexed.
Definition: IdentifierTable.h:67
clang::index::IndexDataConsumer::handleDeclOccurrence
virtual bool handleDeclOccurrence(const Decl *D, SymbolRoleSet Roles, ArrayRef< SymbolRelation > Relations, SourceLocation Loc, ASTNodeInfo ASTNode)
Definition: IndexDataConsumer.h:42
clang
Definition: CalledOnceCheck.h:17
unsigned
clang::Expr
This represents one expression.
Definition: Expr.h:109
clang::index::IndexDataConsumer::finish
virtual void finish()
Definition: IndexDataConsumer.h:66
clang::index::IndexDataConsumer::ASTNodeInfo::OrigD
const Decl * OrigD
Definition: IndexDataConsumer.h:30