mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-09-30 13:05:01 +01:00
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
45 lines
1.4 KiB
C++
45 lines
1.4 KiB
C++
// Part of the Carbon Language project, under the Apache License v2.0 with LLVM
|
|
// Exceptions. See /LICENSE for license information.
|
|
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
|
|
|
#ifndef CARBON_TOOLCHAIN_CHECK_CPP_DIAGNOSTIC_CONSUMER_H_
|
|
#define CARBON_TOOLCHAIN_CHECK_CPP_DIAGNOSTIC_CONSUMER_H_
|
|
|
|
#include <memory>
|
|
|
|
#include "clang/Basic/Diagnostic.h"
|
|
|
|
namespace clang {
|
|
class CompilerInvocation;
|
|
class DiagnosticConsumer;
|
|
} // namespace clang
|
|
|
|
namespace Carbon::Diagnostics {
|
|
class Consumer;
|
|
} // namespace Carbon::Diagnostics
|
|
|
|
namespace Carbon::Check {
|
|
|
|
class Context;
|
|
class CppDiagnosticListener;
|
|
|
|
// Creates a Clang DiagnosticConsumer that adapts Clang diagnostics to Carbon.
|
|
auto MakeDiagnosticConsumer(
|
|
Diagnostics::Consumer& consumer,
|
|
std::shared_ptr<clang::CompilerInvocation> invocation)
|
|
-> std::unique_ptr<clang::DiagnosticConsumer>;
|
|
|
|
// Flushes any pending diagnostics in the given consumer, which must have been
|
|
// created by `MakeDiagnosticConsumer`.
|
|
auto FlushDiagnosticConsumer(clang::DiagnosticConsumer& consumer) -> void;
|
|
|
|
// Creates a diagnostic listener attached to the given Carbon context. The
|
|
// returned listener must not outlive the context.
|
|
auto MakeContextDiagnosticListener(clang::DiagnosticConsumer& consumer,
|
|
Context& context)
|
|
-> std::unique_ptr<CppDiagnosticListener>;
|
|
|
|
} // namespace Carbon::Check
|
|
|
|
#endif // CARBON_TOOLCHAIN_CHECK_CPP_DIAGNOSTIC_CONSUMER_H_
|