HomePhabricator

[Diagnose] Unify MCContext and LLVMContext diagnosing

Authored by ychen on Feb 23 2021, 9:47 AM.

Description

[Diagnose] Unify MCContext and LLVMContext diagnosing

The situation with inline asm/MC error reporting is kind of messy at the
moment. The errors from MC layout are not reliably propagated 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.

Reviewed By: MaskRay

Differential Revision: https://reviews.llvm.org/D97449

Details

Committed
ychenMar 1 2021, 3:58 PM
Reviewer
MaskRay
Differential Revision
D97449: [Diagnose] Unify MCContext and LLVMContext diagnosing
Parents
rG2b5f3f446f36: [Sanitizer][NFC] Fix typo
Branches
Unknown
Tags
Unknown