While there wasn't much use of "return Diag(...) << x" outside Sema (one
each in ARCMigrate, Lex, Parse, and 5 in ClangTidy - which were all just
changed to use named local variables, then stream, then return), in Sema
there were quite a few uses. So this extends Sema::Diag to be a variadic
template allowing the extra parameters to be passed directly rather than
via streaming on the resulting temporary expression.
Details
- Reviewers
rsmith
Diff Detail
Event Timeline
include/clang/Basic/Diagnostic.h | ||
---|---|---|
935–936 | Comment is out of date. | |
include/clang/Sema/Sema.h | ||
1082–1096 | If we only need to support value category preservation for SemaDiagnosticBuilder, can we duplicate this template for the SemaDiagnosticBuilder &&operator<<(SemaDiagnosticBuilder &&Diag, const T &Value) case? | |
lib/Parse/Parser.cpp | ||
163–172 | This one might be more readable as DiagnosticBuilder DB = std::move(Spelling ? ... : ...); Thoughts? |
Addressed Richard's code review feedback
include/clang/Basic/Diagnostic.h | ||
---|---|---|
935–936 | Updated the wording a bit - the scare quotes and somewhat-vague "neuter" seemed unhelpful. Hopefully my rephrasing is an improvement, but I can restore the old or alternate wording if you prefer. | |
include/clang/Sema/Sema.h | ||
1082–1096 | Ah, good idea - that seems to totally work and removes the need for all the mechanical changes. (the handful of non-Sema diag cleanups in a few places (including clang-tidy) remain) | |
lib/Parse/Parser.cpp | ||
163–172 | Tried a few things here (move inside or outside the conditional operator) and none of it works. op<< takes its first arg by const ref (so that it can successfully take a temporary) and then returns it by const ref too - so we'd have to cast away constness before we could move from it. Thoughts? Alternative approaches? |
Comment is out of date.