import_cpp.h 1.3 KB

123456789101112131415161718192021222324252627282930
  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, llvm::StringRef importing_file_path,
  14. llvm::ArrayRef<Parse::Tree::PackagingNames> imports,
  15. llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem> fs,
  16. llvm::StringRef target) -> std::unique_ptr<clang::ASTUnit>;
  17. // Looks up the given name in the Clang AST generated when importing C++ code.
  18. // If successful, generates the instruction and returns the new `InstId`.
  19. auto ImportNameFromCpp(Context& context, SemIR::LocId loc_id,
  20. SemIR::NameScopeId scope_id, SemIR::NameId name_id)
  21. -> SemIR::InstId;
  22. } // namespace Carbon::Check
  23. #endif // CARBON_TOOLCHAIN_CHECK_IMPORT_CPP_H_