Just opening files in vscode and seeing what clangd flags.
Some edits to ostream.h to stop it from getting flagged (the usage pattern means it's not always obviously used).
At present, CHECK/FATAL print their own stack trace. This switches to just using std::abort for the stack trace, as well as the CHECK printing more completely.
This has a few consequences:
1) I'm now buffering the FATAL strings in order to print it later.
2) We now print the bug report message and program arguments on failure. This is part of pretty printing and was elided before.
3) We can now have pretty printing on FATAL, e.g. to show the stacks we're building in the parser.
This is a variation on #1339 and also fixes#1338.
The important difference from #1339 is that this works to retain the
benefits of #1216 which seem important -- both the clarity of printing
the message last and the correctness of actually showing the correct
line number in the backtrace.
The approach in this patch is to disable LLVM's error handling just
before using `std::abort()`. This should give us roughly the best of
both worlds.
This PR also fixes an issue where we wouldn't run the file-cleanup
actions that the LLVM `std::abort()` handler does. This almost certainly
doesn't yet matter, but likely would in the future.
We should separately consider adding back information about filing bugs
that roughly corresponds to the error message that LLVM itself prints.
I've not tried to replicate that from #1339 here and just focused on
getting to `std::abort()` while preserving the desired order of messages
and stack trace locations.
Before, if the llvm hook to print a stack trace on CHECK was bound, it would trace after the message rather than before the message. I'm thinking swapping the order will generally be easier to debug.