mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-10-05 22:02:55 +01:00
Add support for importing a trivial global C++ function (#5033)
ASTUnit is owned by `CompileSubcommand`, passed through `Unit` to be populated in `ImportCppFiles()` and used via `SemIR::File`. When generating the AST, pass `-x c++` args to compile C++ (temporary until we pass args properly). `Cpp` namespace is marked as a special namespace and has dedicated logic in `LookupNameInExactScope()`. The logic for importing declarations from C++ to Carbon is in `import_cpp.cpp`, but we're likely to want to refactor this signfiicantly over time as it grows (perhaps a dedicated directory?). Part of #4666.
This commit is contained in:
@@ -412,6 +412,7 @@ class CompilationUnit {
|
||||
std::optional<std::function<auto()->const Parse::TreeAndSubtrees&>>
|
||||
tree_and_subtrees_getter_;
|
||||
std::optional<SemIR::File> sem_ir_;
|
||||
std::unique_ptr<clang::ASTUnit> cpp_ast_;
|
||||
std::unique_ptr<llvm::LLVMContext> llvm_context_;
|
||||
std::unique_ptr<llvm::Module> module_;
|
||||
};
|
||||
@@ -509,7 +510,8 @@ auto CompilationUnit::GetCheckUnit(SemIR::CheckIRId check_ir_id)
|
||||
.value_stores = &value_stores_,
|
||||
.timings = timings_ ? &*timings_ : nullptr,
|
||||
.tree_and_subtrees_getter = *tree_and_subtrees_getter_,
|
||||
.sem_ir = &*sem_ir_};
|
||||
.sem_ir = &*sem_ir_,
|
||||
.cpp_ast = &cpp_ast_};
|
||||
}
|
||||
|
||||
auto CompilationUnit::PostCheck() -> void {
|
||||
|
||||
Reference in New Issue
Block a user