[PATCH] D84362: [NFC] Add missing functions to PartialDiagnostic

Artem Belevich via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Sep 15 11:32:03 PDT 2020


tra added a comment.

In D84362#2274790 <https://reviews.llvm.org/D84362#2274790>, @yaxunl wrote:

> There are use patterns expecting `PartialDiagnosticInst << X << Y` to continue to be a `PartialDiagnostic&`, e.g.
>
>   PartialDiagnosticAt PDAt(SourceLoc, PartialDiagnosticInst << X << Y);
>
> However if we derive PartialDiagnostic and DiagnosticBuilder from a base class DiagnosticBuilderBase which implements the `<<` operators, `PartialDiagnosticInst << X << Y` will become a `DiagnosticBuilderBase&`, then we can no longer write the above code.
>
> That's one reason I use templates to implement `<<` operators.
>
> Do we want to sacrifice this convenience?

I don't think we have to. 
AFAICT, virtually all such patterns (and there are only 20-ish of them in total) are used with `EmitFormatDiagnostic(S.PDiag())` which could be adapted to accept `DiagnosticBuilderBase` and `Sema::PDiag()` changed to return `PartialDiagnosticBuilder` with no loss of convenience.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D84362/new/

https://reviews.llvm.org/D84362



More information about the cfe-commits mailing list