On Wednesday 19 August 2009 11:29, Chris Lattner wrote:> On Aug 19, 2009, at 9:02 AM, Kenneth Uildriks wrote: > > How do you get LLVM methods to return or throw an error to the > > caller's code rather than aborting the process? I'd like my compiler > > to be able to print diagnostic messages, including language source > > lines, whenever LLVM reports a problem. > > Hi Kenneth, > > Recoverable errors are handled with llvm/Support/ErrorHandling.h. We > use asserts for conditions that "cannot happen". These are internal > errors and are not recoverable. The best way to not get one of these > is for your compiler to not have bugs :)We're dealing with this, but it's not a particularly friendly way to operate. Most compilers have some kind of error reporting mechanism and it would be helpful if LLVM provided a way to turn asserts and aborts into hooks that could be plugged into an existing infrastructure. Signal handlers aren't the best solution. Like I said, we're dealing with it but it's something we should be aware of long-term. -Dave
On Wed, Aug 19, 2009 at 2:34 PM, David Greene<dag at cray.com> wrote:> On Wednesday 19 August 2009 11:29, Chris Lattner wrote: >> On Aug 19, 2009, at 9:02 AM, Kenneth Uildriks wrote: >> > How do you get LLVM methods to return or throw an error to the >> > caller's code rather than aborting the process? I'd like my compiler >> > to be able to print diagnostic messages, including language source >> > lines, whenever LLVM reports a problem. >> >> Hi Kenneth, >> >> Recoverable errors are handled with llvm/Support/ErrorHandling.h. We >> use asserts for conditions that "cannot happen". These are internal >> errors and are not recoverable. The best way to not get one of these >> is for your compiler to not have bugs :) > > We're dealing with this, but it's not a particularly friendly way to > operate. Most compilers have some kind of error reporting mechanism > and it would be helpful if LLVM provided a way to turn asserts and > aborts into hooks that could be plugged into an existing infrastructure. > > Signal handlers aren't the best solution. Like I said, we're dealing with > it but it's something we should be aware of long-term.C++ isn't a safe language; there is in fact such a thing as an unrecoverable error, and there isn't really anything we can do about it. -Eli
On Wednesday 19 August 2009 16:43, Eli Friedman wrote:> > We're dealing with this, but it's not a particularly friendly way to > > operate. Most compilers have some kind of error reporting mechanism > > and it would be helpful if LLVM provided a way to turn asserts and > > aborts into hooks that could be plugged into an existing infrastructure. > > > > Signal handlers aren't the best solution. Like I said, we're dealing > > with it but it's something we should be aware of long-term. > > C++ isn't a safe language; there is in fact such a thing as an > unrecoverable error, and there isn't really anything we can do about > it.It's not about recovery, it's about message reporting. Right now the LLVM abort messages are formatted completely differently than aborts from other parts of our compiler. That's not friendly to users. -Dave