[PATCH] D49013: [Support] Allow formatv() to consume llvm::Error by-value without crashing.

Zachary Turner via llvm-commits llvm-commits at lists.llvm.org
Tue Jul 10 08:51:06 PDT 2018


In the samples you gave in the original code review, it was always just
`formatv(“Error: {0}”, E);`

Is it always this simple and consistent?  Or do you frequently construct
complex messages with many other parameters in the same format string?  If
it’s always (or even often) that simple, maybe you just need a function
like void `logError(Error E)`

On Tue, Jul 10, 2018 at 7:03 AM Sam McCall via Phabricator <
reviews at reviews.llvm.org> wrote:

> sammccall added a comment.
>
> An alternate approach in https://reviews.llvm.org/D49129: give `Error` an
> overloaded `operator<<` that has the same consume semantics at `toString`
> when passed rvalues.
>
> This makes `formatv`, `to_string`, `toString` all do basically the same
> thing (which is the only sensible thing to do when passed an rvalue).
>
> It does require minor changes to `formatv` and `to_string` to make them
> propagate the right kind of reference, but these seem reasonable.
>
> Overall I think I like that approach better than this one (more
> consistent, Error handling lives in Error.h). WDYT?
>
>
> Repository:
>   rL LLVM
>
> https://reviews.llvm.org/D49013
>
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180710/d74c9355/attachment.html>


More information about the llvm-commits mailing list