import_cpp.h 1.5 KB

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