import_cpp.h 1.3 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_IMPORT_CPP_H_
  5. #define CARBON_TOOLCHAIN_CHECK_IMPORT_CPP_H_
  6. #include "llvm/ADT/StringRef.h"
  7. #include "toolchain/check/context.h"
  8. #include "toolchain/check/diagnostic_helpers.h"
  9. namespace Carbon::Check {
  10. // Generates a C++ header that includes the imported cpp files, parses it,
  11. // generates the AST from it and links `SemIR::File` to it. Report C++ errors
  12. // and warnings. If successful, adds a `Cpp` namespace and returns the AST.
  13. auto ImportCppFiles(Context& context,
  14. llvm::ArrayRef<Parse::Tree::PackagingNames> imports,
  15. llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem> fs,
  16. llvm::StringRef clang_path, llvm::StringRef target)
  17. -> std::unique_ptr<clang::ASTUnit>;
  18. // Looks up the given name in the Clang AST generated when importing C++ code.
  19. // If successful, generates the instruction and returns the new `InstId`.
  20. auto ImportNameFromCpp(Context& context, SemIR::LocId loc_id,
  21. SemIR::NameScopeId scope_id, SemIR::NameId name_id)
  22. -> SemIR::InstId;
  23. } // namespace Carbon::Check
  24. #endif // CARBON_TOOLCHAIN_CHECK_IMPORT_CPP_H_