[PATCH] D84362: [NFC] Refactor DiagnosticBuilder and PartialDiagnostic
John McCall via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Thu Oct 15 10:47:17 PDT 2020
rjmccall added inline comments.
================
Comment at: clang/include/clang/Basic/PartialDiagnostic.h:66
+ return *this;
+ }
+
----------------
yaxunl wrote:
> rjmccall wrote:
> > Why are these template operators necessary? The LHS of the `<<` should convert to a base reference type just fine.
> There are lots of usage patterns expecting the derived class after streaming, e.g.
>
> ```
> void foo(PartialDiagnostic& PD);
> foo(PD << X << Y);
> ```
I see. You could also just do this in the base operators by just making them templates, e.g.
```
template <class Diagnostic>
std::enable_if_t<std::is_base_of_v<StreamingDiagnostic, Diagnostic>, const Diagnostic &>
operator<<(const Diagnostic &D, ...) {
}
```
That way you'd never have these forwarding problems — but it would be more boilerplate for each operator, so maybe it's a wash.
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D84362/new/
https://reviews.llvm.org/D84362
More information about the cfe-commits
mailing list