Split up C++ diagnostic emitter and factor it out. (#7558)

Split the diagnostic emitter into a separate emitter (regietered with
Clang) and listener (registered with the emitter). The purpose of this
split is to make the Clang emitter not depend on the `Check::Context`,
so that we can use it, and hence the same Clang instance, with multiple
`Check::Context`s. A fallback listener is registered to collect and emit
any diagnostics produced while we don't have a `Check::Context`
registered with the emitter.

Assisted-by: Gemini via Antigravity
This commit is contained in:
Richard Smith
2026-07-24 20:14:50 +00:00
committed by GitHub
parent 48a03e6a1c
commit 39916ad2ca
11 changed files with 443 additions and 219 deletions
+7
View File
@@ -88,4 +88,11 @@ auto GetCppLocation(Context& context, SemIR::LocId loc_id)
return start_loc.getLocWithOffset(offset);
}
auto AddImportIRInst(SemIR::File& file, clang::SourceLocation clang_source_loc)
-> SemIR::ImportIRInstId {
SemIR::ClangSourceLocId clang_source_loc_id =
file.clang_source_locs().Add(clang_source_loc);
return file.import_ir_insts().Add(SemIR::ImportIRInst(clang_source_loc_id));
}
} // namespace Carbon::Check