[Patch] ErrorOr is not a pointer, don't use a pointer API.
Michael Spencer
bigcheesegs at gmail.com
Wed Jan 8 12:14:33 PST 2014
On Wed, Jan 8, 2014 at 11:45 AM, dblaikie at gmail.com <dblaikie at gmail.com> wrote:
> 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.
Yep, and that's what this was modeled after.
The proposed change ends up either adding get() everywhere or adding
another variable and using get() just once.
>
> 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
>
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
>
More information about the llvm-commits
mailing list