1e5dd7070Spatrick //===--- IndexingAction.h - Frontend index action ---------------*- C++ -*-===// 2e5dd7070Spatrick // 3e5dd7070Spatrick // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4e5dd7070Spatrick // See https://llvm.org/LICENSE.txt for license information. 5e5dd7070Spatrick // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6e5dd7070Spatrick // 7e5dd7070Spatrick //===----------------------------------------------------------------------===// 8e5dd7070Spatrick 9e5dd7070Spatrick #ifndef LLVM_CLANG_INDEX_INDEXINGACTION_H 10e5dd7070Spatrick #define LLVM_CLANG_INDEX_INDEXINGACTION_H 11e5dd7070Spatrick 12e5dd7070Spatrick #include "clang/AST/ASTConsumer.h" 13e5dd7070Spatrick #include "clang/Basic/LLVM.h" 14e5dd7070Spatrick #include "clang/Index/IndexingOptions.h" 15e5dd7070Spatrick #include "clang/Lex/PPCallbacks.h" 16e5dd7070Spatrick #include "clang/Lex/Preprocessor.h" 17e5dd7070Spatrick #include "llvm/ADT/ArrayRef.h" 18e5dd7070Spatrick #include <memory> 19e5dd7070Spatrick 20e5dd7070Spatrick namespace clang { 21e5dd7070Spatrick class ASTContext; 22e5dd7070Spatrick class ASTConsumer; 23e5dd7070Spatrick class ASTReader; 24e5dd7070Spatrick class ASTUnit; 25e5dd7070Spatrick class Decl; 26e5dd7070Spatrick class FrontendAction; 27e5dd7070Spatrick 28e5dd7070Spatrick namespace serialization { 29e5dd7070Spatrick class ModuleFile; 30e5dd7070Spatrick } 31e5dd7070Spatrick 32e5dd7070Spatrick namespace index { 33e5dd7070Spatrick class IndexDataConsumer; 34e5dd7070Spatrick 35e5dd7070Spatrick /// Creates an ASTConsumer that indexes all symbols (macros and AST decls). 36*ec727ea7Spatrick std::unique_ptr<ASTConsumer> 37*ec727ea7Spatrick createIndexingASTConsumer(std::shared_ptr<IndexDataConsumer> DataConsumer, 38*ec727ea7Spatrick const IndexingOptions &Opts, 39*ec727ea7Spatrick std::shared_ptr<Preprocessor> PP); 40*ec727ea7Spatrick 41e5dd7070Spatrick std::unique_ptr<ASTConsumer> createIndexingASTConsumer( 42e5dd7070Spatrick std::shared_ptr<IndexDataConsumer> DataConsumer, 43e5dd7070Spatrick const IndexingOptions &Opts, std::shared_ptr<Preprocessor> PP, 44*ec727ea7Spatrick // Prefer to set Opts.ShouldTraverseDecl and use the above overload. 45*ec727ea7Spatrick // This version is only needed if used to *track* function body parsing. 46e5dd7070Spatrick std::function<bool(const Decl *)> ShouldSkipFunctionBody); 47e5dd7070Spatrick 48e5dd7070Spatrick /// Creates a frontend action that indexes all symbols (macros and AST decls). 49e5dd7070Spatrick std::unique_ptr<FrontendAction> 50e5dd7070Spatrick createIndexingAction(std::shared_ptr<IndexDataConsumer> DataConsumer, 51e5dd7070Spatrick const IndexingOptions &Opts); 52e5dd7070Spatrick 53e5dd7070Spatrick /// Recursively indexes all decls in the AST. 54e5dd7070Spatrick void indexASTUnit(ASTUnit &Unit, IndexDataConsumer &DataConsumer, 55e5dd7070Spatrick IndexingOptions Opts); 56e5dd7070Spatrick 57e5dd7070Spatrick /// Recursively indexes \p Decls. 58e5dd7070Spatrick void indexTopLevelDecls(ASTContext &Ctx, Preprocessor &PP, 59e5dd7070Spatrick ArrayRef<const Decl *> Decls, 60e5dd7070Spatrick IndexDataConsumer &DataConsumer, IndexingOptions Opts); 61e5dd7070Spatrick 62e5dd7070Spatrick /// Creates a PPCallbacks that indexes macros and feeds macros to \p Consumer. 63e5dd7070Spatrick /// The caller is responsible for calling `Consumer.setPreprocessor()`. 64e5dd7070Spatrick std::unique_ptr<PPCallbacks> indexMacrosCallback(IndexDataConsumer &Consumer, 65e5dd7070Spatrick IndexingOptions Opts); 66e5dd7070Spatrick 67e5dd7070Spatrick /// Recursively indexes all top-level decls in the module. 68e5dd7070Spatrick void indexModuleFile(serialization::ModuleFile &Mod, ASTReader &Reader, 69e5dd7070Spatrick IndexDataConsumer &DataConsumer, IndexingOptions Opts); 70e5dd7070Spatrick 71e5dd7070Spatrick } // namespace index 72e5dd7070Spatrick } // namespace clang 73e5dd7070Spatrick 74e5dd7070Spatrick #endif 75