mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-10-04 10:11:06 +01:00
Add a flag to build a single ASTContext shared across all compilations (#7567)
Instead of building one Clang `ASTContext` per compilation, the `--share-cpp-ast` flag causes us to build a single `ASTContext` and share it across all contexts. One new abstraction is added: `CppDomain` represents the Carbon-side view of a Clang AST that might be shared across multiple `SemIR::File`s. This object owns the Clang instance and the AST. For now, we have no isolation between the C++ state exposed to different Carbon compilations, and we have no multiplexing of generated LLVM IR from C++ into different Carbon compilations, so the mode is not usable yet. The plan is to keep it behind a flag until it's ready. Assisted-by: Gemini via Antigravity
This commit is contained in:
@@ -11,18 +11,15 @@
|
||||
namespace Carbon::Check {
|
||||
|
||||
CppContext::CppContext(clang::CompilerInstance& instance,
|
||||
std::unique_ptr<clang::Parser> parser)
|
||||
std::shared_ptr<clang::Parser> parser,
|
||||
std::unique_ptr<CppDiagnosticListener> listener)
|
||||
: ast_context_(&instance.getASTContext()),
|
||||
sema_(&instance.getSema()),
|
||||
parser_(std::move(parser)) {}
|
||||
parser_(std::move(parser)),
|
||||
diagnostic_listener_(std::move(listener)) {}
|
||||
|
||||
CppContext::~CppContext() = default;
|
||||
|
||||
auto CppContext::set_diagnostic_listener(
|
||||
std::unique_ptr<CppDiagnosticListener> listener) -> void {
|
||||
diagnostic_listener_ = std::move(listener);
|
||||
}
|
||||
|
||||
auto CppContext::clang_mangle_context() -> clang::MangleContext& {
|
||||
if (!clang_mangle_context_) {
|
||||
clang_mangle_context_.reset(ast_context().createMangleContext());
|
||||
|
||||
Reference in New Issue
Block a user