1 //===--- IndexingAction.h - Frontend index action ---------------*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 #ifndef LLVM_CLANG_INDEX_INDEXINGACTION_H
11 #define LLVM_CLANG_INDEX_INDEXINGACTION_H
13 #include "clang/Basic/LLVM.h"
14 #include "clang/Lex/PPCallbacks.h"
15 #include "clang/Lex/Preprocessor.h"
16 #include "llvm/ADT/ArrayRef.h"
26 namespace serialization {
31 class IndexDataConsumer;
33 struct IndexingOptions {
34 enum class SystemSymbolFilterKind {
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;
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,
55 std::unique_ptr<FrontendAction> WrappedAction);
57 /// Recursively indexes all decls in the AST.
58 void indexASTUnit(ASTUnit &Unit, IndexDataConsumer &DataConsumer,
59 IndexingOptions Opts);
61 /// Recursively indexes \p Decls.
62 void indexTopLevelDecls(ASTContext &Ctx, Preprocessor &PP,
63 ArrayRef<const Decl *> Decls,
64 IndexDataConsumer &DataConsumer, IndexingOptions Opts);
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);
71 /// Recursively indexes all top-level decls in the module.
72 void indexModuleFile(serialization::ModuleFile &Mod, ASTReader &Reader,
73 IndexDataConsumer &DataConsumer, IndexingOptions Opts);