[PATCH] Add warning capabilities in LLVM (backend part), Take 2
qcolombet at apple.com
Tue Dec 10 16:31:36 PST 2013
Hi dblaikie, rengolin, chandlerc, echristo,
This patch implements the latest proposal discussed a few weeks ago regarding adding warning capabilities in LLVM.
The original RFC:
The latest discussion with the new design:
//// Overview ////
The patch adds a new LLVMContext::diagnose that can be used to communicate to the front-end, if any, that something of interest happened.
The diagnostics are supported by a new abstraction, the DiagnosticInfo class.
The base class contains the following information:
- The kind of the report: What this is this about.
- The severity of the report: How bad this is.
This patch also adds 3 classes:
- DiagnosticInfoInlineAsm: For inline asm reporting. Basically, this diagnostic will be used to switch to the new diagnostic API for LLVMContext::emitError.
- DiagnosticStackSize: For stack size reporting. Comes as a replacement of the hard coded warning in PEI.
- DiagnosticOther: For all other reporting. Features a message with %[0-9]+ specifiers and an array of values. Each specifier will be replaced by the printing of the related index from the array of values.
This patch introduces a new DiagnosticHandlerTy and a new DiagnosticContext that should be set by the front-end to be able to map these diagnostics in its own system.
//// Next Steps ////
- Send the patch for clang (I have it on hold).
- Switch to this reporting for all warnings printing happening in the backend (i.e., get rid of the hard coded warnings).
- Switch LLVMContext::emitError to the new diagnostic API.
- Add an entry in LLVM documentation about this diagnostic reporting feature.
//// Open Questions ////
- Should we make SMDiagnostic a sub class of DiagnosticInfo?
The idea would be to get rid of the InlineAsmDiagHandler.
- Do we want to provide a C API for this?
- Do we want to extend that to fatal error as well?
That would be a nice homogenization of the framework (replace (some of) the calls to report_fatal_error).
Thanks for your reviews.
PS: Hal, DiagnosticPrinter class does not include SCEV or MachineInstr because these are not part of the IR library.
-------------- next part --------------
A non-text attachment was scrubbed...
Size: 25410 bytes
Desc: not available
More information about the llvm-commits