[LLVMdev] Fwd: Bitcode abbreviations for something that's not a record

Rafael EspĂ­ndola rafael.espindola at gmail.com
Fri Jan 23 15:47:55 PST 2015


On 23 January 2015 at 17:43, Filipe Cabecinhas <filcab at gmail.com> wrote:

> It's strictly better than leaving an assert/unreachable, since it's user
> input, not bad API usage.
> I'm not very familiar with BitcodeReader's API, so in this case I would
> prefer to fix it right away, and later we could figure out how to make the
> API recoverable.
>

I agree with both of you :-)
It is an improvement, but not ideal. If the ideal is not obvious we can do
it in two steps and get the test passing for now.


> Although:
> In this case, we can return something like -1, for now, making some
> callers skip over the thing or returning an error. The problem is: this is
> supposed to be an abbrev record. If you can't read one of its parts, what
> do you do?
> Otherwise, I can make readRecord return an std::error_code, since most of
> its callers do the same, and propagate the error, since all of its callers
> (AFAICT) return an error_code too.
>
>
In the case of bit code, the error handling strategy is somewhat clear. I
think what would be needed is:

* Pass a DiagnosticHandlerFunction down to the constructor. The
BitcodeReader can then use the one from the BitstreamReader.
* Have functions that can fail diagnose the failure and return an
error_code or ErrorOr<something>

It shouldn't be hard, but is non trivial, so I would be OK with
report_fatal_error first.

Cheers,
Rafael
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20150123/78594c78/attachment.html>


More information about the llvm-dev mailing list