[PATCH] D26430: Bitcode: Change the BitcodeReader to use llvm::Error internally.

Peter Collingbourne via llvm-commits llvm-commits at lists.llvm.org
Tue Nov 8 16:44:25 PST 2016


On Tue, Nov 8, 2016 at 4:19 PM, Pete Cooper <peter_cooper at apple.com> wrote:

> Thanks Peter.  This is great!
>
> The only thing that i’m not sure about is these methods:
>
> +std::error_code errorToErrorCodeAndEmitErrors(LLVMContext &Ctx, Error
> Err) {
> +  if (Err) {
> +    std::error_code EC;
> +    handleAllErrors(std::move(Err), [&](ErrorInfoBase &EIB) {
> +      EC = EIB.convertToErrorCode();
> +      Ctx.emitError(EIB.message());
> +    });
> +    return EC;
> +  }
> +  return std::error_code();
>  }
>
> I think you can instead just use expectedToError() and
> errorToErrorCode().  Saying that, you are also logging these to the
> diagnostic handler and/or context, so perhaps this is special enough that
> the code you have is the right way to do it.
>

Right, the invalid bitcode tests would probably fail without this as they
are expecting precise error messages.


> Will leave it up to you as you know the code better.  These methods are
> probably only temporary anyway until the rest of the API is converted to
> Error and Expected.


Yes, in 1 or 2 patches time these functions will be removed from
BitcodeReader.cpp. We will still need one of them for the C API to satisfy
the API contract there though.

Peter


> LGTM.
>
> Cheers,
> Pete
> > On Nov 8, 2016, at 4:10 PM, Peter Collingbourne <peter at pcc.me.uk> wrote:
> >
> > pcc created this revision.
> > pcc added reviewers: lhames, mehdi_amini, pete.
> > pcc added a subscriber: llvm-commits.
> >
> > https://reviews.llvm.org/D26430
> >
> > Files:
> >  llvm/lib/Bitcode/Reader/BitcodeReader.cpp
> >
> > <D26430.77281.patch>
>
>


-- 
-- 
Peter
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20161108/86afbd84/attachment.html>


More information about the llvm-commits mailing list