The situation with inline asm/MC error reporting is kind of messy at the
moment. The errors from MC layout are not reliably propagated(D96931) and users
have to specify an inlineasm handler separately to get inlineasm
diagnose. The latter issue is not a correctness issue but could be improved.
- Kill LLVMContext inlineasm diagnose handler and migrate it to use DiagnoseInfo/DiagnoseHandler.
- Introduce DiagnoseInfoSrcMgr to diagnose SourceMgr backed errors. This covers use cases like inlineasm, MC, and any clients using SourceMgr.
- Move AsmPrinter::SrcMgrDiagInfo and its instance to MCContext. The next step is to combine MCContext::SrcMgr and MCContext::InlineSrcMgr because in all use cases, only one of them is used.
- If LLVMContext is available, let MCContext uses LLVMContext's diagnose handler; if LLVMContext is not available, MCContext uses its own default diagnose handler which just prints SMDiagnostic.
- Change a few clients(Clang, llc, lldb) to use the new way of reporting.
StringRef::consume_front
I know you are moving code, but do you know why it needs to chop off the error: prefix (why does the message get a prefix here?)