IndexingAction.h 2.9 KB

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