mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-10-04 22:02:52 +01:00
Combine DiagnosticConverter into DiagnosticEmitter (#4878)
At present, we typically define a DiagnosticConverter, then store an instance of it and a DiagnosticEmitter that wraps it. This is relatively minor in general, but I've been trying to create more self-contained DiagnosticEmitter classes (which hold their own DiagnosticConverter, similar to NullDiagnosticEmitter), and there it just gets in the way. Since we don't reuse DiagnosticConverter instances, this combines the definition into DiagnosticEmitter. Mainly this means we don't have a separate object in play, and less to carry around. The most impact is probably to SemIRDiagnosticConverter, which was also the most complex. Now `SemIRLocDiagnosticEmitter`, this gets some different construction flow. Note in the PR I've split the file rename to its own commit, to try to help delta views. However, the most substantial parts of the refactoring are split into #4876, which this depends upon.
This commit is contained in:
@@ -415,12 +415,6 @@ auto TokenizedBuffer::SourcePointerToDiagnosticLoc(const char* loc) const
|
||||
.last_byte_offset = offset};
|
||||
}
|
||||
|
||||
auto TokenizedBuffer::SourceBufferDiagnosticConverter::ConvertLoc(
|
||||
const char* loc, ContextFnT /*context_fn*/) const
|
||||
-> ConvertedDiagnosticLoc {
|
||||
return tokens_->SourcePointerToDiagnosticLoc(loc);
|
||||
}
|
||||
|
||||
auto TokenizedBuffer::TokenToDiagnosticLoc(TokenIndex token) const
|
||||
-> ConvertedDiagnosticLoc {
|
||||
// Map the token location into a position within the source buffer.
|
||||
@@ -435,10 +429,4 @@ auto TokenizedBuffer::TokenToDiagnosticLoc(TokenIndex token) const
|
||||
return converted;
|
||||
}
|
||||
|
||||
auto TokenDiagnosticConverter::ConvertLoc(TokenIndex token,
|
||||
ContextFnT /*context_fn*/) const
|
||||
-> ConvertedDiagnosticLoc {
|
||||
return tokens_->TokenToDiagnosticLoc(token);
|
||||
}
|
||||
|
||||
} // namespace Carbon::Lex
|
||||
|
||||
Reference in New Issue
Block a user