[PATCH] Add ErrorOr<>::getOrDie() which uses report_fatal_error instead of assert.

Rafael EspĂ­ndola rafael.espindola at gmail.com
Thu Oct 9 16:07:43 PDT 2014


>> Having said that, calling report_fatal_error in a class that is pretty
>> independent from llvm looks a bit odd.
>
>
> Well, this class is a part of LLVM, so it could use other LLVM facilities.

Sure, but llvm is layered. Right now ErrorOr.h uses only AilgnOf and
PointerIntPair.

>>
>> Could we maybe have something
>> like
>>
>> template<typename T>
>> const T& extractOrDie(const ErrorOr<T> &V) {
>>   if (V)
>>     return *V;
>>   report_fatal_error("foo");
>> }
>>
>> defined in some other header?
>
>
> It can be a standalone function, if you think that it makes sense keeping
> ErrorOr<> dependencies on LLVM minimal. But the function would be closely
> tied to ErrorOr<>, and it looks reasonable to put it to the same header.

What abut ErrorHandling.h? Reid, Justin, would you guys be OK with that?

Cheers,
Rafael



More information about the llvm-commits mailing list