clang 10.0.0git

IndexingAction.h
Go to the documentation of this file.
1 //===--- IndexingAction.h - Frontend index action ---------------*- 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_INDEXINGACTION_H
10 #define LLVM_CLANG_INDEX_INDEXINGACTION_H
11
12 #include "clang/AST/ASTConsumer.h"
13 #include "clang/Basic/LLVM.h"
14 #include "clang/Index/IndexingOptions.h"
15 #include "clang/Lex/PPCallbacks.h"
16 #include "clang/Lex/Preprocessor.h"
17 #include "llvm/ADT/ArrayRef.h"
18 #include <memory>
19
20 namespace clang {
21 class ASTContext;
22 class ASTConsumer;
23 class ASTReader;
24 class ASTUnit;
25 class Decl;
26 class FrontendAction;
27
28 namespace serialization {
29 class ModuleFile;
30 }
31
32 namespace index {
33 class IndexDataConsumer;
34
35 /// Creates an ASTConsumer that indexes all symbols (macros and AST decls).
36 std::unique_ptr<ASTConsumer> createIndexingASTConsumer(
37 std::shared_ptr<IndexDataConsumer> DataConsumer,
38 const IndexingOptions &Opts, std::shared_ptr<Preprocessor> PP,
39 std::function<bool(const Decl *)> ShouldSkipFunctionBody);
40
41 inline std::unique_ptr<ASTConsumer> createIndexingASTConsumer(
42 std::shared_ptr<IndexDataConsumer> DataConsumer,
43 const IndexingOptions &Opts, std::shared_ptr<Preprocessor> PP) {
44 return createIndexingASTConsumer(
45 std::move(DataConsumer), Opts, std::move(PP),
46 /*ShouldSkipFunctionBody=*/[](const Decl *) { return false; });
47 }
48
49 /// Creates a frontend action that indexes all symbols (macros and AST decls).
50 std::unique_ptr<FrontendAction>
51 createIndexingAction(std::shared_ptr<IndexDataConsumer> DataConsumer,
52 const IndexingOptions &Opts);
53
54 /// Recursively indexes all decls in the AST.
55 void indexASTUnit(ASTUnit &Unit, IndexDataConsumer &DataConsumer,
56 IndexingOptions Opts);
57
58 /// Recursively indexes \p Decls.
59 void indexTopLevelDecls(ASTContext &Ctx, Preprocessor &PP,
60 ArrayRef<const Decl *> Decls,
61 IndexDataConsumer &DataConsumer, IndexingOptions Opts);
62
63 /// Creates a PPCallbacks that indexes macros and feeds macros to \p Consumer.
64 /// The caller is responsible for calling `Consumer.setPreprocessor()`.
65 std::unique_ptr<PPCallbacks> indexMacrosCallback(IndexDataConsumer &Consumer,
66 IndexingOptions Opts);
67
68 /// Recursively indexes all top-level decls in the module.
69 void indexModuleFile(serialization::ModuleFile &Mod, ASTReader &Reader,
70 IndexDataConsumer &DataConsumer, IndexingOptions Opts);
71
72 } // namespace index
73 } // namespace clang
74
75 #endif
clang::Decl
Decl - This represents one declaration (or definition), e.g.
Definition: DeclBase.h:88
clang::index::IndexingOptions
Definition: IndexingOptions.h:19
clang::CodeGen::AlignmentSource::Decl
The l-value was an access to a declared entity or something equivalently strong, like the address of ...
clang::ASTContext
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
Definition: ASTContext.h:168
clang::ASTUnit
Utility class for loading a ASTContext from an AST file.
Definition: ASTUnit.h:89
clang::index::indexASTUnit
void indexASTUnit(ASTUnit &Unit, IndexDataConsumer &DataConsumer, IndexingOptions Opts)
Recursively indexes all decls in the AST.
Definition: IndexingAction.cpp:160
IndexingOptions.h
clang::index::indexModuleFile
void indexModuleFile(serialization::ModuleFile &Mod, ASTReader &Reader, IndexDataConsumer &DataConsumer, IndexingOptions Opts)
Recursively indexes all top-level decls in the module.
Definition: IndexingAction.cpp:196
LLVM.h
Forward-declares and imports various common LLVM datatypes that clang wants to use unqualified...
clang::index::IndexDataConsumer
Definition: IndexDataConsumer.h:26
llvm::ArrayRef
Definition: LLVM.h:31
clang::index::createIndexingASTConsumer
std::unique_ptr< ASTConsumer > createIndexingASTConsumer(std::shared_ptr< IndexDataConsumer > DataConsumer, const IndexingOptions &Opts, std::shared_ptr< Preprocessor > PP)
Definition: IndexingAction.h:41
Preprocessor.h
Defines the clang::Preprocessor interface.
clang::serialization::ModuleFile
Information about a module that has been loaded by the ASTReader.
Definition: ModuleFile.h:107
ASTConsumer.h
clang::index::createIndexingAction
std::unique_ptr< FrontendAction > createIndexingAction(std::shared_ptr< IndexDataConsumer > DataConsumer, const IndexingOptions &Opts)
Creates a frontend action that indexes all symbols (macros and AST decls).
Definition: IndexingAction.cpp:135
clang
Dataflow Directional Tag Classes.
Definition: CFGReachabilityAnalysis.h:21
clang::ASTReader
Reads an AST files chain containing the contents of a translation unit.
Definition: ASTReader.h:340
clang::index::indexTopLevelDecls
void indexTopLevelDecls(ASTContext &Ctx, Preprocessor &PP, ArrayRef< const Decl *> Decls, IndexDataConsumer &DataConsumer, IndexingOptions Opts)
Recursively indexes Decls.
Definition: IndexingAction.cpp:173
PPCallbacks.h
Defines the PPCallbacks interface.
clang::index::indexMacrosCallback
std::unique_ptr< PPCallbacks > indexMacrosCallback(IndexDataConsumer &Consumer, IndexingOptions Opts)
Creates a PPCallbacks that indexes macros and feeds macros to Consumer.
Definition: IndexingAction.cpp:191
clang::Preprocessor
Engages in a tight little dance with the lexer to efficiently preprocess tokens.
Definition: Preprocessor.h:128