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 "llvm/ADT/ArrayRef.h"
25 namespace serialization {
30 class IndexDataConsumer;
32 struct IndexingOptions {
33 enum class SystemSymbolFilterKind {
39 SystemSymbolFilterKind SystemSymbolFilter
40 = SystemSymbolFilterKind::DeclarationsOnly;
41 bool IndexFunctionLocals = false;
42 bool IndexImplicitInstantiation = false;
45 /// Creates a frontend action that indexes all symbols (macros and AST decls).
46 /// \param WrappedAction another frontend action to wrap over or null.
47 std::unique_ptr<FrontendAction>
48 createIndexingAction(std::shared_ptr<IndexDataConsumer> DataConsumer,
50 std::unique_ptr<FrontendAction> WrappedAction);
52 /// Recursively indexes all decls in the AST.
53 /// Note that this does not index macros.
54 void indexASTUnit(ASTUnit &Unit, IndexDataConsumer &DataConsumer,
55 IndexingOptions Opts);
57 /// Recursively indexes \p Decls.
58 /// Note that this does not index macros.
59 void indexTopLevelDecls(ASTContext &Ctx, ArrayRef<const Decl *> Decls,
60 IndexDataConsumer &DataConsumer, IndexingOptions Opts);
62 /// Creates a PPCallbacks that indexes macros and feeds macros to \p Consumer.
63 /// The caller is responsible for calling `Consumer.setPreprocessor()`.
64 std::unique_ptr<PPCallbacks> indexMacrosCallback(IndexDataConsumer &Consumer,
65 IndexingOptions Opts);
67 /// Recursively indexes all top-level decls in the module.
68 /// FIXME: make this index macros as well.
69 void indexModuleFile(serialization::ModuleFile &Mod, ASTReader &Reader,
70 IndexDataConsumer &DataConsumer, IndexingOptions Opts);