Clang Project

clang_source_code/include/clang/Index/IndexingAction.h
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/Basic/LLVM.h"
13#include "clang/Lex/PPCallbacks.h"
14#include "clang/Lex/Preprocessor.h"
15#include "llvm/ADT/ArrayRef.h"
16#include <memory>
17
18namespace clang {
19  class ASTContext;
20  class ASTReader;
21  class ASTUnit;
22  class Decl;
23  class FrontendAction;
24
25namespace serialization {
26  class ModuleFile;
27}
28
29namespace index {
30  class IndexDataConsumer;
31
32struct IndexingOptions {
33  enum class SystemSymbolFilterKind {
34    None,
35    DeclarationsOnly,
36    All,
37  };
38
39  SystemSymbolFilterKind SystemSymbolFilter
40    = SystemSymbolFilterKind::DeclarationsOnly;
41  bool IndexFunctionLocals = false;
42  bool IndexImplicitInstantiation = false;
43  // Whether to index macro definitions in the Preprocesor when preprocessor
44  // callback is not available (e.g. after parsing has finished). Note that
45  // macro references are not available in Proprocessor.
46  bool IndexMacrosInPreprocessor = false;
47  // Has no effect if IndexFunctionLocals are false.
48  bool IndexParametersInDeclarations = false;
49  bool IndexTemplateParameters = false;
50};
51
52/// Creates a frontend action that indexes all symbols (macros and AST decls).
53/// \param WrappedAction another frontend action to wrap over or null.
54std::unique_ptr<FrontendAction>
55createIndexingAction(std::shared_ptr<IndexDataConsumerDataConsumer,
56                     IndexingOptions Opts,
57                     std::unique_ptr<FrontendActionWrappedAction);
58
59/// Recursively indexes all decls in the AST.
60void indexASTUnit(ASTUnit &UnitIndexDataConsumer &DataConsumer,
61                  IndexingOptions Opts);
62
63/// Recursively indexes \p Decls.
64void indexTopLevelDecls(ASTContext &CtxPreprocessor &PP,
65                        ArrayRef<const Decl *> Decls,
66                        IndexDataConsumer &DataConsumerIndexingOptions Opts);
67
68/// Creates a PPCallbacks that indexes macros and feeds macros to \p Consumer.
69/// The caller is responsible for calling `Consumer.setPreprocessor()`.
70std::unique_ptr<PPCallbacksindexMacrosCallback(IndexDataConsumer &Consumer,
71                                                 IndexingOptions Opts);
72
73/// Recursively indexes all top-level decls in the module.
74void indexModuleFile(serialization::ModuleFile &ModASTReader &Reader,
75                     IndexDataConsumer &DataConsumerIndexingOptions Opts);
76
77// namespace index
78// namespace clang
79
80#endif
81
clang::index::IndexingOptions::SystemSymbolFilterKind
clang::index::IndexingOptions::SystemSymbolFilter
clang::index::IndexingOptions::IndexFunctionLocals
clang::index::IndexingOptions::IndexImplicitInstantiation
clang::index::IndexingOptions::IndexMacrosInPreprocessor
clang::index::IndexingOptions::IndexParametersInDeclarations
clang::index::IndexingOptions::IndexTemplateParameters