[Patch] ErrorOr is not a pointer, don't use a pointer API.

dblaikie at gmail.com dblaikie at gmail.com
Wed Jan 8 11:45:16 PST 2014


FWIW there are other non-pointers that use pointer-like semantics, such as
boost::optional. So there's precedence in some pretty mainstream APIs for
this design.

But I don't work with code using this type very much, so it's best left up
to you/them to decide what kind of API they're most comfortable with.

Perhaps a thread link for the "as was observed before" reference would also
be useful.
On Wed Jan 08 2014 at 10:47:42 AM, Rafael EspĂ­ndola <
rafael.espindola at gmail.com> wrote:

> With the mangler out of the way I got back to coding a lib/Object
> interface for IR files. The first part being modernizing the IR api to
> use error_code and ErrorOr.
>
> Doing so I found one more issue with ErrorOr. It has a pointer like
> API, but it is not a pointer. It stores a value of type T, not a
> pointer to T. Modifying the stored object causes nothing else to be
> mutated and, as was observed before, an ErrorOr<smart_pointer<T> > is
> a fairly confusing thing.
>
> The attached patch are
>
> * add-new-api.patch: Just adds the get and getError methods.
> * convert-llvm.patch: Converts llvm to use the new methods.
> * convert-lld.patch: Converts lld to use the new methods.
> * remove-old-api.patch: Remove the pointer API and simplify the bool
> operator.
>
> Cheers,
> Rafael
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20140108/141af4d6/attachment.html>


More information about the llvm-commits mailing list