clang  10.0.0svn
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"
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) {
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.
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.
70  IndexDataConsumer &DataConsumer, IndexingOptions Opts);
71 
72 } // namespace index
73 } // namespace clang
74 
75 #endif
Decl - This represents one declaration (or definition), e.g.
Definition: DeclBase.h:88
The l-value was an access to a declared entity or something equivalently strong, like the address of ...
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
Definition: ASTContext.h:160
Utility class for loading a ASTContext from an AST file.
Definition: ASTUnit.h:89
void indexASTUnit(ASTUnit &Unit, IndexDataConsumer &DataConsumer, IndexingOptions Opts)
Recursively indexes all decls in the AST.
void indexModuleFile(serialization::ModuleFile &Mod, ASTReader &Reader, IndexDataConsumer &DataConsumer, IndexingOptions Opts)
Recursively indexes all top-level decls in the module.
Forward-declares and imports various common LLVM datatypes that clang wants to use unqualified...
std::unique_ptr< ASTConsumer > createIndexingASTConsumer(std::shared_ptr< IndexDataConsumer > DataConsumer, const IndexingOptions &Opts, std::shared_ptr< Preprocessor > PP)
Defines the clang::Preprocessor interface.
Information about a module that has been loaded by the ASTReader.
Definition: Module.h:107
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).
Dataflow Directional Tag Classes.
Reads an AST files chain containing the contents of a translation unit.
Definition: ASTReader.h:354
void indexTopLevelDecls(ASTContext &Ctx, Preprocessor &PP, ArrayRef< const Decl *> Decls, IndexDataConsumer &DataConsumer, IndexingOptions Opts)
Recursively indexes Decls.
Defines the PPCallbacks interface.
std::unique_ptr< PPCallbacks > indexMacrosCallback(IndexDataConsumer &Consumer, IndexingOptions Opts)
Creates a PPCallbacks that indexes macros and feeds macros to Consumer.
Engages in a tight little dance with the lexer to efficiently preprocess tokens.
Definition: Preprocessor.h:125