]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/llvm/tools/clang/include/clang/Index/IndexingAction.h
Merge llvm, clang, compiler-rt, libc++, libunwind, lld, lldb and openmp
[FreeBSD/FreeBSD.git] / contrib / llvm / tools / clang / include / clang / Index / IndexingAction.h
1 //===--- IndexingAction.h - Frontend index action ---------------*- C++ -*-===//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9
10 #ifndef LLVM_CLANG_INDEX_INDEXINGACTION_H
11 #define LLVM_CLANG_INDEX_INDEXINGACTION_H
12
13 #include "clang/Basic/LLVM.h"
14 #include "clang/Lex/PPCallbacks.h"
15 #include "clang/Lex/Preprocessor.h"
16 #include "llvm/ADT/ArrayRef.h"
17 #include <memory>
18
19 namespace clang {
20   class ASTContext;
21   class ASTReader;
22   class ASTUnit;
23   class Decl;
24   class FrontendAction;
25
26 namespace serialization {
27   class ModuleFile;
28 }
29
30 namespace index {
31   class IndexDataConsumer;
32
33 struct IndexingOptions {
34   enum class SystemSymbolFilterKind {
35     None,
36     DeclarationsOnly,
37     All,
38   };
39
40   SystemSymbolFilterKind SystemSymbolFilter
41     = SystemSymbolFilterKind::DeclarationsOnly;
42   bool IndexFunctionLocals = false;
43   bool IndexImplicitInstantiation = false;
44   // Whether to index macro definitions in the Preprocesor when preprocessor
45   // callback is not available (e.g. after parsing has finished). Note that
46   // macro references are not available in Proprocessor.
47   bool IndexMacrosInPreprocessor = false;
48 };
49
50 /// Creates a frontend action that indexes all symbols (macros and AST decls).
51 /// \param WrappedAction another frontend action to wrap over or null.
52 std::unique_ptr<FrontendAction>
53 createIndexingAction(std::shared_ptr<IndexDataConsumer> DataConsumer,
54                      IndexingOptions Opts,
55                      std::unique_ptr<FrontendAction> WrappedAction);
56
57 /// Recursively indexes all decls in the AST.
58 void indexASTUnit(ASTUnit &Unit, IndexDataConsumer &DataConsumer,
59                   IndexingOptions Opts);
60
61 /// Recursively indexes \p Decls.
62 void indexTopLevelDecls(ASTContext &Ctx, Preprocessor &PP,
63                         ArrayRef<const Decl *> Decls,
64                         IndexDataConsumer &DataConsumer, IndexingOptions Opts);
65
66 /// Creates a PPCallbacks that indexes macros and feeds macros to \p Consumer.
67 /// The caller is responsible for calling `Consumer.setPreprocessor()`.
68 std::unique_ptr<PPCallbacks> indexMacrosCallback(IndexDataConsumer &Consumer,
69                                                  IndexingOptions Opts);
70
71 /// Recursively indexes all top-level decls in the module.
72 void indexModuleFile(serialization::ModuleFile &Mod, ASTReader &Reader,
73                      IndexDataConsumer &DataConsumer, IndexingOptions Opts);
74
75 } // namespace index
76 } // namespace clang
77
78 #endif