LLVM asserts

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 :slight_smile:

-Chris

Do you mean things like assert() and abort() calls? Those are abnormal situations and internal compiler errors, not indicators of a problem in the user's source. If you really want to catch them and do something, you could install a signal handler for SIGABRT, I suppose, and do whatever you want there.

Regards,
   Jim

Please email llvmdev, not me directly.

So things like type mismatches, missing return statements, and whatnot
count as "internal errors"? I guess that makes sense... I'll just
have to do those check on my side then.

Yes. The IR has to be well formed by your frontend.

-Chris

I have done that too recently. Did Mailman stop setting the ReplyTo header?

Please email llvmdev, not me directly.

I have done that too recently. Did Mailman stop setting the ReplyTo
header?

Apparently it mysteriously was changed. I have fixed this so it should direct you to reply to the list.

-Tanya

Hello, Jakob

I have done that too recently. Did Mailman stop setting the ReplyTo
header?

Yes. So, now you should use "reply all", not "reply". It's quite hard
to change the habits :frowning:

Oh, it was on purpose? I'll have to practice then.

Yesterday I replied to one of my own list posts. I felt rather stupid when that one landed in my inbox. (^_^)

No, you ALWAYS check. That way you may also avoid sending that
outrageously sexy personal reply to the list... :-/

    M

Hello, Jakob

I have done that too recently. Did Mailman stop setting the ReplyTo

header?

Yes. So, now you should use “reply all”, not “reply”. It’s quite hard

to change the habits :frowning:

Oh, it was on purpose? I’ll have to practice then.

Yesterday I replied to one of my own list posts. I felt rather stupid
when that one landed in my inbox. (^_^)

I guess Chris changed it, so I’ll change it back to what he had it. It probably would have been better to make an announcement on the list though :wink:

Chris - Can you comment on list why you made this change?

Thanks,
Tanya

It's back now. Thanks.

/jakob

Best practise seems to be to encourage that replies remain on-list.
see http://producingoss.com/en/mailing-lists.html#reply-to

    M

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

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

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

I asked Chris to make this change (but on IRC, so I guess it wasn't
visible on the list).

This matches what we do for cfe-* and one really nice benefit of
getting in the Reply-All habit is that the reply goes both directly to
the sender and to the list.

The problem I perceived was that LLVM is getting so much traffic that
it is quite easy for people to miss replies to commit messages (i.e.,
review feedback) unless they get the message personally.

- Daniel

Sorry, sure. The basic problem it solves is that many people read the commits list (in particular) only infrequently. They post frequently due to commits, and having them in the CC line makes them notice it faster. I was manually cc'ing the person I was responding to on a ton of emails. I consider this to be silly and took mailman's advice of not forcing the reply-to line.

-Chris

This is what ErrorReporting.h is all about.

-Chris

But asserts and aborts don't go through that, right? What's needed is
a way to get those assert and abort messages out to other compiler
components so they have a chance to report them nicely to the user.

Again, it's not a critical issue right now, just one I've thought about
from time to time.

                                 -Dave

I agree this is helpful for the commits list. For the dev list, I'm
not so sure. It's kinda annoying to have to delete messages twice.

                                -Dave