generate_ast.h 1.2 KB

12345678910111213141516171819202122232425262728293031
  1. // Part of the Carbon Language project, under the Apache License v2.0 with LLVM
  2. // Exceptions. See /LICENSE for license information.
  3. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  4. #ifndef CARBON_TOOLCHAIN_CHECK_CPP_GENERATE_AST_H_
  5. #define CARBON_TOOLCHAIN_CHECK_CPP_GENERATE_AST_H_
  6. #include "llvm/ADT/ArrayRef.h"
  7. #include "llvm/ADT/IntrusiveRefCntPtr.h"
  8. #include "llvm/Support/VirtualFileSystem.h"
  9. #include "toolchain/check/context.h"
  10. namespace Carbon::Check {
  11. // Generates a Clang AST for the given C++ imports and sets it as the context's
  12. // `cpp_context` and the SemIR's `cpp_file`. Returns a bool that represents
  13. // whether compilation was successful.
  14. auto GenerateAst(Context& context,
  15. llvm::ArrayRef<Parse::Tree::PackagingNames> imports,
  16. llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem> fs,
  17. llvm::LLVMContext* llvm_context,
  18. std::shared_ptr<clang::CompilerInvocation> base_invocation)
  19. -> bool;
  20. // Finishes AST generation for the given checking context. Performs end of file
  21. // steps such as template instantiation and warning on unused declarations.
  22. auto FinishAst(Context& context) -> void;
  23. } // namespace Carbon::Check
  24. #endif // CARBON_TOOLCHAIN_CHECK_CPP_GENERATE_AST_H_