mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-10-01 16:45:52 +01:00
Add some encapsulation to CppDomain (#7579)
Start tracking the domain within `CppContext`s instead of having them duplicate its fields. This allows us to remove the shared ownership of the clang parser. --------- Co-authored-by: Christopher Di Bella <cjdb.ns@gmail.com>
This commit is contained in:
co-authored by
Christopher Di Bella
parent
9b8a2124b9
commit
9bcee64b32
@@ -6,20 +6,24 @@
|
||||
|
||||
#include "clang/AST/Mangle.h"
|
||||
#include "clang/Frontend/CompilerInstance.h"
|
||||
#include "clang/Parse/Parser.h"
|
||||
#include "toolchain/check/cpp/domain.h"
|
||||
|
||||
namespace Carbon::Check {
|
||||
|
||||
CppContext::CppContext(clang::CompilerInstance& instance,
|
||||
std::shared_ptr<clang::Parser> parser,
|
||||
CppContext::CppContext(CppDomain& domain,
|
||||
std::unique_ptr<CppDiagnosticListener> listener)
|
||||
: ast_context_(&instance.getASTContext()),
|
||||
sema_(&instance.getSema()),
|
||||
parser_(std::move(parser)),
|
||||
diagnostic_listener_(std::move(listener)) {}
|
||||
: domain_(&domain), diagnostic_listener_(std::move(listener)) {}
|
||||
|
||||
CppContext::~CppContext() = default;
|
||||
|
||||
auto CppContext::ast_context() -> clang::ASTContext& {
|
||||
return domain_->clang_instance().getASTContext();
|
||||
}
|
||||
|
||||
auto CppContext::sema() -> clang::Sema& {
|
||||
return domain_->clang_instance().getSema();
|
||||
}
|
||||
|
||||
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