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

Rafael EspĂ­ndola rafael.espindola at gmail.com
Thu Oct 9 17:49:08 PDT 2014


>> I don't thing anyone disagrees that a nice error message is a feature,
>> but it might not be the priority of every code to use a SMDiagnostic.
>> Using report_fatal_error is a reasonable way to start (or an
>> improvement over a misplaced assert/unreachable, like we have in parts
>> of LLVM (pr20485 for example)).
>
> To be clear, I was actually just referring to the message that's being
> passed to report_fatal_error in the second point.

Oh, I missed that point. It is probably better do to something like

template<typename T>
const T& extractOrDie(const ErrorOr<T> &V, const char *Msg) {
  if (V)
    return *V;
  report_fatal_error(Msg);
}

Cheers,
Rafael



More information about the llvm-commits mailing list